[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Export of property key:value
From: |
Edward DeMeulle |
Subject: |
Re: [O] Export of property key:value |
Date: |
Mon, 29 Jul 2013 20:11:39 -0700 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) |
Nicolas Goaziou <address@hidden> writes:
> You can use a hook (e.g., `org-export-before-processing-hook) to insert
> "amount : {{{property(amount)}}}" (or with `org-entry-get', you don't
> need the macro in that case) after each property drawer with an amount
> property.
(apologies if this is a double-post, the first didn't seem to have been sent)
Thanks for the info. I took it up as a challenge to finally learn a
little elisp. This is what I have so far, which appears to work as long
as I expand the entire subtree to be exported. I'd appreciate any
criticism since I really don't know if I'm handling things the best
possible way.
(defun ewd/export-properties (backend)
"Export all properties whose names listed in EXPORT_PROPERTIES in the format:
- <name>: <value> after each heading of specified level
NOTE: 1st value in EXPORT_PROPERTIES is heading level"
(if (org-entry-get (point) "EXPORT_PROPERTIES")
(let* (
(export_properties (split-string
(org-entry-get (point) "EXPORT_PROPERTIES") "
"))
(export-level (string-to-number (car export_properties)))
(export-list (cdr export_properties))
)
(org-map-entries
(lambda ()
(next-line)
(open-line 1)
(dolist (prop export-list)
(if (= export-level (car (org-heading-components)))
(progn (insert "- " prop ": "
(if (org-entry-get (point) prop)
(org-entry-get (point) prop) "N/A"))
(newline)))))))))
(add-hook 'org-export-before-processing-hook 'ewd/export-properties)