From 567331e169cbf5b788ec1f8bc0d4a359fc783a3a Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Fri, 31 Jul 2009 09:17:27 +0800 Subject: [PATCH] Switch directly from CHILDREN to FOLDED if there is no subtree. Also send a meaningful message FOLDED (NO SUBTREE) to avoid confusion. --- lisp/ChangeLog | 4 ++++ lisp/org.el | 20 +++++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 18b0abe9f..586ad98f0 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -2,6 +2,10 @@ * org.el (org-make-link-regexps): Don't exclude parentheses from `org-plain-link-re' + (org-cycle-internal-local): When locally cycling, switch directly + from CHILDREN to FOLDED if there is no subtree + (org-cycle): Update the docstring to document the new behavior of + `org-cycle-internal-local'. 2009-07-29 Nicolas Goaziou (tiny change) diff --git a/lisp/org.el b/lisp/org.el index b2ce54163..ff8506b18 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -4740,6 +4740,7 @@ in special contexts. From this state, you can move to one of the children and zoom in further. 3. SUBTREE: Show the entire subtree, including body text. + If there is no subtree, switch directly from CHILDREN to FOLDED. - When there is a numeric prefix, go up to a heading with level ARG, do a `show-subtree' and return to the previous cursor position. If ARG @@ -4937,11 +4938,20 @@ in special contexts. ((and (eq last-command this-command) (eq org-cycle-subtree-status 'children)) ;; We just showed the children, now show everything. - (run-hook-with-args 'org-pre-cycle-hook 'subtree) - (org-show-subtree) - (message "SUBTREE") - (setq org-cycle-subtree-status 'subtree) - (run-hook-with-args 'org-cycle-hook 'subtree)) + (if (save-excursion + (beginning-of-line 2) + (re-search-forward org-complex-heading-regexp eos t)) + (progn + (run-hook-with-args 'org-pre-cycle-hook 'subtree) + (org-show-subtree) + (message "SUBTREE") + (setq org-cycle-subtree-status 'subtree) + (run-hook-with-args 'org-cycle-hook 'subtree)) + (run-hook-with-args 'org-pre-cycle-hook 'folded) + (hide-subtree) + (message "FOLDED (NO SUBTREE)") + (setq org-cycle-subtree-status 'folded) + (run-hook-with-args 'org-cycle-hook 'folded))) (t ;; Default action: hide the subtree. (run-hook-with-args 'org-pre-cycle-hook 'folded)