You could use a slight modification of the answer to another question.
After trying the full stuff in some org-file you can put https://emacs.stackexchange.com/questions/21459/programmatically-read-and-set-buffer-wide-org-mode-property
into your init file and just use org-global-props
in your org-file.
#+TITLE: Awesome File
#+AUTHOR: My Name
#+XYZ: xyz
/content/
#+BEGIN_SRC emacs-lisp
;; Definition of `org-global-props' that could go into your init file:
(defun org-global-props (&optional property buffer)
"Get the plists of global org properties of current buffer."
(unless property (setq property "PROPERTY"))
(with-current-buffer (or buffer (current-buffer))
(org-element-map (org-element-parse-buffer) 'keyword (lambda (el) (when (string-match property (org-element-property :key el)) el)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Stuff for your org-file:
(mapcar (lambda (prop)
(list (org-element-property :key prop)
(org-element-property :value prop)))
(org-global-props "\\(AUTHOR\\|TITLE\\|XYZ\\)"))
#+END_SRC
#+RESULTS:
| TITLE | Awesome File |
| AUTHOR | My Name |
| XYZ | xyz |
In order to get value of first property with key
you can use following function.
(defun org-global-prop-value (key)
"Get global org property KEY of current buffer."
(org-element-property :value (car (org-global-props key))))
For example, (org-global-prop-value "author")
returns My Name
. Keep in mind, that key
respects case sensitivity rules for search.
(org-element-property :value (car (org-global-props "AUTHOR")))
is fine enough. Thanks again. – d12frosted Apr 19 '16 at 11:08