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 via email to