[Top][All Lists]

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

bug#19324: 25.0.50; add-function and nil

From: Stefan Monnier
Subject: bug#19324: 25.0.50; add-function and nil
Date: Thu, 11 Dec 2014 14:11:25 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

> But :around are still broken.  It promises to pass on ORIG but instead
> passes a proxy.  So the advice has no (public) way to tell missing
> function.  Do you have a fix for this?

No I don't have a fix for this.
`add-function' is designed to work on places that only hold functions,
so any other value (such as nil) will create problems.

IOW a variable that can hold "either nil or a function" is not something
that add-function supports.

I guess we could treat nil as an alias for `ignore' in the "proxy
function", which would fix this particular issue.  See patch below.
But I don't intend to handle all the cases in which a "nil function" can
show up.  Many/most uses of `foo-function' actually give a special
meaning to nil which is different from `ignore'.
So I'm not sure we should cater to this particular case.

> Otherwise we have to check and set a dummy value to be safe, for
> example┬╣.

That looks like a good workaround.


diff --git a/lisp/emacs-lisp/nadvice.el b/lisp/emacs-lisp/nadvice.el
index a81d3e4..7e1c236 100644
--- a/lisp/emacs-lisp/nadvice.el
+++ b/lisp/emacs-lisp/nadvice.el
@@ -234,7 +234,7 @@ different, but `function-equal' will hopefully ignore those 
   (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.
-          (lambda (&rest args) (apply (default-value var) args)))))
+          (lambda (&rest args) (apply (or (default-value var) #'ignore) 
   (defun advice--normalize-place (place)

reply via email to

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