From mboxrd@z Thu Jan 1 00:00:00 1970 From: Richard Lawrence Subject: org-map-entries and org-map-continue-from Date: Mon, 28 Feb 2011 10:40:24 -0800 Message-ID: <87oc5watpj.fsf@berkeley.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from [140.186.70.92] (port=50758 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pu7ww-0002lH-7P for emacs-orgmode@gnu.org; Mon, 28 Feb 2011 13:36:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pu7wv-0000kt-0a for emacs-orgmode@gnu.org; Mon, 28 Feb 2011 13:36:02 -0500 Received: from lo.gmane.org ([80.91.229.12]:36695) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pu7wu-0000kj-Kv for emacs-orgmode@gnu.org; Mon, 28 Feb 2011 13:36:00 -0500 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1Pu7wt-0002hP-6Z for emacs-orgmode@gnu.org; Mon, 28 Feb 2011 19:35:59 +0100 Received: from c-67-164-33-170.hsd1.ca.comcast.net ([67.164.33.170]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 28 Feb 2011 19:35:59 +0100 Received: from richard.lawrence by c-67-164-33-170.hsd1.ca.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 28 Feb 2011 19:35:59 +0100 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: emacs-orgmode@gnu.org Hi all, Bastien had advised me [1] to use (setq org-map-continue-from (outline-next-heading)) in a function called by org-map-entries in order to map that function across just the /children/ of the current entry (i.e., to exclude the current `parent' entry itself). This works great, but I have now found that it has a weird side-effect: it calls the function twice on the last child. 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 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/