Browse Source

Cycle lists properly.

* org-list.el (org-list-bottom-point): Be sure to check real
  ORG-OUTLINE-REGEXP and not outline-regexp, that might be modified.
* org.el (org-cycle-internal-local): cycle up to end of subtree or end
  of item if we are in a list.
Nicolas Goaziou 14 years ago
parent
commit
1f41236014
2 changed files with 13 additions and 9 deletions
  1. 4 1
      lisp/org-list.el
  2. 9 8
      lisp/org.el

+ 4 - 1
lisp/org-list.el

@@ -421,7 +421,10 @@ A checkbox is blocked if all of the following conditions are fulfilled:
   (save-excursion
     (and (org-in-item-p)
 	 (let ((pos (org-beginning-of-item))
-	       (bound (or (and (outline-next-heading)
+	       (bound (or (and (let ((outline-regexp org-outline-regexp))
+				 ;; we need set the default regexp
+				 ;; because folding change its value.
+				 (outline-next-heading))
 			       (skip-chars-backward " \t\r\n")
 			       (1+ (point-at-eol)))
 			  (point-max))))

+ 9 - 8
lisp/org.el

@@ -5900,12 +5900,13 @@ in special contexts.
 	(outline-next-heading)
 	(setq has-children (and (org-at-heading-p t)
 				(> (funcall outline-level) level))))
-      (org-end-of-subtree t)
-      (unless (eobp)
-	(skip-chars-forward " \t\n")
-	(beginning-of-line 1) ; in case this is an item
-	)
-      (setq eos (if (eobp) (point) (1- (point)))))
+      ;; if we're in a list, org-end-of-subtree is in fact org-end-of-item.
+      (if (org-at-item-p)
+	  (setq eos (1- (org-end-of-item)))
+	(org-end-of-subtree t)
+	(unless (eobp)
+	  (skip-chars-forward " \t\n"))
+	(setq eos (if (eobp) (point) (1- (point))))))
     ;; Find out what to do next and set `this-command'
     (cond
      ((= eos eoh)
@@ -5939,14 +5940,14 @@ in special contexts.
       ;; We just showed the children, or no children are there,
       ;; now show everything.
       (run-hook-with-args 'org-pre-cycle-hook 'subtree)
-      (org-show-subtree)
+      (outline-flag-region eoh eos nil)
       (message (if children-skipped "SUBTREE (NO CHILDREN)" "SUBTREE"))
       (setq org-cycle-subtree-status 'subtree)
       (run-hook-with-args 'org-cycle-hook 'subtree))
      (t
       ;; Default action: hide the subtree.
       (run-hook-with-args 'org-pre-cycle-hook 'folded)
-      (hide-subtree)
+      (outline-flag-region eoh eos t)
       (message "FOLDED")
       (setq org-cycle-subtree-status 'folded)
       (run-hook-with-args 'org-cycle-hook 'folded)))))