Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toc-org-enable to add TOC headline if missing #26

Closed
VladimirAlexiev opened this issue Jul 1, 2016 · 8 comments
Closed

toc-org-enable to add TOC headline if missing #26

VladimirAlexiev opened this issue Jul 1, 2016 · 8 comments

Comments

@VladimirAlexiev
Copy link

Something for toc-org-enable:

    (setq  ; toc-org puts TOC in the org file, so these conflict
       org-export-with-section-numbers nil
       org-export-with-toc nil)
    ;; add TOC headline if missing
    (unless (org-find-exact-headline-in-buffer "Table of Contents")
      (org-first-headline-recenter)
      (beginning-of-line)
      (insert "* Table of Contents                                 :TOC_5:\n\n"))

Why :TOC_5: not :TOC_2: ? See #27

@snosov1
Copy link
Owner

snosov1 commented Jul 1, 2016

Not sure I understand the problem.

@csantosb
Copy link

csantosb commented Jul 1, 2016

I think the idea is to auto insert a TOC in none exists.

Personally, I would prefer you let the user customize this package behavior, for
example with

(advice-add 'toc-org-insert-toc :before #'toc-org-advice)

You define your own toc-org-advice, as the one above

@snosov1
Copy link
Owner

snosov1 commented Jul 1, 2016

I think the idea is to auto insert a TOC in none exists.

You mean right after opening the file? Or what? I still don't fully understand =)

@csantosb
Copy link

csantosb commented Jul 1, 2016

Well, when toc-org-insert-toc acts, that's to say, when before-save-hook is called. No need to modify the package to achieve this, in my opinion.

@snosov1
Copy link
Owner

snosov1 commented Jul 1, 2016

Yeah, if you want to generate the TOC right after you open the file, you can use find-file-hook. Not sure it's a good idea, though. Some time ago, this was a default behavior of the mode, but I eliminated that.

@csantosb
Copy link

csantosb commented Jul 1, 2016

Up to the user to decide ... ! I am using this setup, which fits me.

@VladimirAlexiev
Copy link
Author

If this mode depends on a :TOC: heading, I think it should ensure (or at least have an option to do it).
But I'm also happy to close this. @csantosb thanks, your code is better, esp :noexport: so I can use the "native" toc:t for html export

@snosov1
Copy link
Owner

snosov1 commented Jul 1, 2016

Ok, let's close it. Thx!

@snosov1 snosov1 closed this as completed Jul 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants