emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Possible bug in `org-subtree--get-subtree-options`?
@ 2022-03-14 17:42 Kaushal Modi
  2022-10-18  4:12 ` Ihor Radchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Kaushal Modi @ 2022-03-14 17:42 UTC (permalink / raw)
  To: emacs-org list, Nicolas Goaziou

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

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

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

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

end of thread, other threads:[~2022-11-27  8:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-14 17:42 Possible bug in `org-subtree--get-subtree-options`? Kaushal Modi
2022-10-18  4:12 ` Ihor Radchenko
2022-11-27  8:51   ` Ihor Radchenko

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