alphapapa / org-make-toc

Automatic tables of contents for Org-mode files
GNU General Public License v3.0
108 stars 18 forks source link

Is there a way to have TOC only n levels deep? #9

Closed mankoff closed 5 years ago

mankoff commented 5 years ago

If I just want a top-level TOC that is only 1 or 2 levels deep, I don't see how to get that from the docs or example. If I leave out :TOC: this, nothing is generated. If I have that with a :TOC: 2, it still generates all (deep) sub-headings.

alphapapa commented 5 years ago

Did you look at the example file?

mankoff commented 5 years ago

Yes I did read it and tried by trial-and-error. The only way I see to exclude something is with explicit keywords: :TOC: ignore. I have an Org file with 195 headings (23 top level, 41 2nd level, 41 3nd, 67 4th), so I was hoping for a feature that did not require me to touch them.

alphapapa commented 5 years ago

As the documentation and examples explain, to limit the depth of a heading's TOC entries, use :TOC: n on a heading. So if you want all of your top-level headings to appear in the TOC with subheadings up to a depth of 2, you could use a keyboard macro to quickly apply :TOC: 2 properties to the top-level headings.

There is not currently a global TOC depth limit. That would be a nice feature to have if the code is ever rewritten, which it probably ought to be someday.

mankoff commented 5 years ago

Thank you for the clarificiation. I have a work-around that doesn't involve touching the file outside of the TOC section. I'm not using toc-org. That package has slightly different behavior (skipping noexport tags and COMMENT states), but can generate similar TOC to this package with the following config:

(use-package toc-org
  :after org
  :hook (org-mode . toc-org-enable)
  :config (setq-default toc-org-noexport-regexp "noexport_nomatch"
            toc-org-comment-regexp "comment_nomatch"))

And can make TOCs to any depth with tags :TOC_n:.

alphapapa commented 5 years ago

That's a little ironic, since I made this package because the author of toc-org didn't want to implement the features this package has. :)

mankoff commented 5 years ago

¯_(ツ)_/¯