emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] [PATCH] Re: BUG: org-cycle opens archived subtrees when the ar


From: Emilio Jesús Gallego Arias
Subject: [Orgmode] [PATCH] Re: BUG: org-cycle opens archived subtrees when the archive property is present
Date: Mon, 15 Feb 2010 13:02:25 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.92 (gnu/linux)

address@hidden (Emilio Jesús Gallego Arias) writes:

> To reproduce save this minimal org file:
>
> #+STARTUP: even
> * A
>   :PROPERTIES:
>   :ARCHIVE: a
>   :END:
> ** B                                                          :ARCHIVE:
>    Some text
>
> and hit TAB when in the * A headline; then the ** B headline contents
> will be incorrectly shown.

I've found the culprit in org-hide-archived-subtrees:

,----
| (defun org-hide-archived-subtrees (beg end)
|   "Re-hide all archived subtrees after a visibility state change."
|   (save-excursion
|     (let* ((re (concat ":" org-archive-tag ":")))
|       (goto-char beg)
|       (while (re-search-forward re end t)
|       (and (org-on-heading-p) (org-flag-subtree t))
|       (org-end-of-subtree t)))))
`----

The problem is that the RE matches the first archive "property" and
then does an org-end-of-subtree which skips all the subtrees of the
parent tree where the ARCHIVE property is located.

I've replaced this part

|       (and (org-on-heading-p) (org-flag-subtree t))
|       (org-end-of-subtree t)))))

by

|       (when (org-on-heading-p)
|             (org-flag-subtree t)
|             (org-end-of-subtree t)))))))

so org-end-of-subtree is only called if we are really in a headline. I
think that makes sense.

Git patch attached.

Regards,
Emilio
diff --git a/lisp/org.el b/lisp/org.el
index f237367..d2db359 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -3597,8 +3597,9 @@ collapsed state."
     (let* ((re (concat ":" org-archive-tag ":")))
       (goto-char beg)
       (while (re-search-forward re end t)
-       (and (org-on-heading-p) (org-flag-subtree t))
-       (org-end-of-subtree t)))))
+       (when (org-on-heading-p)
+             (org-flag-subtree t)
+             (org-end-of-subtree t))))))
 
 (defun org-flag-subtree (flag)
   (save-excursion

Attachment: pgp8gDtjB2zc3.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]