Browse Source

Fix bug with updating parent statistics when children are hidden.

Report by Charles Sebold.
Carsten Dominik 17 years ago
parent
commit
b1e7ec5010
2 changed files with 36 additions and 1 deletions
  1. 6 0
      lisp/ChangeLog
  2. 30 1
      lisp/org.el

+ 6 - 0
lisp/ChangeLog

@@ -1,3 +1,9 @@
+2008-09-26  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org.el (org-get-next-sibling, org-forward-same-level): New
+	functions, similar to the outline versions, but invisible headings
+	are OK.
+
 2008-09-24  Carsten Dominik  <dominik@science.uva.nl>
 
 	* org-table.el (org-table-sum): Do not format the result with %g,

+ 30 - 1
lisp/org.el

@@ -7881,7 +7881,7 @@ For calling through lisp, arg is also interpreted in the following way:
 	    (and (member kwd org-done-keywords)
 		 (setq cnt-done (1+ cnt-done)))
 	    (condition-case nil
-		(outline-forward-same-level 1)
+		(org-forward-same-level 1)
 	      (error (end-of-line 1)))))
 	(replace-match 
 	 (if is-percent
@@ -13864,6 +13864,35 @@ When ENTRY is non-nil, show the entire entry."
 			   (save-excursion (outline-end-of-heading) (point))
 			   flag))))
 
+(defun org-forward-same-level (arg)
+  "Move forward to the ARG'th subheading at same level as this one.
+Stop at the first and last subheadings of a superior heading.
+This is like outline-forward-same-level, but invisible headings are ok."
+  (interactive "p")
+  (outline-back-to-heading t)
+  (while (> arg 0)
+    (let ((point-to-move-to (save-excursion
+			      (org-get-next-sibling))))
+      (if point-to-move-to
+	  (progn
+	    (goto-char point-to-move-to)
+	    (setq arg (1- arg)))
+	(progn
+	  (setq arg 0)
+	  (error "No following same-level heading"))))))
+
+(defun org-get-next-sibling ()
+  "Move to next heading of the same level, and return point.
+If there is no such heading, return nil.
+This is like outline-next-sibling, but invisible headings are ok."
+  (let ((level (funcall outline-level)))
+    (outline-next-heading)
+    (while (and (not (eobp)) (> (funcall outline-level) level))
+      (outline-next-heading))
+    (if (or (eobp) (< (funcall outline-level) level))
+	nil
+      (point))))
+
 (defun org-end-of-subtree (&optional invisible-OK to-heading)
   ;; This is an exact copy of the original function, but it uses
   ;; `org-back-to-heading', to make it work also in invisible