From mboxrd@z Thu Jan 1 00:00:00 1970 From: coroa@online.de (Jonas =?utf-8?Q?H=C3=B6rsch?=) Subject: retrieve value of a property from a property-drawer (was: org-sync doesn't work with recent org-element.el) Date: Fri, 14 Dec 2012 14:34:20 +0100 Message-ID: <87k3sk3ggz.fsf_-_@online.de> References: <874njtc39x.fsf@online.de> <876247nxgo.fsf@bzg.ath.cx> <87sj792gr9.fsf@online.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:45567) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjVPY-0005PK-Em for emacs-orgmode@gnu.org; Fri, 14 Dec 2012 08:34:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TjVPX-0005UD-4t for emacs-orgmode@gnu.org; Fri, 14 Dec 2012 08:34:44 -0500 Received: from plane.gmane.org ([80.91.229.3]:53395) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjVPW-0005U7-Tv for emacs-orgmode@gnu.org; Fri, 14 Dec 2012 08:34:43 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1TjVPg-0001SP-20 for emacs-orgmode@gnu.org; Fri, 14 Dec 2012 14:34:52 +0100 Received: from e178199007.adsl.alicedsl.de ([85.178.199.7]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 14 Dec 2012 14:34:52 +0100 Received: from coroa by e178199007.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 14 Dec 2012 14:34:52 +0100 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 --=-=-= Content-Type: text/plain Hej, org-element-wizards, i found that the following use of org-element-map retrieves reliably the value of a key from a property drawer. is such a use, especially the temporary overriding of the headline's type to org-data, to be considered allowed usage or rather a hack and thus to be avoided? --=-=-= Content-Type: text/x-org Content-Disposition: inline; filename=test.org * First headline :PROPERTIES: :url: http://orgmode.org/ :END: #+begin_src emacs-lisp (defun retrieve-property-value (headlineitem key) (org-element-map (cons 'org-data (cdr headlineitem)) 'node-property (lambda (x) (and (string= (org-element-property :key x) key) (org-element-property :value x))) nil t 'headline)) (let* ((doc (org-element-parse-buffer)) (firstheadline (org-element-map doc 'headline 'identity nil t))) (retrieve-property-value firstheadline "url")) #+end_src #+RESULTS: : http://orgmode.org/ --=-=-= Content-Type: text/plain thanks for any comments, jonas --=-=-=--