From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: Possibly Bug in function org-scan-tags Date: Fri, 16 Dec 2011 18:05:31 -0500 Message-ID: <9202.1324076731@alphaville.americas.hpqcorp.net> References: Reply-To: nicholas.dokos@hp.com Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([140.186.70.92]:43069) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RbgqN-0002QC-FS for emacs-orgmode@gnu.org; Fri, 16 Dec 2011 18:05:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RbgqL-0001Wa-Hl for emacs-orgmode@gnu.org; Fri, 16 Dec 2011 18:05:35 -0500 Received: from g5t0007.atlanta.hp.com ([15.192.0.44]:19172) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RbgqL-0001Vn-DP for emacs-orgmode@gnu.org; Fri, 16 Dec 2011 18:05:33 -0500 In-Reply-To: Message from bala mayam of "Fri\, 16 Dec 2011 00\:56\:43 +0200." List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: bala mayam Cc: nicholas.dokos@hp.com, emacs-orgmode@gnu.org bala mayam wrote: > The patch has error, it does not work for the following example file > /tmp/example.org > * DONE s1 > * DONE s2 > * DONE s3 >=20 > The below patch works for all the cases >=20 > 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 th= e outpu > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ;; Get the correct position fr= om where to continue > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (if org-map-continue-from > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (goto-= char org-map-continue-from) > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (and (=3D (point) lspos= ) (end-of-line 1))))) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (and (=3D (point) lspos= ) (end-of-line 1))) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (setq org-map-continue-from nil))) > =C2=A0=C2=A0=C2=A0=C2=A0 (when (and (eq action 'sparse-tree) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 (not org-sparse-tree-open-archived-trees)) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (org-hide-archived-subtrees (point-m= in) (point-max))) >=20 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 (=3D (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