emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Kaushal Modi <kaushal.modi@gmail.com>
To: emacs-org list <emacs-orgmode@gnu.org>,
	Nicolas Goaziou <mail@nicolasgoaziou.fr>
Subject: Possible bug in `org-subtree--get-subtree-options`?
Date: Mon, 14 Mar 2022 13:42:27 -0400	[thread overview]
Message-ID: <CAFyQvY3mxi4DRTS+W-AX7bFELVujqH4DODEYPy3hyGRRuMEPSw@mail.gmail.com> (raw)

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

             reply	other threads:[~2022-03-14 18:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-14 17:42 Kaushal Modi [this message]
2022-10-18  4:12 ` Possible bug in `org-subtree--get-subtree-options`? Ihor Radchenko
2022-11-27  8:51   ` 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=CAFyQvY3mxi4DRTS+W-AX7bFELVujqH4DODEYPy3hyGRRuMEPSw@mail.gmail.com \
    --to=kaushal.modi@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    /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).