Open TheAifam5 opened 2 years ago
To make a nested TOC, the buffer-local imenu-create-index-function
has to be set to markdown-imenu-create-nested-index
instead of markdown-imenu-create-flat-index
.
Did this chance with a new recent Emacs version?
Did this chance with a new recent Emacs version?
It did; maybe a default value was changed? Although this would be a change in markdown-mode rather than Emacs itself right?
I tried setting it like this: (custom-set-variables '(imenu-create-index-function markdown-imenu-create-nested-index)
but it didn't work. any advice here?
I tried setting it like this:
(custom-set-variables '(imenu-create-index-function markdown-imenu-create-nested-index)
but it didn't work. any advice here?
It took a while digging around and this seems related to native compilation as far as I can tell. I have a workaround in my config here: https://codeberg.org/sochotnicky/dotfiles/src/branch/main/dot_doom.d/config.org#headline-64
Basically - disable native compilation for markdown-mode & add a hook to enable nested TOC generation. Might help you as well?
Good idea, but didn't work unfortunately. This is a bummer, as this is a super useful feature for me.
I tried setting it like this:
(custom-set-variables '(imenu-create-index-function markdown-imenu-create-nested-index)
but it didn't work. any advice here?
To be clear - you need to delete any already natively-compiled markdown-mode files or that first part won't be effective. Just make sure you do that...
I had to restart my emacs, but it worked! Nice callout @sochotnicky
Hi, replace this funtion will fix it.
(defun markdown-toc--compute-toc-structure (imenu-index)
"Given a IMENU-INDEX, compute the TOC structure."
(--mapcat (markdown-toc--compute-toc-structure-from-level
(if (eq markdown-toc-user-toc-structure-manipulation-fn 'cdr)
-1
0)
it)
imenu-index))
bug
Generated TOC does not respect heading levels and every TOC entry is on the same level.
Emacs Doom: master Emacs Version: 28.1 with native-compilation
Config
With and without it, the issue still occurs.
Expected behavior
Actual behavior
Steps to reproduce the behavior