From 8b88b04c1b87cfc957b7d016f735d7f8a7fb90cd Mon Sep 17 00:00:00 2001 From: Zelong Kuang Date: Sun, 14 Dec 2025 19:27:57 +1100 Subject: [PATCH] ``` 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 ``` --- init.el | 1 + lisp/init-completion.el | 3 ++- lisp/init-edit.el | 1 + lisp/init-org.el | 14 ------------- lisp/init-snippet.el | 10 --------- lisp/init-tex.el | 45 +++++++++-------------------------------- recentf | 8 ++++++-- 7 files changed, 19 insertions(+), 63 deletions(-) delete mode 100644 lisp/init-snippet.el diff --git a/init.el b/init.el index 99659dc..e951be2 100644 --- a/init.el +++ b/init.el @@ -88,3 +88,4 @@ (require 'init-coding) (require 'init-org) +(require 'init-tex) diff --git a/lisp/init-completion.el b/lisp/init-completion.el index 63aada4..fddbc4f 100644 --- a/lisp/init-completion.el +++ b/lisp/init-completion.el @@ -60,7 +60,8 @@ ;; Enrich existing commands with completion annotations (use-package marginalia - :hook (after-init . marginalia-mode)) + :init + (marginalia-mode)) ;; Consulting completing-read (use-package consult diff --git a/lisp/init-edit.el b/lisp/init-edit.el index 91f2d5d..d937ffb 100644 --- a/lisp/init-edit.el +++ b/lisp/init-edit.el @@ -18,6 +18,7 @@ :hook ((LaTeX-mode . yas-minor-mode) (post-self-insert . my/yas-try-expanding-auto-snippets)) :config + (yas-global-mode) (use-package warnings :config (cl-pushnew '(yasnippet backquote-change) diff --git a/lisp/init-org.el b/lisp/init-org.el index 8dd3922..30cd0a5 100644 --- a/lisp/init-org.el +++ b/lisp/init-org.el @@ -68,28 +68,14 @@ ;; Increase preview width (plist-put org-latex-preview-appearance-options :page-width 0.8) - - ;; ;; Use dvisvgm to generate previews - ;; ;; You don't need this, it's the default: - ;; (setq org-latex-preview-process-default 'dvisvgm) - ;; Turn on `org-latex-preview-mode', it's built into Org and much faster/more - ;; featured than org-fragtog. (Remember to turn off/uninstall org-fragtog.) - ;; ;; Block C-n, C-p etc from opening up previews when using `org-latex-preview-mode' ;; (setq org-latex-preview-mode-ignored-commands ;; '(next-line previous-line mwheel-scroll ;; scroll-up-command scroll-down-command)) - ;; ;; Enable consistent equation numbering (setq org-latex-preview-numbered t) - - ;; Bonus: Turn on live previews. This shows you a live preview of a LaTeX - ;; fragment and updates the preview in real-time as you edit it. - ;; To preview only environments, set it to '(block edit-special) instead (setq org-latex-preview-mode-display-live t) - - ;; More immediate live-previews -- the default delay is 1 second (setq org-latex-preview-mode-update-delay 0.25)) (use-package org-roam diff --git a/lisp/init-snippet.el b/lisp/init-snippet.el deleted file mode 100644 index 4cd6c8c..0000000 --- a/lisp/init-snippet.el +++ /dev/null @@ -1,10 +0,0 @@ -(use-package! yasnippet - :config - (defun my-yas-try-expanding-auto-snippets () - (when yas-minor-mode - (let ((yas-buffer-local-condition ''(require-snippet-condition . auto))) - (yas-expand)))) - (add-hook 'post-command-hook #'my-yas-try-expanding-auto-snippets) - ) - -(provide 'init-snippet) diff --git a/lisp/init-tex.el b/lisp/init-tex.el index 5fdfc84..8328bda 100644 --- a/lisp/init-tex.el +++ b/lisp/init-tex.el @@ -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 ("" . cdlatex-tab))) -(use-package cdlatex - :hook ((cdlatex-tab . yas-expand) - (cdlatex-tab . cdlatex-in-yas-field)) - :config - (use-package yasnippet - :bind (:map yas-keymap - ("" . 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) diff --git a/recentf b/recentf index 80c195f..2ab9b90 100644 --- a/recentf +++ b/recentf @@ -1,10 +1,14 @@ -;;; Automatically generated by ‘recentf’ on Sun Dec 14 11:04:21 2025. +;;; Automatically generated by ‘recentf’ on Sun Dec 14 19:26:39 2025 -*- mode: emacs-lisp; lexical-binding: t -*- (setq recentf-list '( - "~/.emacs.d/lisp/init-org.el" "~/.emacs.d/init.el" + "~/.emacs.d/lisp/init-snippet.el" + "~/.emacs.d/lisp/init-org.el" + "~/.emacs.d/lisp/init-tex.el" "~/org/roam/20251212003211-presentation_of_group.org" + "~/build-emacs-for-macos/builds/Emacs.app/Contents/Resources/lisp/loaddefs.el.gz" + "~/.emacs.d/lisp/init-completion.el" "~/.emacs.d/lisp/init-edit.el" "~/.emacs.d/early-init.el" "~/org/roam/20251117171745-emacs.org"