* bug#20718: 25.0.50; find-function fails on advised subrs (again)
@ 2015-06-02 12:49 Michael Heerdegen
2015-06-04 0:09 ` Dmitry Gutov
0 siblings, 1 reply; 4+ messages in thread
From: Michael Heerdegen @ 2015-06-02 12:49 UTC (permalink / raw
To: 20718
Hello,
just as a random example:
(advice-add 'handle-switch-frame :after #'prin1)
and M-x find-function 'handle-switch-frame RET
==> find-function-search-for-symbol: Don't know where
`handle-switch-frame' is defined
Works without advicing. I included the word "again" in the subject
because this had been fixed once in #789 in 2008.
It doesn't work because `find-function-library' performs the subrp test
just on the symbol function of the given function name, which is the
advice, not the original subr.
Thanks,
Michael.
In GNU Emacs 25.0.50.4 (x86_64-unknown-linux-gnu, GTK+ Version 3.14.5)
of 2015-05-30 on drachen
Windowing system distributor `The X.Org Foundation', version 11.0.11701000
System Description: Debian GNU/Linux testing (stretch)
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#20718: 25.0.50; find-function fails on advised subrs (again)
2015-06-02 12:49 bug#20718: 25.0.50; find-function fails on advised subrs (again) Michael Heerdegen
@ 2015-06-04 0:09 ` Dmitry Gutov
2015-06-04 15:55 ` Stefan Monnier
0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Gutov @ 2015-06-04 0:09 UTC (permalink / raw
To: michael_heerdegen, 20718
On 06/02/2015 03:49 PM, Michael Heerdegen wrote:
> It doesn't work because `find-function-library' performs the subrp test
> just on the symbol function of the given function name, which is the
> advice, not the original subr.
At a glance, the problem is in find-function-advised-original: it only
supports the old-style advice, and returns nil for 'handle-switch-frame
augmented with advice-add.
Something like the patch below should fix it, but then the function
returns a #<subr> object, instead of function symbol, and several
callers seem to depend on the return value being the latter (because
they want to call symbol-function on it).
diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el
index 7ea13d4..75fdfc7 100644
--- a/lisp/emacs-lisp/find-func.el
+++ b/lisp/emacs-lisp/find-func.el
@@ -192,9 +192,9 @@ defined in C.")
"Return the original function symbol of an advised function FUNC.
If FUNC is not the symbol of an advised function, just returns FUNC."
(or (and (symbolp func)
- (featurep 'advice)
- (let ((ofunc (cdr (assq 'origname (ad-get-advice-info func)))))
- (and (fboundp ofunc) ofunc)))
+ (featurep 'nadvice)
+ (let ((ofunc (advice--symbol-function func)))
+ (and (advice--p ofunc) (advice--cd*r ofunc))))
func))
(defun find-function-C-source (fun-or-var file type)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#20718: 25.0.50; find-function fails on advised subrs (again)
2015-06-04 0:09 ` Dmitry Gutov
@ 2015-06-04 15:55 ` Stefan Monnier
2015-06-04 22:36 ` Dmitry Gutov
0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2015-06-04 15:55 UTC (permalink / raw
To: Dmitry Gutov; +Cc: michael_heerdegen, 20718
> Something like the patch below should fix it, but then the function
> returns a #<subr> object, instead of function symbol, and several callers
> seem to depend on the return value being the latter (because they want to
> call symbol-function on it).
Indeed, even its docstring says that it returns "the original function
symbol", and that's basically meaningless in general (and in the
nadvice case in particular).
So the callers will need to be adjusted.
Stefan
> diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el
> index 7ea13d4..75fdfc7 100644
> --- a/lisp/emacs-lisp/find-func.el
> +++ b/lisp/emacs-lisp/find-func.el
> @@ -192,9 +192,9 @@ defined in C.")
> "Return the original function symbol of an advised function FUNC.
> If FUNC is not the symbol of an advised function, just returns FUNC."
> (or (and (symbolp func)
> - (featurep 'advice)
> - (let ((ofunc (cdr (assq 'origname (ad-get-advice-info func)))))
> - (and (fboundp ofunc) ofunc)))
> + (featurep 'nadvice)
> + (let ((ofunc (advice--symbol-function func)))
> + (and (advice--p ofunc) (advice--cd*r ofunc))))
> func))
> (defun find-function-C-source (fun-or-var file type)
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#20718: 25.0.50; find-function fails on advised subrs (again)
2015-06-04 15:55 ` Stefan Monnier
@ 2015-06-04 22:36 ` Dmitry Gutov
0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Gutov @ 2015-06-04 22:36 UTC (permalink / raw
To: Stefan Monnier; +Cc: michael_heerdegen, 20718-done
Version: 25.1
On 06/04/2015 06:55 PM, Stefan Monnier wrote:
> So the callers will need to be adjusted.
Ok, done. I seems to work now.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-06-04 22:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-02 12:49 bug#20718: 25.0.50; find-function fails on advised subrs (again) Michael Heerdegen
2015-06-04 0:09 ` Dmitry Gutov
2015-06-04 15:55 ` Stefan Monnier
2015-06-04 22:36 ` Dmitry Gutov
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.