From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Abrahamsen Subject: Re: accessing properties in org-element-parse-buffer tree Date: Sun, 31 Aug 2014 10:08:06 +0800 Message-ID: <87k35p5s3d.fsf@ericabrahamsen.net> References: <87ppfhzweg.fsf@ithaka.home> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55025) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XNuUs-0002eH-98 for emacs-orgmode@gnu.org; Sat, 30 Aug 2014 22:04:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XNuUm-0005Tc-1M for emacs-orgmode@gnu.org; Sat, 30 Aug 2014 22:04:02 -0400 Received: from plane.gmane.org ([80.91.229.3]:56630) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XNuUl-0005TY-Ql for emacs-orgmode@gnu.org; Sat, 30 Aug 2014 22:03:55 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XNuUh-0001Dg-6K for emacs-orgmode@gnu.org; Sun, 31 Aug 2014 04:03:51 +0200 Received: from 222.128.166.224 ([222.128.166.224]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 31 Aug 2014 04:03:51 +0200 Received: from eric by 222.128.166.224 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 31 Aug 2014 04:03:51 +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: emacs-orgmode@gnu.org Eike writes: > Hello list, > > I want to ask for help regarding elisp and org-elements. I like to > access the properties of all my headlines and I created the following > function (tree is the parsed tree) that collects them into an a-list: You could also take a look at org-collector, in contrib. It might give you some ideas, or even solve your problem directly. > #+begin_src emacs-lisp > (defun collect-props (tree) > (car (org-element-map tree 'headline > (lambda (hl) > (when (eq 2 (org-element-property :level hl)) ; want only level-2 properties > (org-element-map hl 'node-property > (lambda (np) > (cons (org-element-property :key np) > (org-element-property :value np))))))))) > #+end_src > > I'm not very confident about this, is this ok? Is there a better way? > For example, the first car looks strange, and I don't know how to get > rid of it. > > Thanks you very much in advance!!! > Kind regards > Eike > > -- > gpg: AD7AC35E > finger print: 137F BB0B 1639 D25F DC5D E59C B412 C5F5 AD7A C35E