I currently begin to write a org-mode backend for a custom file format, so I can export from org-file to that format.
Therefore I need to apply properties (or attributes) to headings. My prolbem is now, how I could solve this.
I currently have the following headline function:
(defun org-mine-headline (headline contents info)
(let ((full-text
(substring-no-properties
(org-export-data (org-element-property :title headline) info)))
(p (org-element-property nil headline))
(a (org-export-read-attribute :attr_mine headline)))
(format "%s: [%s] %s" full-text p contents)))
Which gives me with the following org file:
* H1
#+PROPERTY: findme a
foo
the following output:
H1: [nil] foo
But I would like it to become something like that:
H1: [(:findme "a")] foo
I also tried attributes with no success:
* H1
#+ATTR_MINE: :findme a
foo
(let* ((first-keyword (car (org-element-map headline 'keyword #'identity))) (key (org-element-property :key first-keyword)) (value (org-element-property :value first-keyword))) (list key value))
. Depends on the parse depth ofheadline
whether this works or not.key
should be"PROPERTY"
andvalue
should be"findme a"
.org-element-map
gives you the list and you can replace#'identity
with the mapping from key to value. So you get the list of values.(let* ((keywords (org-element-map headline 'keyword #'identity)) (values (mapcar (lambda (keyword) (org-element-property :value keyword)) keywords))) values)
. Not yet well formed but I think I can work it out. Thanks again for the neat trick withorg-element-map
. One question, may I need thosePROPERTY
keys?#'identity
is replaced by the map from the keys to the values. That has the advantage of a selective listing. In our example onlyPROPERTY
keys are listed.