emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: coroa@online.de (Jonas Hörsch)
To: emacs-orgmode@gnu.org
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	[thread overview]
Message-ID: <87k3sk3ggz.fsf_-_@online.de> (raw)
In-Reply-To: 87sj792gr9.fsf@online.de

[-- Attachment #1: Type: text/plain, Size: 300 bytes --]

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?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: test.org --]
[-- Type: text/x-org, Size: 619 bytes --]

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


[-- Attachment #3: Type: text/plain, Size: 32 bytes --]


thanks for any comments,
jonas

  reply	other threads:[~2012-12-14 13:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-10 15:53 org-sync doesn't work with recent org-element.el Jonas Hörsch
2012-12-12 14:42 ` Bastien
2012-12-13  1:06   ` Aurélien Aptel
2012-12-13 10:03     ` Bastien
2012-12-14  8:13     ` Jonas Hörsch
2012-12-14 13:34       ` Jonas Hörsch [this message]
2012-12-16 12:45       ` Jonas Hörsch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k3sk3ggz.fsf_-_@online.de \
    --to=coroa@online.de \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).