Fix nested VISIBILITY property
* lisp/org.el (org-set-visibility-according-to-property): Fix nested VISIBILITY property. Small refactoring. * testing/lisp/test-org.el (test-org/set-visibility-according-to-property): Add test. Reported-by: Michael Maurer <maurer.michael@gmail.com> <http://lists.gnu.org/r/emacs-orgmode/2019-01/msg00402.html>
This commit is contained in:
parent
4761fab2ff
commit
70c90c2cb5
48
lisp/org.el
48
lisp/org.el
|
@ -7286,30 +7286,32 @@ With a numeric prefix, show all headlines up to that level."
|
|||
(org-cycle-show-empty-lines t)))
|
||||
|
||||
(defun org-set-visibility-according-to-property ()
|
||||
"Switch subtree visibilities according to :VISIBILITY: property."
|
||||
"Switch subtree visibility according to VISIBILITY property."
|
||||
(interactive)
|
||||
(org-with-wide-buffer
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "^[ \t]*:VISIBILITY:" nil t)
|
||||
(if (not (org-at-property-p)) (outline-next-heading)
|
||||
(let ((state (match-string 3)))
|
||||
(save-excursion
|
||||
(org-back-to-heading t)
|
||||
(outline-hide-subtree)
|
||||
(org-reveal)
|
||||
(cond
|
||||
((equal state "folded")
|
||||
(outline-hide-subtree))
|
||||
((equal state "children")
|
||||
(org-show-hidden-entry)
|
||||
(org-show-children))
|
||||
((equal state "content")
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
(org-narrow-to-subtree)
|
||||
(org-content))))
|
||||
((member state '("all" "showall"))
|
||||
(outline-show-subtree)))))))))
|
||||
(let ((regexp (org-re-property "VISIBILITY")))
|
||||
(org-with-point-at 1
|
||||
(while (re-search-forward regexp nil t)
|
||||
(let ((state (match-string 3)))
|
||||
(if (not (org-at-property-p)) (outline-next-heading)
|
||||
(save-excursion
|
||||
(org-back-to-heading t)
|
||||
(outline-hide-subtree)
|
||||
(org-reveal)
|
||||
(pcase state
|
||||
("folded"
|
||||
(outline-hide-subtree))
|
||||
("children"
|
||||
(org-show-hidden-entry)
|
||||
(org-show-children))
|
||||
("content"
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
(org-narrow-to-subtree)
|
||||
(org-content))))
|
||||
((or "all" "showall")
|
||||
(outline-show-subtree))
|
||||
(_ nil)))
|
||||
(org-end-of-subtree)))))))
|
||||
|
||||
(defun org-overview ()
|
||||
"Switch to overview mode, showing only top-level headlines.
|
||||
|
|
|
@ -7489,7 +7489,21 @@ Contents
|
|||
Contents
|
||||
*** <point>c"
|
||||
(org-set-visibility-according-to-property)
|
||||
(not (invisible-p (point))))))
|
||||
(not (invisible-p (point)))))
|
||||
;; When VISIBILITY properties are nested, ignore inner ones.
|
||||
(should
|
||||
(org-test-with-temp-text
|
||||
"
|
||||
* A
|
||||
:PROPERTIES:
|
||||
:VISIBILITY: folded
|
||||
:END:
|
||||
** <point>B
|
||||
:PROPERTIES:
|
||||
:VISIBILITY: folded
|
||||
:END:"
|
||||
(org-set-visibility-according-to-property)
|
||||
(invisible-p (point)))))
|
||||
|
||||
|
||||
;;; Yank and Kill
|
||||
|
|
Loading…
Reference in New Issue