emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nick Dokos <nicholas.dokos@hp.com>
To: bala mayam <balamayam@gmail.com>
Cc: nicholas.dokos@hp.com, emacs-orgmode@gnu.org
Subject: Re: Possibly Bug in function org-scan-tags
Date: Fri, 16 Dec 2011 18:05:31 -0500	[thread overview]
Message-ID: <9202.1324076731@alphaville.americas.hpqcorp.net> (raw)
In-Reply-To: Message from bala mayam <balamayam@gmail.com> of "Fri\, 16 Dec 2011 00\:56\:43 +0200." <CAGo50eOhmavm+i9gtbpE63CEFdBvNrrK6KCRKzm0Lp9nWhuPFA@mail.gmail.com>

bala mayam <balamayam@gmail.com> wrote:

> The patch has error, it does not work for the following example file
> /tmp/example.org
> * DONE s1
> * DONE s2
> * DONE s3
> 
> The below patch works for all the cases
> 
> diff --git a/lisp/org.el b/lisp/org.el
> index 8a1fbd3..93d603f 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -12858,7 +12858,8 @@ only lines with a TODO keyword are included in the outpu
>         ;; Get the correct position from where to continue
>         (if org-map-continue-from
>             (goto-char org-map-continue-from)
> -         (and (= (point) lspos) (end-of-line 1)))))
> +         (and (= (point) lspos) (end-of-line 1)))
> +       (setq org-map-continue-from nil)))
>      (when (and (eq action 'sparse-tree)
>                (not org-sparse-tree-open-archived-trees))
>        (org-hide-archived-subtrees (point-min) (point-max)))
> 

OK, I've looked at it some more and unless I'm mistaken again, I think
you are correct that it is a bug. Here's the structure of the relevant
code in org-scan-tags:

     ...
     (while (re-search-forward re nil t)
	(catch :skip
	   ...
	   (when ...
	      (cond
	         ((eq action 'sparse-tree)
		  ... do the sparse-tree stuff...)

		 ((eq action 'agenda)
		  ... do the agenda stuff ...)

		 ((functionp action)   ; user provided a function - the case here
                  (setq org-map-continue-from nil)
	          (save-excursion
		  	(setq rtn1 (funcall action))
			(push rtn1 rtn)))

		 (t (error "Invalid action")))

	      ... stuff after the cond ...
           ) ; closes the when form
	) ; closes the catch

	;; Get the correct position from where to continue
	(if org-map-continue-from
	    (goto-char org-map-continue-from)
	  (and (= (point) lspos) (end-of-line 1)))
    ) ; closes the while

    ...

So in the case of a user-supplied action, org-map-continue-from is
initialized to nil and then the function is called. The function (as in
your case) may modify org-map-continue-from which is then used at the
end of the while loop (and not reset to nil, as you observed, so next
time around, it will be non-nil even if we don't go through the
user-provided action).

I would fix it by pulling the (setq org-map-continue-from nil) from just
before the calling of the function all the way out to the top of the loop,
instead of adding another one at the end as you did, but that's a minor
point.

Nick

  parent reply	other threads:[~2011-12-16 23:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-15  1:18 Possibly Bug in function org-scan-tags bala subramaniyam
2011-12-15 22:56 ` bala mayam
2011-12-16  6:41   ` Nick Dokos
2011-12-16  7:16     ` Nick Dokos
2011-12-16 23:05   ` Nick Dokos [this message]
2011-12-31  8:29 ` Carsten Dominik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9202.1324076731@alphaville.americas.hpqcorp.net \
    --to=nicholas.dokos@hp.com \
    --cc=balamayam@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).