emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* BUG: org-cycle opens archived subtrees when the archive property is present
@ 2010-02-12 17:17 Emilio Jesús Gallego Arias
  2010-02-15 12:02 ` [PATCH] " Emilio Jesús Gallego Arias
  0 siblings, 1 reply; 3+ messages in thread
From: Emilio Jesús Gallego Arias @ 2010-02-12 17:17 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 608 bytes --]

Dear org-mode developers,

first and foremost thank you for this wonderful tool.

I think I hit a bug in org-cycle: If the tree has the ARCHIVE property
set and some subtree has the ARCHIVE tag, org-cycle will open the
archive subtree as if we were using C-Tab.

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'm using current org git and I've reproduced it without any specific
org-mode configuration.

Regards,
Emilio

[-- Attachment #1.2: Type: application/pgp-signature, Size: 835 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] Re: BUG: org-cycle opens archived subtrees when the archive property is present
  2010-02-12 17:17 BUG: org-cycle opens archived subtrees when the archive property is present Emilio Jesús Gallego Arias
@ 2010-02-15 12:02 ` Emilio Jesús Gallego Arias
  2010-02-16  4:53   ` Carsten Dominik
  0 siblings, 1 reply; 3+ messages in thread
From: Emilio Jesús Gallego Arias @ 2010-02-15 12:02 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1.1: Type: text/plain, Size: 1317 bytes --]

egallego@babel.ls.fi.upm.es (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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.2: Patch --]
[-- Type: text/x-diff, Size: 500 bytes --]

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 #1.2: Type: application/pgp-signature, Size: 835 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Re: BUG: org-cycle opens archived subtrees when the archive property is present
  2010-02-15 12:02 ` [PATCH] " Emilio Jesús Gallego Arias
@ 2010-02-16  4:53   ` Carsten Dominik
  0 siblings, 0 replies; 3+ messages in thread
From: Carsten Dominik @ 2010-02-16  4:53 UTC (permalink / raw)
  To: Emilio Jesús Gallego Arias; +Cc: emacs-orgmode

Hi Emilio,

thanks for the bug report and correct analysis - I have applied your  
patch.

- Carsten

On Feb 15, 2010, at 1:02 PM, Emilio Jesús Gallego Arias wrote:

> egallego@babel.ls.fi.upm.es (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
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

- Carsten

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-02-16  4:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-12 17:17 BUG: org-cycle opens archived subtrees when the archive property is present Emilio Jesús Gallego Arias
2010-02-15 12:02 ` [PATCH] " Emilio Jesús Gallego Arias
2010-02-16  4:53   ` Carsten Dominik

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).