From a5c977b43e6937f0f38f49121b0128c78219eeed Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Tue, 30 Jan 2024 14:43:08 +0100 Subject: [PATCH] org-cycle-set-visibility-according-to-property: Honor inner VISIBILITY settings * lisp/org-cycle.el (org-cycle-set-visibility-according-to-property): Do not ignore :VISIBILITY: properties when parent also has :VISIBILITY:. * testing/lisp/test-org-fold.el (test-org-fold/set-visibility-according-to-property): Add new test. Similar to how :VISIBILITY: overrides #+STARTUP folding settings, child :VISIBILITY: should override parent :VISIBILITY:. The previous version of the code was skipping child VISIBILITY property to address https://lists.gnu.org/r/emacs-orgmode/2019-01/msg00402.html However, that problem in that bug report was not with child VISIBILITY property, but rather with previous implementation detail that `org-reveal' was called prior to setting VISIBILITY. That affected parent headings as well and no longer a problem. Reported-by: John Mathena Link: https://orgmode.org/list/87tucu99od.fsf@localhost --- lisp/org-cycle.el | 3 +-- testing/lisp/test-org-fold.el | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lisp/org-cycle.el b/lisp/org-cycle.el index c1602f7cd..78d723130 100644 --- a/lisp/org-cycle.el +++ b/lisp/org-cycle.el @@ -667,8 +667,7 @@ With a numeric prefix, show all headlines up to that level." (org-cycle-content)))) ((or "all" "showall") (org-fold-show-subtree)) - (_ nil))) - (org-end-of-subtree t))))))) + (_ nil))))))))) (defun org-cycle-overview () "Switch to overview mode, showing only top-level headlines." diff --git a/testing/lisp/test-org-fold.el b/testing/lisp/test-org-fold.el index 9f15f0a38..a671800ff 100644 --- a/testing/lisp/test-org-fold.el +++ b/testing/lisp/test-org-fold.el @@ -418,7 +418,8 @@ Contents *** c" (org-set-visibility-according-to-property) (not (invisible-p (point))))) - ;; When VISIBILITY properties are nested, ignore inner ones. + ;; When VISIBILITY properties are nested, do not alter parent + ;; visibility unless necessary. (should (org-test-with-temp-text " @@ -431,7 +432,20 @@ Contents :VISIBILITY: folded :END:" (org-set-visibility-according-to-property) - (invisible-p (point))))) + (invisible-p (point)))) + (should + (org-test-with-temp-text + " +* A +:PROPERTIES: +:VISIBILITY: folded +:END: +** B +:PROPERTIES: +:VISIBILITY: content +:END:" + (org-set-visibility-according-to-property) + (not (invisible-p (point)))))) (ert-deftest test-org-fold/visibility-show-branches () "Test visibility of inline archived subtrees."