Skip to content

Instantly share code, notes, and snippets.

@kdmsnr
Forked from kenoss/my-tex-imenu.el
Last active November 9, 2022 06:56
Show Gist options
  • Save kdmsnr/3dabe645134e93ffa79ebd14157016f9 to your computer and use it in GitHub Desktop.
Save kdmsnr/3dabe645134e93ffa79ebd14157016f9 to your computer and use it in GitHub Desktop.
TeXで階層imenu(適当)
(defun latex-create-imenu-index ()
(let ((index '())
(pattern (rx "\\" (group (or "part" "chapter" "section" "subsection" "paragraph" "subparagraph"))
"{" (group (* (not (any "}")))) "}"))
(pairs '(
(part . 0)
(chapter . 0)
(section . 2)
(subsection . 4)
(paragraph . 6)
(subparagraph . 8)
))
)
(goto-char (point-max))
(while (re-search-backward pattern (point-min) t)
(push (cons (concat (make-string (alist-get (intern (match-string-no-properties 1)) pairs) ? )
(match-string-no-properties 2))
(match-beginning 0))
index))
index))
(add-hook 'yatex-mode-hook
'(lambda ()
(setq imenu-create-index-function 'latex-create-imenu-index)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment