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