emacs-diffs
[Top][All Lists]
Advanced

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

master b27e2bbb347: Use OClosure to drop `advice--buffer-local-function-


From: Stefan Monnier
Subject: master b27e2bbb347: Use OClosure to drop `advice--buffer-local-function-sample` hack
Date: Sun, 29 Oct 2023 14:13:12 -0400 (EDT)

branch: master
commit b27e2bbb347c981ad12e05161d2bee195d110dd4
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    Use OClosure to drop `advice--buffer-local-function-sample` hack
    
    * lisp/emacs-lisp/nadvice.el (advice--forward): New OClosure, to
    replace `advice--buffer-local-function-sample`.
    (advice--set-buffer-local, advice--buffer-local): Adjust accordingly.
---
 lisp/emacs-lisp/nadvice.el | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/lisp/emacs-lisp/nadvice.el b/lisp/emacs-lisp/nadvice.el
index cd80df2c41d..ce5467f3c5c 100644
--- a/lisp/emacs-lisp/nadvice.el
+++ b/lisp/emacs-lisp/nadvice.el
@@ -292,14 +292,13 @@ HOW is a symbol to select an entry in 
`advice--how-alist'."
                               (equal function (cdr (assq 'name props))))
                           (list (advice--remove-function rest function)))))))
 
-(defvar advice--buffer-local-function-sample nil
-  "Keeps an example of the special \"run the default value\" functions.
-These functions play the same role as t in buffer-local hooks, and to recognize
-them, we keep a sample here against which to compare.  Each instance is
-different, but `function-equal' will hopefully ignore those differences.")
+(oclosure-define (advice--forward
+                  (:predicate advice--forward-p))
+  "Redirect to the global value of a var.
+These functions act like the t special value in buffer-local hooks.")
 
 (defun advice--set-buffer-local (var val)
-  (if (function-equal val advice--buffer-local-function-sample)
+  (if (advice--forward-p val)
       (kill-local-variable var)
     (set (make-local-variable var) val)))
 
@@ -308,11 +307,10 @@ different, but `function-equal' will hopefully ignore 
those differences.")
   "Buffer-local value of VAR, presumed to contain a function."
   (declare (gv-setter advice--set-buffer-local))
   (if (local-variable-p var) (symbol-value var)
-    (setq advice--buffer-local-function-sample
-          ;; This function acts like the t special value in buffer-local hooks.
-          ;; FIXME: Provide an `advice-bottom' function that's like
-          ;; `advice-cd*r' but also follows through this proxy.
-          (lambda (&rest args) (apply (default-value var) args)))))
+    ;; FIXME: Provide an `advice-bottom' function that's like
+    ;; `advice--cd*r' but also follows through this proxy.
+    (oclosure-lambda (advice--forward) (&rest args)
+      (apply (default-value var) args))))
 
 (eval-and-compile
   (defun advice--normalize-place (place)



reply via email to

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