auctex-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Cosmetic patch for AUCTeX


From: Stefan Monnier
Subject: Cosmetic patch for AUCTeX
Date: Wed, 29 Dec 2021 00:21:21 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

The patch below removes the fallback code for when `nadvice` is not
available, replacing it with a dependency on `nadvice-0.3` (which could
be replaced by a dependency on Emacs-24.4).


        Stefan


diff --git a/auctex.el b/auctex.el
index da5e667ba4..72d262dc33 100644
--- a/auctex.el
+++ b/auctex.el
@@ -6,7 +6,7 @@
 ;; URL: https://www.gnu.org/software/auctex/
 ;; Maintainer: auctex-devel@gnu.org
 ;; Notifications-To: auctex-diffs@gnu.org
-;; Package-Requires: ((emacs "24.3"))
+;; Package-Requires: ((emacs "24.3") (nadvice "0.3"))
 ;; Keywords: TeX LaTeX Texinfo ConTeXt docTeX preview-latex
 
 ;; This file is part of GNU Emacs.
diff --git a/context.el b/context.el
index 139663599e..6914bacb31 100644
--- a/context.el
+++ b/context.el
@@ -640,10 +640,7 @@ for a label to be inserted after the sectioning command."
 
 (TeX-auto-add-type "environment" "ConTeXt")
 
