emacs-orgmode
[Top][All Lists]
Advanced

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

[Q] How to get all the properties of the current subtree?


From: Rodrigo Morales
Subject: [Q] How to get all the properties of the current subtree?
Date: Sun, 15 Aug 2021 22:46:15 -0500

* Epilogue

Consider the following Org Mode file

#+CAPTION: The main.org file
#+BEGIN_SRC org
,* The first heading
:PROPERTIES:
:FOO: foo-value
:END:

,** The first subheading
:PROPERTIES:
:BAR: bar-value
:END:
#+END_SRC

I know that I can use the function =org-entry-properties= to get some
properties of the current subtree. Apparently, =org-entry-properties=
is only able to get the direct properties (i.e. it doesn't consider
the inherited properties)

#+BEGIN_SRC elisp
(with-current-buffer "main.org"
  (end-of-buffer)
  (pp-to-string (org-entry-properties)))
#+END_SRC

#+RESULTS:
#+begin_example
(("CATEGORY" . "main")
 ("BAR" . "bar-value")
 ("BLOCKED" . "")
 ("FILE" . "/home/beep1560/e/main.org")
 ("PRIORITY" . "B")
 ("ITEM" . "The first subheading"))
#+end_example

Note that even though =foo= is an inherited property of "The first
subheading", it is not obtained by =org-entry-properties=. Because
=foo= is an inherited property of "The first subheading", it can be
obtained by =org-entry-get= (see below).

#+BEGIN_SRC elisp
(with-current-buffer "main.org"
  (end-of-buffer)
  (org-entry-get nil "FOO" t))
#+END_SRC

#+RESULTS:
#+begin_example
foo-value
#+end_example

* The question

My question is: How to get all the properties (inherited properties
included) of the current subtree? In the example shown below, I would
expect the following result

#+BEGIN_EXAMPLE
(("CATEGORY" . "main")
 ("FOO" . "foo-value")
 ("BAR" . "bar-value")
 ("BLOCKED" . "")
 ("FILE" . "/home/beep1560/e/main.org")
 ("PRIORITY" . "B")
 ("ITEM" . "The first subheading"))
#+END_EXAMPLE

As I explained above, the function =org-entry-properties= doesn't
accomplish this.

reply via email to

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