``` refactor(tex,completion,edit): Reorganize LaTeX configuration

and cleanup

- Require init-tex module in main init.el Change marginalia
- initialization from hook to immediate mode activation Enable
- yasnippet globally in init-edit Remove unused init-snippet.el
- module Simplify init-tex.el by removing redundant
- cdlatex-yasnippet integration Add lexical binding and proper
- package demand configuration for AuCTeX Clean up commented code in
- init-org.el ```
This commit is contained in:
Zelong Kuang
2025-12-14 19:27:57 +11:00
parent 9e7872b4aa
commit 8b88b04c1b
7 changed files with 19 additions and 63 deletions

View File

@@ -1,7 +1,13 @@
;; -*- lexical-binding: t; -*-
(use-package latex
:ensure auctex
:demand t
:ensure (auctex :pre-build (("./autogen.sh")
("./configure" "--without-texmf-dir" "--with-lispdir=.")
("make")))
:mode (("\\.tex\\'" . LaTeX-mode))
:hook ((LaTeX-mode . prettify-symbols-mode))
:bind (:map LaTeX-mode-map
("C-S-e" . latex-math-from-calc))
@@ -29,39 +35,6 @@
:hook (LaTeX-mode . turn-on-cdlatex)
:bind (:map cdlatex-mode-map
("<tab>" . cdlatex-tab)))
(use-package cdlatex
:hook ((cdlatex-tab . yas-expand)
(cdlatex-tab . cdlatex-in-yas-field))
:config
(use-package yasnippet
:bind (:map yas-keymap
("<tab>" . yas-next-field-or-cdlatex)
("TAB" . yas-next-field-or-cdlatex))
:config
(defun cdlatex-in-yas-field ()
;; Check if we're at the end of the Yas field
(when-let* ((_ (overlayp yas--active-field-overlay))
(end (overlay-end yas--active-field-overlay)))
(if (>= (point) end)
;; Call yas-next-field if cdlatex can't expand here
(let ((s (thing-at-point 'sexp)))
(unless (and s (assoc (substring-no-properties s)
cdlatex-command-alist-comb))
(yas-next-field-or-maybe-expand)
t))
;; otherwise expand and jump to the correct location
(let (cdlatex-tab-hook minp)
(setq minp
(min (save-excursion (cdlatex-tab)
(point))
(overlay-end yas--active-field-overlay)))
(goto-char minp) t))))
(defun yas-next-field-or-cdlatex nil
(interactive)
"Jump to the next Yas field correctly with cdlatex active."
(if
(or (bound-and-true-p cdlatex-mode)
(bound-and-true-p org-cdlatex-mode))
(cdlatex-tab)
(yas-next-field-or-maybe-expand)))))
(provide 'init-tex)