-(if (fboundp 'advice-add)               ;Emacs≥24.4 (or ELPA package nadvice)
-    (advice-add 'ConTeXt-add-environments :after #'ConTeXt--invalidate-menu)
-  (defadvice ConTeXt-add-environments (after ConTeXt-invalidate-menu (&rest 
environments) activate)
-    (ConTeXt--invalidate-menu)))
+(advice-add 'ConTeXt-add-environments :after #'ConTeXt--invalidate-menu)
 (defun ConTeXt--invalidate-menu (&rest _)
   "Mark the menu as being in need of a refresh."
   (setq ConTeXt-menu-changed t))
diff --git a/latex.el b/latex.el
index e1f217f9ca..9d05fc7d7b 100644
--- a/latex.el
+++ b/latex.el
@@ -1985,11 +1985,7 @@ The value is actually the tail of the list of options 
given to PACKAGE."
 
 (add-hook 'TeX-auto-cleanup-hook #'LaTeX-auto-cleanup)
 
-(if (fboundp 'advice-add)               ;Emacs≥24.4 (or ELPA package nadvice)
-    (advice-add 'LaTeX-add-bibliographies :after #'TeX-run-style-hooks)
-  (defadvice LaTeX-add-bibliographies (after run-bib-style-hooks (&rest 
bibliographies) activate)
-    "Add BIBLIOGRAPHIES to the list of known bibliographies and style files."
-    (apply #'TeX-run-style-hooks bibliographies)))
+(advice-add 'LaTeX-add-bibliographies :after #'TeX-run-style-hooks)
 
 ;;; Biber support
 
@@ -6074,10 +6070,7 @@ corresponds to the variables 
`LaTeX-environment-menu-name' and
                (mapcar #'LaTeX-environment-modify-menu-entry
                        (LaTeX-environment-list))))))))
 
-(if (fboundp 'advice-add)               ;Emacs≥24.4 (or ELPA package nadvice)
-    (advice-add 'LaTeX-add-environments :after #'LaTeX--invalidate-menus)
-  (defadvice LaTeX-add-environments (after LaTeX-invalidate-environment-menu 
(&rest environments) activate)
-    (LaTeX--invalidate-menus)))
+(advice-add 'LaTeX-add-environments :after #'LaTeX--invalidate-menus)
 (defun LaTeX--invalidate-menus (&rest _)
   "Mark the environment menus as being in need of a refresh."
   (setq LaTeX-environment-menu nil)
diff --git a/preview.el b/preview.el
index 0d5ec377ea..bea2adf905 100644
--- a/preview.el
+++ b/preview.el
@@ -2070,11 +2070,6 @@ overlays not in the active window."
       (preview-toggle ovr)
       (push ovr preview-temporary-opened))))
 
-(if (fboundp 'advice-add)               ;Emacs≥24.4 (or ELPA package nadvice)
-    nil ; See the defcustom below.
-  (defadvice replace-highlight (before preview)
-    (preview--open-for-replace (ad-get-arg 0) (ad-get-arg 1))))
-
 (defun preview--open-for-replace (beg end &rest _)
   "Make `query-replace' open preview text about to be replaced."
   (preview-open-overlays (overlays-in beg end)))
@@ -2086,16 +2081,11 @@ overlays not in the active window."
   :require 'preview
   :set (lambda (symbol value)
          (set-default symbol value)
-         (if (fboundp 'advice-add) ; COMPATIBILITY for Emacs<24.4
-             (if value
-                 (advice-add 'replace-highlight :before
-                             #'preview--open-for-replace)
-               (advice-remove 'replace-highlight
-                              #'preview--open-for-replace))
-           (if value
-               (ad-enable-advice 'replace-highlight 'before 'preview)
-             (ad-disable-advice 'replace-highlight 'before 'preview))
-           (ad-activate 'replace-highlight)))
+         (if value
+             (advice-add 'replace-highlight :before
+                         #'preview--open-for-replace)
+           (advice-remove 'replace-highlight
+                          #'preview--open-for-replace)))
   :initialize #'custom-initialize-reset)
 
 (defun preview-relaxed-string= (&rest args)
diff --git a/tex-site.el b/tex-site.el
index b19a39ee89..4da3076cb1 100644
--- a/tex-site.el
+++ b/tex-site.el
@@ -95,49 +95,22 @@ shared by all users of a site."
 
 (add-hook 'tex-site-unload-hook
           (lambda ()
-            (if (fboundp 'advice-add)
-                (TeX-modes-set 'TeX-modes nil)
-              (let ((list after-load-alist))
-                (while list
-                  ;; Adapted copy of the definition of `assq-delete-all'
-                  ;; from Emacs 21 as substitute for
-                  ;; `(assq-delete-all'TeX-modes-set (car list))' which
-                  ;; fails on non-list elements in Emacs 21.
-                  (let* ((alist (car list))
-                         (tail alist)
-                         (key #'TeX-modes-set))
-                    (while tail
-                      (if (and (consp (car tail))
-                               (eq (car (car tail)) key))
-                          (setq alist (delq (car tail) alist)))
-                      (setq tail (cdr tail))))
-                  (setq list (cdr list)))))
+            (TeX-modes-set 'TeX-modes nil)
             (setq load-path (delq TeX-lisp-directory load-path))))
 
-(defun TeX-modes-set (var value &optional update)
+(defun TeX-modes-set (var value &optional _ignored)
   "Set VAR (which should be `TeX-modes') to VALUE.
 
 This places either the standard or the AUCTeX versions of
-functions into the respective function cell of the mode.
-If UPDATE is set, a previously saved value for
-the non-AUCTeX function gets overwritten with the current
-definition."
+functions into the respective function cell of the mode."
   (custom-set-default var value)
   (let ((list TeX-mode-alist) elt)
     (while list
       (setq elt (car (pop list)))
       (let ((dst (intern (concat "TeX-" (symbol-name elt)))))
-        (if (fboundp 'advice-add)
-            (if (memq elt value)
-                (advice-add elt :override dst)
-              (advice-remove elt dst))
-          (when (or update (null (get elt 'tex-saved)))
-            (when (fboundp elt)
-              (put elt 'tex-saved (symbol-function elt))))
-          (defalias elt
-            (if (memq elt value)
-                dst
-              (get elt 'tex-saved))))))))
+        (if (memq elt value)
+            (advice-add elt :override dst)
+          (advice-remove elt dst))))))
 
 (defcustom TeX-modes
   (mapcar #'car TeX-mode-alist)
@@ -148,14 +121,7 @@ set it with `TeX-modes-set'."
   :type (cons 'set
               (mapcar (lambda(x) (list 'const (car x))) TeX-mode-alist))
   :set #'TeX-modes-set
-  :initialize(lambda (var value)
-               (custom-initialize-reset var value)
-               (unless (fboundp 'advice-add)
-                 (let ((list TeX-mode-alist))
-                   (while list
-                     (eval-after-load (cdar list)
-                       `(TeX-modes-set ',var ,var t))
-                     (setq list (cdr list)))))) )
+  :initialize #'custom-initialize-reset)
 
 (defconst AUCTeX-version "13.0.15"
     "AUCTeX version.
diff --git a/tex.el b/tex.el
index 3cf8f65ec2..351bfd6239 100644
--- a/tex.el
+++ b/tex.el
@@ -770,11 +770,7 @@ emacs 24.1 and is then later run by emacs 24.5."
                           (add-to-list 'Info-file-list-for-emacs
                                        (cons elt "AUCTeX"))))
 
-(if (fboundp 'advice-add)               ;Emacs≥24.4 (or ELPA package nadvice)
-    (advice-add 'hack-one-local-variable :after #'TeX--call-minor-mode)
-  (defadvice hack-one-local-variable (after TeX-hack-one-local-variable-after
-                                          activate)
-    (TeX--call-minor-mode (ad-get-arg 0) (ad-get-arg 1))))
+(advice-add 'hack-one-local-variable :after #'TeX--call-minor-mode)
 (defun TeX--call-minor-mode (var val &rest _)
   "Call minor mode function if minor mode variable is found."
     ;; Instead of checking for each mode explicitely `minor-mode-list'




reply via email to

[Prev in Thread] Current Thread [Next in Thread]