branch: externals/auctex commit 46f2f2215d9b626f09700697a4231d9e1a805ad6 Author: Ikumi Keita <ik...@ikumi.que.jp> Commit: Ikumi Keita <ik...@ikumi.que.jp>
Inherit abbrevs saved in table with former mode name * tex.el (TeX-abbrev-mode-setup): Add argument for additional parent abbrev table for compatibility. * latex.el (LaTeX-mode): Add `latex-mode-abbrev-table' as parent of `LaTeX-mode-abbrev-table'. (docTeX-mode): Add `doctex-mode-abbrev-table' as parent of `docTeX-mode-abbrev-table'. * plain-tex.el (plain-TeX-mode): Add `plain-tex-mode-abbrev-table' as parent of `plain-TeX-mode-abbrev-table'. * context.el (ConTeXt-mode): Add `context-mode-abbrev-table' as parent of `ConTeXt-mode-abbrev-table'. --- context.el | 2 +- latex.el | 4 ++-- plain-tex.el | 2 +- tex.el | 15 ++++++++++++--- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/context.el b/context.el index a3716237df..a7c2b8391a 100644 --- a/context.el +++ b/context.el @@ -1819,7 +1819,7 @@ that is, you do _not_ have to cater for this yourself by adding \\\\\\=' or $." :type '(repeat regexp) :group 'TeX-command) -(TeX-abbrev-mode-setup ConTeXt-mode) +(TeX-abbrev-mode-setup ConTeXt-mode context-mode-abbrev-table) (defun ConTeXt-mode-common-initialization () "Initialization code that is common for all ConTeXt interfaces." diff --git a/latex.el b/latex.el index a19564f1b1..8da3a61cd2 100644 --- a/latex.el +++ b/latex.el @@ -7858,7 +7858,7 @@ This happens when \\left is inserted." :type 'hook :group 'LaTeX) -(TeX-abbrev-mode-setup LaTeX-mode) +(TeX-abbrev-mode-setup LaTeX-mode latex-mode-abbrev-table) ;;;###autoload (add-to-list 'auto-mode-alist '("\\.drv\\'" . LaTeX-mode) t) ;; append to the end of `auto-mode-alist' to give higher priority to Guix/Nix's derivation modes @@ -7933,7 +7933,7 @@ of `LaTeX-mode-hook'." ;;;###autoload (defalias 'LaTeX-mode #'TeX-LaTeX-mode) -(TeX-abbrev-mode-setup docTeX-mode) +(TeX-abbrev-mode-setup docTeX-mode doctex-mode-abbrev-table) ;;;###autoload (define-derived-mode docTeX-mode LaTeX-mode "docTeX" diff --git a/plain-tex.el b/plain-tex.el index 63366d9b62..2397f71bf8 100644 --- a/plain-tex.el +++ b/plain-tex.el @@ -113,7 +113,7 @@ plain-TeX file, or any mode derived thereof. See variable :type 'hook :group 'TeX-misc) -(TeX-abbrev-mode-setup plain-TeX-mode) +(TeX-abbrev-mode-setup plain-TeX-mode plain-tex-mode-abbrev-table) ;; We want to use `plain-TeX-mode' as the function name. However, it is ;; overwritten when tex-mode.el, prior to Emacs 29, is loaded afterwards diff --git a/tex.el b/tex.el index db8b998119..52c61f6ee5 100644 --- a/tex.el +++ b/tex.el @@ -6704,15 +6704,24 @@ error." ;;; Abbrev mode -(defmacro TeX-abbrev-mode-setup (mode) - "Set up the abbrev table and variable for MODE." +(defmacro TeX-abbrev-mode-setup (mode usertable) + "Set up the abbrev table and variable for MODE. +The table inherits from USERTABLE if it is a valid abbrev table." (let ((symbol (intern (concat (symbol-name mode) "-abbrev-table"))) (name (TeX-mode-prefix mode))) `(progn (defvar ,symbol nil ,(format "Abbrev table for %s mode." name)) (define-abbrev-table ',symbol nil) - (abbrev-table-put ,symbol :parents (list text-mode-abbrev-table))))) + (let ((parents (list text-mode-abbrev-table))) + ;; Users may already have user abbrevs in tables based on the + ;; former mode names such as `latex-mode-abbrev-table', + ;; stored in .emacs.d/abbrev_defs. In that case, add them as + ;; parent abbrev tables. + (if (and (boundp ',usertable) + (abbrev-table-p ,usertable)) + (push ,usertable parents)) + (abbrev-table-put ,symbol :parents parents))))) ;;; Special provisions for other modes and libraries