Browse Source

org-cycle-set-visibility-according-to-property: Do not change ancestor visibility

* lisp/org-cycle.el (org-cycle-set-visibility-according-to-property):
Do not unconditionally run `org-fold-reveal' for headlines with
"VISIBILITY" property.  `org-fold-reveal' can break the global
visibility and ancestor headline visibility settings.
*
testing/lisp/test-org-fold.el (test-org-fold/set-visibility-according-to-property):
Add test.

Reported-by: Eduardo Suarez <esuarez@itccanarias.org>
Link: https://orgmode.org/list/20220409202736.GA28127@itccanarias.org
Ihor Radchenko 1 year ago
parent
commit
eb15341b3c
2 changed files with 30 additions and 1 deletions
  1. 0 1
      lisp/org-cycle.el
  2. 30 0
      testing/lisp/test-org-fold.el

+ 0 - 1
lisp/org-cycle.el

@@ -630,7 +630,6 @@ With a numeric prefix, show all headlines up to that level."
 	    (save-excursion
 	      (org-back-to-heading t)
 	      (org-fold-subtree t)
-	      (org-fold-reveal)
 	      (pcase state
 		("folded"
 		 (org-fold-subtree t))

+ 30 - 0
testing/lisp/test-org-fold.el

@@ -285,6 +285,36 @@
 ** <point>b"
      (org-set-visibility-according-to-property)
      (invisible-p (point))))
+  (org-test-with-temp-text
+      "<point>
+#+STARTUP: overview
+* A
+** AA
+** AB
+*** ABA
+:PROPERTIES:
+:VISIBILITY: folded
+:END:
+**** ABAA
+**** ABAB
+**** ABAC
+** AC
+* B
+"
+    (org-set-regexps-and-options)
+    (org-cycle-set-startup-visibility)
+    (search-forward "A")
+    (should-not (invisible-p (point)))
+    (search-forward "AB")
+    (should (invisible-p (point)))
+    (search-forward "ABA")
+    (should (invisible-p (point)))
+    (search-forward "ABAB")
+    (should (invisible-p (point)))
+    (search-forward "AC")
+    (should (invisible-p (point)))
+    (search-forward "B")
+    (should-not (invisible-p (point))))
   ;; "children" state.
   (should
    (org-test-with-temp-text