From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#19324: 25.0.50; add-function and nil Date: Thu, 11 Dec 2014 14:11:25 -0500 Message-ID: References: <87vbllxw05.fsf@gmail.com> <87bnnbt342.fsf@gmail.com> <877fxyu9h1.fsf@gmail.com> <87egs6uljg.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1418329832 26010 80.91.229.3 (11 Dec 2014 20:30:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 11 Dec 2014 20:30:32 +0000 (UTC) Cc: 19324@debbugs.gnu.org To: Leo Liu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Dec 11 21:30:25 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XzANU-0004yb-Se for geb-bug-gnu-emacs@m.gmane.org; Thu, 11 Dec 2014 21:30:25 +0100 Original-Received: from localhost ([::1]:54252 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XzANU-00062n-Cx for geb-bug-gnu-emacs@m.gmane.org; Thu, 11 Dec 2014 15:30:24 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44466) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XzANJ-00062P-BJ for bug-gnu-emacs@gnu.org; Thu, 11 Dec 2014 15:30:20 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XzANA-0005rR-1P for bug-gnu-emacs@gnu.org; Thu, 11 Dec 2014 15:30:13 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:33850) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XzAN9-0005qq-V0 for bug-gnu-emacs@gnu.org; Thu, 11 Dec 2014 15:30:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XzAN9-0005ni-27 for bug-gnu-emacs@gnu.org; Thu, 11 Dec 2014 15:30:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 11 Dec 2014 20:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19324 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 19324-submit@debbugs.gnu.org id=B19324.141832974822201 (code B ref 19324); Thu, 11 Dec 2014 20:30:02 +0000 Original-Received: (at 19324) by debbugs.gnu.org; 11 Dec 2014 20:29:08 +0000 Original-Received: from localhost ([127.0.0.1]:43216 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XzAMF-0005m1-HI for submit@debbugs.gnu.org; Thu, 11 Dec 2014 15:29:07 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:22137) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XzAMC-0005lH-Fy for 19324@debbugs.gnu.org; Thu, 11 Dec 2014 15:29:05 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Aj8PAOwQflTO+ILA/2dsb2JhbABbgweDYIVawjuCYgQCAoEkFwEBAQEBAXyEAwEBAwFWIwULCw4mEhQYDSSISgnWWQEBAQcBAQEBHpA8MweESAWLAaQugXiEGSGCdwEBAQ X-IPAS-Result: Aj8PAOwQflTO+ILA/2dsb2JhbABbgweDYIVawjuCYgQCAoEkFwEBAQEBAXyEAwEBAwFWIwULCw4mEhQYDSSISgnWWQEBAQcBAQEBHpA8MweESAWLAaQugXiEGSGCdwEBAQ X-IronPort-AV: E=Sophos;i="5.07,502,1413259200"; d="scan'208";a="100224224" Original-Received: from 206-248-130-192.dsl.teksavvy.com (HELO pastel.home) ([206.248.130.192]) by ironport2-out.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 11 Dec 2014 15:28:58 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 72F32262D; Thu, 11 Dec 2014 14:11:25 -0500 (EST) In-Reply-To: <87egs6uljg.fsf@gmail.com> (Leo Liu's message of "Fri, 12 Dec 2014 01:46:27 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:97229 Archived-At: > 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=B9. 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 t= hose 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 h= ooks. - (lambda (&rest args) (apply (default-value var) args))))) + (lambda (&rest args) (apply (or (default-value var) #'ignore) ar= gs))))) =20 (eval-and-compile (defun advice--normalize-place (place)