summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2018-01-02 14:12:20 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2018-01-02 14:13:46 +0100
commit16c7ae7996a95f8091eb80a61dd85db817ca5d90 (patch)
treec8ef448dd4213c8d6bd4c42ca2e91e0ffdefd522
parentec6813157e450ef0f5f4915b5782232d8466ce3f (diff)
downloadorg-mode-16c7ae7996a95f8091eb80a61dd85db817ca5d90.tar.gz
Fix handling nested VISIBILITY properties
* lisp/org.el (org-set-visibility-according-to-property): Fix handling nested VISIBILITY properties. * testing/lisp/test-org.el (test-org/set-visibility-according-to-property): New test. Reported-by: Michael Maurer <maurer.michael@gmail.com> <http://lists.gnu.org/r/emacs-orgmode/2018-01/msg00012.html>
-rw-r--r--lisp/org.el32
-rw-r--r--testing/lisp/test-org.el89
2 files changed, 106 insertions, 15 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 8264422..5272061 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -1,7 +1,7 @@
;;; org.el --- Outline-based notes management and organizer -*- lexical-binding: t; -*-
;; Carstens outline-mode for keeping track of everything.
-;; Copyright (C) 2004-2017 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
;;
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Maintainer: Carsten Dominik <carsten at orgmode dot org>
@@ -7023,20 +7023,22 @@ With a numeric prefix, show all headlines up to that level."
(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)))))))
+ (org-reveal))
+ (cond
+ ((equal state "folded")
+ (outline-hide-subtree)
+ (org-end-of-subtree t t))
+ ((equal state "children")
+ (org-show-hidden-entry)
+ (org-show-children))
+ ((equal state "content")
+ (save-excursion
+ (save-restriction
+ (org-narrow-to-subtree)
+ (org-content)))
+ (org-end-of-subtree t t))
+ ((member state '("all" "showall"))
+ (outline-show-subtree))))))
(unless no-cleanup
(org-cycle-hide-archived-subtrees 'all)
(org-cycle-hide-drawers 'all)
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index e1ef482..a102d5e 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -6704,6 +6704,95 @@ CLOCK: [2012-03-29 Thu 10:00]--[2012-03-29 Thu 16:40] => 6:40"
(org-copy-visible (point-min) (point-max))
(current-kill 0 t))))))
+(ert-deftest test-org/set-visibility-according-to-property ()
+ "Test `org-set-visibility-according-to-property' specifications."
+ ;; "folded" state.
+ (should
+ (org-test-with-temp-text
+ "
+* a
+:PROPERTIES:
+:VISIBILITY: folded
+:END:
+** <point>b"
+ (org-set-visibility-according-to-property)
+ (invisible-p (point))))
+ ;; "children" state.
+ (should
+ (org-test-with-temp-text
+ "
+* a
+:PROPERTIES:
+:VISIBILITY: children
+:END:
+** b
+<point>Contents
+** c"
+ (org-set-visibility-according-to-property)
+ (invisible-p (point))))
+ (should
+ (org-test-with-temp-text
+ "
+* a
+:PROPERTIES:
+:VISIBILITY: children
+:END:
+** b
+Contents
+*** <point>c"
+ (org-set-visibility-according-to-property)
+ (invisible-p (point))))
+ ;; "content" state.
+ (should
+ (org-test-with-temp-text
+ "
+* a
+:PROPERTIES:
+:VISIBILITY: content
+:END:
+** b
+<point>Contents
+*** c"
+ (org-set-visibility-according-to-property)
+ (invisible-p (point))))
+ (should
+ (org-test-with-temp-text
+ "
+* a
+:PROPERTIES:
+:VISIBILITY: content
+:END:
+** b
+Contents
+*** <point>c"
+ (org-set-visibility-according-to-property)
+ (not (invisible-p (point)))))
+ ;; "showall" state.
+ (should
+ (org-test-with-temp-text
+ "
+* a
+:PROPERTIES:
+:VISIBILITY: showall
+:END:
+** b
+<point>Contents
+*** c"
+ (org-set-visibility-according-to-property)
+ (not (invisible-p (point)))))
+ (should
+ (org-test-with-temp-text
+ "
+* a
+:PROPERTIES:
+:VISIBILITY: showall
+:END:
+** b
+Contents
+*** <point>c"
+ (org-set-visibility-according-to-property)
+ (not (invisible-p (point))))))
+
(provide 'test-org)