From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: org-map-entries and org-map-continue-from Date: Mon, 28 Feb 2011 14:02:39 -0500 Message-ID: <26540.1298919759@alphaville.dokosmarshall.org> References: <87oc5watpj.fsf@berkeley.edu> Reply-To: nicholas.dokos@hp.com Return-path: Received: from [140.186.70.92] (port=35227 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pu8Mx-0007db-WF for emacs-orgmode@gnu.org; Mon, 28 Feb 2011 14:02:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pu8Ms-0000y5-Qo for emacs-orgmode@gnu.org; Mon, 28 Feb 2011 14:02:56 -0500 Received: from vms173013pub.verizon.net ([206.46.173.13]:61310) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pu8Ms-0000xh-LQ for emacs-orgmode@gnu.org; Mon, 28 Feb 2011 14:02:50 -0500 Received: from alphaville.dokosmarshall.org ([unknown] [173.76.32.106]) by vms173013.mailsrvcs.net (Sun Java(tm) System Messaging Server 7u2-7.02 32bit (built Apr 16 2009)) with ESMTPA id <0LHC003MVCWF7EU0@vms173013.mailsrvcs.net> for emacs-orgmode@gnu.org; Mon, 28 Feb 2011 13:02:41 -0600 (CST) In-reply-to: Message from Richard Lawrence of "Mon, 28 Feb 2011 10:40:24 PST." <87oc5watpj.fsf@berkeley.edu> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Richard Lawrence Cc: nicholas.dokos@hp.com, emacs-orgmode@gnu.org Richard Lawrence wrote: > For a simple example, suppose I write: > #+BEGIN_SRC emacs-lisp > (defun get-export-filenames () > (interactive) > (setq export-files '()) > (progn > (org-map-entries > (lambda () > (setq org-map-continue-from (outline-next-heading)) > (let ((org-trust-scanner-tags t)) > (push (org-entry-get (point) "EXPORT_FILE_NAME") export-files))) > nil 'tree) > (message export-files))) ; errors, but lets me see the list of collected values > #+END_SRC > As you point out below, everything works as it should: outline-next-heading steps you through the headlines and eventually returns nil correctly. The problem is that org-entry-get does not just look forward: it looks *around* and finds the property when point is both at the beginning and at the end of the headline "Four", so you get "four" twice. But I'm not sure what the right way to deal with it is. Nick > And I call this function from a buffer that looks like: > > * Top > > ** One > :PROPERTIES: > :EXPORT_FILE_NAME: one > :END: > ** Two > :PROPERTIES: > :EXPORT_FILE_NAME: two > :END: > ** Three > :PROPERTIES: > :EXPORT_FILE_NAME: three > :END: > ** Four > :PROPERTIES: > :EXPORT_FILE_NAME: four > :END: > > Then the list that I get back (the value of export-files) looks like: > > ("four" "four" "three" "two" "one") > > Whereas I would like it to be just: > > ("four" "three" "two" "one") > > Can anyone see what I need to do to achieve that? [Apart from just using > (cdr export-files), I mean -- I'd like to know the /right/ way.] I'm > puzzled because outline-next-heading, if called interactively from the > last child, does indeed put point at the end of that child or at the > next (parent-level) heading, so it doesn't seem that the problem is that > it somehow loops back when there is no next child-level entry. > > Many thanks if you catch something I've missed! > > Best, > Richard > > [1] http://article.gmane.org/gmane.emacs.orgmode/37244/ >