From b1e7ec501039e351e7363cee99a16129b0b8caf2 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Fri, 26 Sep 2008 17:06:17 +0200 Subject: [PATCH] Fix bug with updating parent statistics when children are hidden. Report by Charles Sebold. --- lisp/ChangeLog | 6 ++++++ lisp/org.el | 31 ++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8f2b71fd5..0986465c7 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2008-09-26 Carsten Dominik + + * 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 * org-table.el (org-table-sum): Do not format the result with %g, diff --git a/lisp/org.el b/lisp/org.el index 398809ddf..2d27a9b84 100644 --- a/lisp/org.el +++ b/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