all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Leo Liu <sdl.web@gmail.com>
Cc: 19324@debbugs.gnu.org
Subject: bug#19324: 25.0.50; add-function and nil
Date: Thu, 11 Dec 2014 14:11:25 -0500	[thread overview]
Message-ID: <jwvoarac8t6.fsf-monnier+emacsbugs@gnu.org> (raw)
In-Reply-To: <87egs6uljg.fsf@gmail.com> (Leo Liu's message of "Fri, 12 Dec 2014 01:46:27 +0800")

> 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.


        Stefan


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 differences.")
   (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) args)))))
 
 (eval-and-compile
   (defun advice--normalize-place (place)





  reply	other threads:[~2014-12-11 19:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-09  4:55 bug#19324: 25.0.50; add-function and nil Leo Liu
2014-12-10 19:54 ` Stefan Monnier
2014-12-11  0:57   ` Leo Liu
2014-12-11  2:48     ` Stefan Monnier
2014-12-11  3:54       ` Leo Liu
2014-12-11 17:01         ` Stefan Monnier
2014-12-11 17:46           ` Leo Liu
2014-12-11 19:11             ` Stefan Monnier [this message]
2014-12-12  0:44               ` Leo Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvoarac8t6.fsf-monnier+emacsbugs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=19324@debbugs.gnu.org \
    --cc=sdl.web@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.