emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] getting file properties


From: Nick Dokos
Subject: Re: [O] getting file properties
Date: Sun, 05 May 2013 00:36:04 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

address@hidden (J. David Boyd) writes:

> John Kitchin <address@hidden> writes:
>
>> Hi everyone,
>>
>> if I have an org-file with this in it:
>>
>> #+EMAIL: address@hidden
>>
>> is there an org lisp command to get the email address after I have
>> opened the file? I am looping through many files to generate a report,
>> and would like to do this in emacs-lisp. I had hoped org-entry-get
>> would do it, but it does not (it will retrieve it from #+PROPERTY:
>> EMAIL address@hidden).
>>
>> Is it possible to define other keywords similar to that? E.g.
>>
>> #+ANDREWID: jkitchin
>>
>> and then to be able to read them from a lisp command (without writing
>> the parsing code myself)? something like (org-entry-get-keyword
>> "ANDREWID"). 
>>
>> I could not find anything like this in the property API
>> (http://orgmode.org/manual/Using-the-property-API.html) which is where
>> i thought it would be.
>>
>> Thanks!
>>
>> John
>>
>> -----------------------------------
>> John Kitchin
>> Associate Professor
>> Doherty Hall A207F
>> Department of Chemical Engineering
>> Carnegie Mellon University
>> Pittsburgh, PA 15213
>> 412-268-7803
>> http://kitchingroup.cheme.cmu.edu
>
>
> I'm interested in an answer to this as well...
>
>
>

Here's one way:

--8<---------------cut here---------------start------------->8---
(defun jk-org-kwds ()
  (let* ((parse-tree (org-element-parse-buffer))
         (keys (org-element-map parse-tree 'keyword (function identity))))
    (mapcar (function  (lambda (x) (cons (org-element-property :key x)
                                         (org-element-property :value x)))) 
keys)))
--8<---------------cut here---------------end--------------->8---

This returns a list of (KEY. VALUE) pairs.

I'm sure there are other (better, cheaper) ways, but I'm going through
org-element.el, and having that hammer in hand, everything looks like
a nail to me :-)

-- 
Nick




reply via email to

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