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 <jmmathena@gmail.com>
Link: https://orgmode.org/list/87tucu99od.fsf@localhost
This commit is contained in:
Ihor Radchenko 2024-01-30 14:43:08 +01:00
parent e2144f5f32
commit a5c977b43e
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
2 changed files with 17 additions and 4 deletions

View File

@ -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."

View File

@ -418,7 +418,8 @@ Contents
*** <point>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:
** <point>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."