emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: daisysky@tuta.io
Cc: Emacs Orgmode <emacs-orgmode@gnu.org>
Subject: Re: [BUG] `org-format-outline-path` returns inproper `org-level-N` face for a heading if its level is not consequent from its parent heading.
Date: Fri, 18 Oct 2024 17:33:06 +0000	[thread overview]
Message-ID: <87ed4dxqnh.fsf@localhost> (raw)
In-Reply-To: <O9TyqcQ--B-9@tuta.io>

daisysky--- via "General discussions about Org-mode."
<emacs-orgmode@gnu.org> writes:

> For example, in an org-mode buffer
> ```
> * Heading level 1
> *** Heading level 3 ; where the point is at
>
> ```
>
> Run `(org-format-outline-path (org-get-outline-path t nil))` in
> `eval-expression`.
>
> The output is `#("Heading level 1/Heading level 3" 0 15 (face org-level-1)
> 16 31 (face org-level-2))`.
>
> Which doesn't work as expected, it should add face of `org-level-3` instead of
> `org-level-2`.

I can see why it is unexpected, but it is not a bug.
You are calling `org-format-outline-path' on the output of
`org-get-outline-path'. And `org-get-outline-path', does not actually
return the real headline depth. What is does return is

    ... a list of ancestors for current headline, as a list of strings

In other words, if some ancestors skip certain outline levels, this fact
is not recorded by `org-get-outline-path'.

If you want to apply correct faces according the actual headline depth,
you will need to use a different function, similar to
`org-get-outline-path', that will put "" in place of "missing" outline
levels. You will also need to filter out //.  Or you may implement a
custom version of `org-format-outline-path' as well.

TL;DR: Org mode APIs do not provide what you are trying to achieve.

Not a bug.
Canceled.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


  reply	other threads:[~2024-10-18 17:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-18  9:35 [BUG] `org-format-outline-path` returns inproper `org-level-N` face for a heading if its level is not consequent from its parent heading daisysky--- via General discussions about Org-mode.
2024-10-18 17:33 ` Ihor Radchenko [this message]
2024-10-18 17:42   ` Ihor Radchenko
     [not found]     ` <O9Xr56X--B-9@tuta.io>
2024-10-19  7:33       ` 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=87ed4dxqnh.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=daisysky@tuta.io \
    --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).