emacs-orgmode
[Top][All Lists]
Advanced

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

Possible bug in `org-subtree--get-subtree-options`?


From: Kaushal Modi
Subject: Possible bug in `org-subtree--get-subtree-options`?
Date: Mon, 14 Mar 2022 13:42:27 -0400

Hello Nicolas,

Today I was debugging something where a subtree export wasn't recognizing the EXPORT_OPTIONS property set in that subtree.

MWE:

=====
* Top level
** Allow broken links, but mark them
:PROPERTIES:
:EXPORT_FILE_NAME: allow-broken-links-but-mark-them
:EXPORT_OPTIONS: broken-links:mark
:END:
=====

1. Move cursor to BOL of "** Allow broken links, but mark them" line.
2. M-: (org-export--get-subtree-options)

Output:

(:title (#("Top level" 0 9 (:parent #1))))

Issue: Point is already on a heading, but it is jumping to the parent heading and returning that heading's properties.

Debugging through how the export options got parsed in subtree exports, I reached the `org-export--get-subtree-options' function and this line in there:

;; https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/lisp/ox.el#n1425
(if (org-at-heading-p) (org-up-heading-safe) (org-back-to-heading t))

It looks like the if condition actions are swapped here.

Should it be:

(if (org-at-heading-p) (org-back-to-heading t) (org-up-heading-safe))
;; If point is in a heading, just go to the BOLĀ  (org-back-to-heading t)
;; Otherwise, jump up to a parent-heading if available.

If I evaluate that function after updating that if condition as above and redo the steps I mentioned above, the output is now what I expect:

(:with-broken-links mark :title (#("Allow broken links, but mark them" 0 33 (:parent #1))))

I am only surprised that this line has been there at least since 2015.

Thanks!

--
Kaushal Modi

reply via email to

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