Hi Arash, >>>>> Arash Esbati <ar...@gnu.org> writes: > Ikumi Keita <ik...@ikumi.que.jp> writes: >> OK, I'll do some tests and propose a change for the document.
> 🙏 How about the attached patch? (Maybe I should decouple the commit from bug#71363. When I first got started with this issue, it was a subsidiary topic of bug#71363.) Regards, Ikumi Keita #StandWithUkraine #StopWarInUkraine #Gaza #StopMassiveKilling #CeasefireNOW
>From 2db4d6091baac1b5c4a94eaeb8b96abeb35c6160 Mon Sep 17 00:00:00 2001 From: Ikumi Keita <ik...@ikumi.que.jp> Date: Tue, 12 Mar 2024 14:55:11 +0900 Subject: [PATCH] Keep compatibility with Org mode src editing (bug#71363) * tex-site.el.in (TeX-modes-set): Add entries for AUCTeX LaTeX mode to `org-src-lang-modes'. Use `major-mode-remap-defaults' for Emacs 30 and later, instead of `major-mode-remap-alist', in order to avoid altering user customize option. * doc/install.texi (Loading the package): Update the recommendation accordingly. Update the way to disable AUCTeX for ELPA site-wide installation as well. --- doc/install.texi | 38 +++++++++++++++++++++----------- tex-site.el.in | 56 +++++++++++++++++++++++++++++++++--------------- 2 files changed, 65 insertions(+), 29 deletions(-) diff --git a/doc/install.texi b/doc/install.texi index c2499e63..5a00f8c3 100644 --- a/doc/install.texi +++ b/doc/install.texi @@ -38,9 +38,6 @@ Once the installation is completed, you can skip the rest of this section and proceed to @ref{Quick Start}. @end ifclear -The remainder of this section is about installing @AUCTeX{} from a -release tarball or from a checkout of the @AUCTeX{} repository. - Installing @AUCTeX{} should be simple: merely @command{./configure}, @command{make}, and @code{make install} for a standard site-wide installation (most other installations can be done by specifying a @@ -371,21 +368,31 @@ list. Type to manipulate the contents of @code{TeX-modes}. @end defopt -Don't remove @code{tex-mode} from @code{TeX-modes} because it results in -inconsistent behavior. +Don't remove @code{tex-mode} from @code{TeX-modes} unless you set +@code{TeX-modes} empty to disable @AUCTeX{} completely, otherwise it +results in inconsistent behavior. -On Emacs 29 and later, you can alter @code{major-mode-remap-alist} instead -of @code{TeX-modes} as you like to arrange @AUCTeX{} redirections. In -fact, @code{TeX-modes} option does nothing other than setting up -@code{major-mode-remap-alist} according its value on those Emacsens. +On Emacs 29 and later, @AUCTeX{} uses either +@code{major-mode-remap-defaults} or @code{major-mode-remap-alist} for +redirection. But we recommend not to customize them directly because the +customization code for @code{TeX-modes} takes care of some other +compatibility issues. -If you want to remove a preinstalled @AUCTeX{} completely before any of -its modes have been used, +When there is a site-wide installation of @AUCTeX{} and you don't want to +use it, you can disable it by +@lisp +(push '(auctex nil) package-load-list) +@end lisp +@noindent +in your early init file (@pxref{Early Init File,,,emacs}) for +@acronym{ELPA} installation, or @lisp (unload-feature 'tex-site) @end lisp @noindent -in your init file should accomplish that. +in your (standard) init file for configure--make installation. (We +recommend those treatments over setting @code{TeX-modes} to @code{nil}, +because they don't leave unused autoloads persisted.) @node Advice for package providers @section Providing @AUCTeX{} as a package @@ -399,6 +406,7 @@ There are people that prefer the built-in Emacs modes for editing @TeX{} files, in particular plain @TeX{} users. There are various ways to tell @AUCTeX{} even after auto-activation that it should not get used, and they are described in +@c FIXME: It doesn't seem that these references discuss this topic. @ifset rawfile the @file{README} file. @end ifset @@ -410,6 +418,12 @@ So if you have users that don't want to use the preinstalled @AUCTeX{}, they can easily get rid of it. Activating @AUCTeX{} by default is therefore a good choice. +First of all, you can install @acronym{ELPA} @AUCTeX{} package under a +directory listed in @code{package-directory-list} to have site-wide +default. + +Next, we discuss configure--make installation. + If the installation procedure did not achieve this already by placing @file{auctex.el} and @file{preview-latex.el} into a possibly existing @file{site-start.d} directory, you can do this by placing diff --git a/tex-site.el.in b/tex-site.el.in index 911a2080..7dd16333 100644 --- a/tex-site.el.in +++ b/tex-site.el.in @@ -113,29 +113,51 @@ Arrange the redirection of the built-in TeX modes according to VALUE. - The built-in modes in VALUE are redirected to the corresponding AUCTeX major modes. - The built-in modes not in VALUE discard redirection, if any. -If `major-mode-remap-alist' is available, use it for redirection. -Otherwise, use advice facility." +If either `major-mode-remap-defaults' or `major-mode-remap-alist' is +available, use it for redirection in that order. Otherwise, use advice +facility." (custom-set-default var value) (let (elt dst) (dolist (entry TeX-mode-alist) (setq elt (car entry) dst (cdr entry)) (if (memq elt value) - (if (boundp 'major-mode-remap-alist) - (or (eq (cdr-safe (assq elt major-mode-remap-alist)) dst) - (push (cons elt dst) major-mode-remap-alist)) - ;; COMPATIBILITY for Emacs<29 - (advice-add elt :override dst - ;; COMPATIBILITY for Emacs 28.[12] - ;; Give it higher precedence than the :around - ;; advice given to `tex-mode' in tex-mode.el. - ;; <URL:https://lists.gnu.org/r/auctex-devel/2022-09/msg00050.html> - '((depth . -10)))) - (if (boundp 'major-mode-remap-alist) - (setq major-mode-remap-alist - (delete entry major-mode-remap-alist)) - ;; COMPATIBILITY for Emacs<29 - (advice-remove elt dst)))))) + (progn + (cond ((boundp 'major-mode-remap-defaults) + ;; For Emacs 30 and later + (add-to-list 'major-mode-remap-defaults (cons elt dst))) + ((boundp 'major-mode-remap-alist) + ;; COMPATIBILITY for Emacs 29 + (add-to-list 'major-mode-remap-alist (cons elt dst))) + (t + ;; COMPATIBILITY for Emacs<29 + (advice-add elt :override dst + ;; COMPATIBILITY for Emacs 28 + ;; Give it higher precedence than the :around + ;; advice given to `tex-mode' in tex-mode.el. + ;; <URL:https://lists.gnu.org/r/auctex-devel/2022-09/msg00050.html> + '((depth . -10))))) + ;; Keep compatibility. (bug#71363) + (if (eq elt 'latex-mode) + (with-eval-after-load 'org-src + (defvar org-src-lang-modes) ; Silence byte compiler. + ;; Check the actual presence in the entry in case that + ;; the user once choosed AUCTeX LaTeX mode and + ;; abandoned it afterwards in the same emacs session. + (when (memq 'latex-mode TeX-modes) + (push '("latex" . LaTeX) org-src-lang-modes) + (push '("beamer" . LaTeX) org-src-lang-modes))))) + (cond ((boundp 'major-mode-remap-defaults) + ;; For Emacs 30 and later + (setq major-mode-remap-defaults + (delete entry major-mode-remap-defaults))) + ((boundp 'major-mode-remap-alist) + ;; COMPATIBILITY for Emacs 29 + (setq major-mode-remap-alist + (delete entry major-mode-remap-alist))) + (t + ;; COMPATIBILITY for Emacs<29 + (advice-remove elt dst))))))) (defcustom TeX-modes (mapcar #'car TeX-mode-alist) -- 2.44.0