lang/latex: refactor & fix hooks

This commit is contained in:
Henrik Lissner 2020-05-08 06:28:35 -04:00
parent ab0d37776b
commit 3528fe0ca9
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -82,7 +82,6 @@ If no viewers are found, `latex-preview-pane' is used.")
:when (featurep! +fold) :when (featurep! +fold)
:hook (TeX-mode . TeX-fold-buffer) :hook (TeX-mode . TeX-fold-buffer)
:hook (TeX-mode . TeX-fold-mode) :hook (TeX-mode . TeX-fold-mode)
:config :config
;; Fold after all auctex macro insertions ;; Fold after all auctex macro insertions
(advice-add #'TeX-insert-macro :after #'+latex-fold-last-macro-a) (advice-add #'TeX-insert-macro :after #'+latex-fold-last-macro-a)
@ -91,17 +90,16 @@ If no viewers are found, `latex-preview-pane' is used.")
(advice-add #'cdlatex-math-modify :after #'+latex-fold-last-macro-a) (advice-add #'cdlatex-math-modify :after #'+latex-fold-last-macro-a)
;; Fold after snippets ;; Fold after snippets
(when (featurep! :editor snippets) (when (featurep! :editor snippets)
(add-hook 'TeX-fold-mode-hook (add-hook! 'TeX-fold-mode-hook
(defun +latex-fold-set-yas-hook-h () (defun +latex-fold-snippet-contents-h ()
"Set a local after-snippet-hook to fold the snippet contents."
(add-hook! 'yas-after-exit-snippet-hook :local (add-hook! 'yas-after-exit-snippet-hook :local
(TeX-fold-region yas-snippet-beg yas-snippet-end))))) (TeX-fold-region yas-snippet-beg yas-snippet-end)))))
(add-hook 'mixed-pitch-mode-hook (add-hook! 'mixed-pitch-mode-hook
(defun +latex-fold-set-variable-pitch-h () (defun +latex-fold-set-variable-pitch-h ()
"Fix folded things invariably getting fixed pitch when using mixed-pitch. "Fix folded things invariably getting fixed pitch when using mixed-pitch.
Math faces should stay fixed by the mixed-pitch blacklist, this Math faces should stay fixed by the mixed-pitch blacklist, this is mostly for
is mostly for \\section etc." \\section etc."
(when mixed-pitch-mode (when mixed-pitch-mode
;; Adding to this list makes mixed-pitch clean the face remaps after us ;; Adding to this list makes mixed-pitch clean the face remaps after us
(add-to-list 'mixed-pitch-fixed-cookie (add-to-list 'mixed-pitch-fixed-cookie