[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] scratch/auctex-lexbind d7bdc79 10/13: Expose the body of advice t
From: |
Stefan Monnier |
Subject: |
[elpa] scratch/auctex-lexbind d7bdc79 10/13: Expose the body of advice to the compiler |
Date: |
Tue, 23 Mar 2021 13:56:57 -0400 (EDT) |
branch: scratch/auctex-lexbind
commit d7bdc79cafa1bca2a0da5caa9aa7911393175366
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
Expose the body of advice to the compiler
While at it, use `advice-add` when available.
We can drop `defadvice` completely when we bump the required version
to Emacs-24.4, or if/when we add `nadvice` as a required package.
* context.el (ConTeXt--invalidate-menu): New function.
(ConTeXt-add-environments): Advise with it.
* latex.el (LaTeX-add-bibliographies): Advise with `TeX-run-style-hooks`.
(LaTeX--invalidate-menus): New function.
(LaTeX-add-environments): Advise with it.
* preview.el.in (preview--open-for-replace): New function.
(replace-highlight): Advise with it.
* tex.el (tex--call-minor-mode): New function.
(hack-one-local-variable): Advise with it.
---
context.el | 8 ++++++--
latex.el | 18 +++++++++++-------
preview.el.in | 10 +++++++---
tex.el | 10 ++++++----
4 files changed, 30 insertions(+), 16 deletions(-)
diff --git a/context.el b/context.el
index 4def467..e3a32aa 100644
--- a/context.el
+++ b/context.el
@@ -636,8 +636,12 @@ inserted after the sectioning command."
(TeX-auto-add-type "environment" "ConTeXt")
-(defadvice ConTeXt-add-environments (after ConTeXt-invalidate-menu (&rest
environments) activate)
- "Add ENVIRONMENTS to the list of known environments."
+(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)))
+(defun ConTeXt--invalidate-menu (&rest _)
+ "Mark the menu as being in need of a refresh."
(setq ConTeXt-menu-changed t))
;; (defvar ConTeXt-environment-list ()
diff --git a/latex.el b/latex.el
index 3265615..9e22628 100644
--- a/latex.el
+++ b/latex.el
@@ -1967,9 +1967,11 @@ The value is actually the tail of the list of options
given to PACKAGE."
(add-hook 'TeX-auto-cleanup-hook #'LaTeX-auto-cleanup)
-(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))
+(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)))
;;; Biber support
@@ -5761,10 +5763,12 @@ corresponds to the variables
`LaTeX-environment-menu-name' and
(mapcar #'LaTeX-environment-modify-menu-entry
(LaTeX-environment-list))))))))
-(defadvice LaTeX-add-environments (after LaTeX-invalidate-environment-menu
(&rest environments) activate)
- "Add ENVIRONMENTS to the list of known environments.
-Additionally invalidate the environment submenus to let them be
-regenerated by the respective menu filter."
+(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)))
+(defun LaTeX--invalidate-menus (&rest _)
+ "Mark the environment menus as being in need of a refresh."
(setq LaTeX-environment-menu nil)
(setq LaTeX-environment-modify-menu nil))
diff --git a/preview.el.in b/preview.el.in
index a15629b..2789a0e 100644
--- a/preview.el.in
+++ b/preview.el.in
@@ -2060,10 +2060,14 @@ overlays not in the active window."
(preview-toggle ovr)
(push ovr preview-temporary-opened))))
-(defadvice replace-highlight (before preview)
+(if (fboundp 'advice-add) ;Emacs≥24.4 (or ELPA package nadvice)
+ (advice-add 'replace-highlight :before #'preview--open-for-replace)
+ (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 (ad-get-arg 0) (ad-get-arg 1))))
+ (preview-open-overlays (overlays-in beg end)))
(defcustom preview-query-replace-reveal t
"Make `query-replace' autoreveal previews."
diff --git a/tex.el b/tex.el
index a295a21..b6d1530 100644
--- a/tex.el
+++ b/tex.el
@@ -752,17 +752,19 @@ emacs 24.1 and is then later run by emacs 24.5."
(add-to-list 'Info-file-list-for-emacs
(cons elt "AUCTeX"))))
-(defadvice hack-one-local-variable (after TeX-hack-one-local-variable-after
+(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))))
+(defun tex--call-minor-mode (var val &rest _)
"Call minor mode function if minor mode variable is found."
- (let ((var (ad-get-arg 0))
- (val (ad-get-arg 1)))
;; Instead of checking for each mode explicitely `minor-mode-list'
;; could be used. But this may make the byte compiler pop up.
(when (memq var '(TeX-PDF-mode
TeX-source-correlate-mode TeX-interactive-mode
TeX-fold-mode LaTeX-math-mode))
- (if (symbol-value val) (funcall var 1) (funcall var 0)))))
+ (funcall var (if (symbol-value val) 1 0))))
(defvar TeX-overlay-priority-step 16
"Numerical difference of priorities between nested overlays.
- [elpa] branch scratch/auctex-lexbind created (now 7606a49), Stefan Monnier, 2021/03/23
- [elpa] scratch/auctex-lexbind c037cac 02/13: Prepare for enabling lexical binding in preview.el.in, Stefan Monnier, 2021/03/23
- [elpa] scratch/auctex-lexbind 7ccff10 01/13: ; * latex.el (LaTeX-fill-region-as-paragraph): Fix typo., Stefan Monnier, 2021/03/23
- [elpa] scratch/auctex-lexbind 7c2f403 03/13: * font-latex.el (font-latex-make-built-in-keywords): Reorder defs, Stefan Monnier, 2021/03/23
- [elpa] scratch/auctex-lexbind 1d188f5 05/13: Use #' rather than ' to quote functions, Stefan Monnier, 2021/03/23
- [elpa] scratch/auctex-lexbind e6910bb 07/13: Don't quote `lambda`, Stefan Monnier, 2021/03/23
- [elpa] scratch/auctex-lexbind d7bdc79 10/13: Expose the body of advice to the compiler,
Stefan Monnier <=
- [elpa] scratch/auctex-lexbind 00ef597 09/13: Miscellaneous minor changes, Stefan Monnier, 2021/03/23
- [elpa] scratch/auctex-lexbind 7606a49 13/13: Use UTF-8 for all ELisp files, Stefan Monnier, 2021/03/23
- [elpa] scratch/auctex-lexbind 6ca7910 12/13: Prefer lexical closures over hand-built lambda forms, Stefan Monnier, 2021/03/23
- [elpa] scratch/auctex-lexbind 2852adf 11/13: Activate lexical-binding everywhere, Stefan Monnier, 2021/03/23
- [elpa] scratch/auctex-lexbind 7d89628 04/13: * font-latex.el (font-latex-make-built-in-keywords): Make it a macro, Stefan Monnier, 2021/03/23
- [elpa] scratch/auctex-lexbind 8de4670 06/13: Remove some redundant `:group` arguments, Stefan Monnier, 2021/03/23
- [elpa] scratch/auctex-lexbind 7a68408 08/13: Remove some XEmacs and old-Emacs code, Stefan Monnier, 2021/03/23