Browse Source

Switch directly from CHILDREN to FOLDED if there is no subtree.

Also send a meaningful message FOLDED (NO SUBTREE) to avoid confusion.
Bastien Guerry 16 years ago
parent
commit
567331e169
2 changed files with 19 additions and 5 deletions
  1. 4 0
      lisp/ChangeLog
  2. 15 5
      lisp/org.el

+ 4 - 0
lisp/ChangeLog

@@ -2,6 +2,10 @@
 
 
 	* org.el (org-make-link-regexps): Don't exclude parentheses from
 	* org.el (org-make-link-regexps): Don't exclude parentheses from
 	`org-plain-link-re'
 	`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 <n.goaziou@neuf.fr>  (tiny change)
 2009-07-29  Nicolas Goaziou <n.goaziou@neuf.fr>  (tiny change)
 
 

+ 15 - 5
lisp/org.el

@@ -4740,6 +4740,7 @@ in special contexts.
                From this state, you can move to one of the children
                From this state, you can move to one of the children
                and zoom in further.
                and zoom in further.
   3. SUBTREE:  Show the entire subtree, including body text.
   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
 - 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
   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)
      ((and (eq last-command this-command)
 	   (eq org-cycle-subtree-status 'children))
 	   (eq org-cycle-subtree-status 'children))
       ;; We just showed the children, now show everything.
       ;; 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
      (t
       ;; Default action: hide the subtree.
       ;; Default action: hide the subtree.
       (run-hook-with-args 'org-pre-cycle-hook 'folded)
       (run-hook-with-args 'org-pre-cycle-hook 'folded)