all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [Q] How to get all the properties of the current subtree?
@ 2021-08-16  3:46 Rodrigo Morales
  2022-04-28 14:48 ` Ihor Radchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Rodrigo Morales @ 2021-08-16  3:46 UTC (permalink / raw)
  To: org-mode-email

[-- Attachment #1: Type: text/plain, Size: 1666 bytes --]

* 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.

[-- Attachment #2: Type: text/html, Size: 2388 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Q] How to get all the properties of the current subtree?
  2021-08-16  3:46 [Q] How to get all the properties of the current subtree? Rodrigo Morales
@ 2022-04-28 14:48 ` Ihor Radchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Ihor Radchenko @ 2022-04-28 14:48 UTC (permalink / raw)
  To: Rodrigo Morales; +Cc: org-mode-email

Rodrigo Morales <moralesrodrigo1100@gmail.com> writes:

> 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

You would need to collect property names by running org-entry-properties
on current heading, it's parent, and so on. You can get parent headings
as (org-element-property :parent (org-element-at-point)) in newer Org or
using org-up-heading-safe.

Then, you can run org-entry-get on the acquired list of property names.

Best,
Ihor




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-28 15:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-16  3:46 [Q] How to get all the properties of the current subtree? Rodrigo Morales
2022-04-28 14:48 ` Ihor Radchenko

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.