emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] retrieve value of a property from a property-drawer (was: org-sync d


From: Jonas Hörsch
Subject: [O] 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
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

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?

* 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/

thanks for any comments,
jonas

reply via email to

[Prev in Thread] Current Thread [Next in Thread]