emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Rodrigo Morales <moralesrodrigo1100@gmail.com>
To: org-mode-email <emacs-orgmode@gnu.org>
Subject: [Q] How to get all the properties of the current subtree?
Date: Sun, 15 Aug 2021 22:46:15 -0500	[thread overview]
Message-ID: <CAGxMbPbOe+nZgpqNekn1gpA0ys1Op3xLOB0Td=Mer96L1UJ_4A@mail.gmail.com> (raw)

[-- 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 --]

             reply	other threads:[~2021-08-16  3:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-16  3:46 Rodrigo Morales [this message]
2022-04-28 14:48 ` [Q] How to get all the properties of the current subtree? Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAGxMbPbOe+nZgpqNekn1gpA0ys1Op3xLOB0Td=Mer96L1UJ_4A@mail.gmail.com' \
    --to=moralesrodrigo1100@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).