org-make-toc icon indicating copy to clipboard operation
org-make-toc copied to clipboard

:include siblings may sometimes include descendants also?

Open akirak opened this issue 3 years ago • 4 comments

Hello, I have run the latest version of org-make-toc on the README of my project, and there is something wrong with the output.

Both "Guide" and "Design goal" should reside at the same level as "Features", but they are demoted. The output in plain text is as follows:

:CONTENTS:
- [[#features][Features]]
    - [[#when-to-and-when-not-to-use-elinter][When to and when not to use elinter]]
  - [[#guide-how-to-configure-your-emacs-lisp-project][Guide: How to configure your Emacs Lisp project]]
  - [[#design-goal][Design goal]]
:END:

I produced the TOC with my new GitHub Action which runs org-make-toc on CI. It basically runs this script in batch mode with the file given as an argument, so it has no custom Org options set.

Can this be a bug with org-make-toc.el?

akirak avatar Oct 15 '21 06:10 akirak

Hi Akira,

Does the bug only happen on the GitHub Action CI?

alphapapa avatar Oct 15 '21 23:10 alphapapa

Does the bug only happen on the GitHub Action CI?

No, the bug reproduces on interactive sessions as well, with my extensively customized config. org-make-toc seems to produce exactly the same output between the two environments.

Interestingly, it seems to produce a correct output when I demote the TOC context to the second level. You can get a correct result from the following input:

* New heading
** The TOC context
:PROPERTIES:
:TOC:      :include siblings :depth 2 :ignore this
:END:

:CONTENTS:
:END:

*** Features
*** Guide
*** Design goal

while not from the following one:

* The TOC context
:PROPERTIES:
:TOC:      :include siblings :depth 2 :ignore this
:END:

:CONTENTS:
:END:

** Features
** Guide
** Design goal

akirak avatar Oct 16 '21 04:10 akirak

I'm sorry, but the culpit was :include siblings, which should have been :include descendants. I don't remember why I got it wrong, but correctly specifying the property has fixed the issue:

:PROPERTIES:
:TOC:      :include descendants :depth 2
:END:

It seems that the descendants are included in the TOC in a wrong way if :include siblings is specified in the property. I don't think this is a common case, but it may be another bug.

akirak avatar Oct 16 '21 08:10 akirak

Thanks.

alphapapa avatar Oct 16 '21 12:10 alphapapa