From a98413726f5a10676f9faf4c4013ac6eaa53b42b Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Tue, 7 Jun 2022 10:30:47 -0400 Subject: [PATCH] find-func.el: Fix bug#41104 * lisp/emacs-lisp/find-func.el (find-function-advised-original): Look at the actual function definition rather than `advice--symbol-function` which sometimes returns only the advice. * test/lisp/emacs-lisp/find-func-tests.el (find-func-tests--find-library-verbose): Add test. --- lisp/emacs-lisp/find-func.el | 6 +++--- test/lisp/emacs-lisp/find-func-tests.el | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el index 96eaf1ab642..2dec51dd044 100644 --- a/lisp/emacs-lisp/find-func.el +++ b/lisp/emacs-lisp/find-func.el @@ -270,7 +270,7 @@ If FUNC is not a symbol, return it. Else, if it's not advised, return the symbol's function definition." (or (and (symbolp func) (featurep 'nadvice) - (let ((ofunc (advice--symbol-function func))) + (let ((ofunc (symbol-function func))) (if (advice--p ofunc) (advice--cd*r ofunc) ofunc))) @@ -516,8 +516,8 @@ Return t if any PRED returns t." (defun find-function-library (function &optional lisp-only verbose) "Return the pair (ORIG-FUNCTION . LIBRARY) for FUNCTION. -ORIG-FUNCTION is the original name, after removing all advice and -resolving aliases. LIBRARY is an absolute file name, a relative +ORIG-FUNCTION is the original name, after resolving aliases. +LIBRARY is an absolute file name, a relative file name inside the C sources directory, or a name of an autoloaded feature. diff --git a/test/lisp/emacs-lisp/find-func-tests.el b/test/lisp/emacs-lisp/find-func-tests.el index d29d9ff6563..420c61acb55 100644 --- a/test/lisp/emacs-lisp/find-func-tests.el +++ b/test/lisp/emacs-lisp/find-func-tests.el @@ -95,6 +95,13 @@ expected function symbol and function library, respectively." (advice-remove #'mark-sexp 'my-message)) (ert-deftest find-func-tests--find-library-verbose () + (unwind-protect + (progn + (advice-add 'dired :before #'ignore) + ;; bug#41104 + (should (equal (find-function-library #'dired) '(dired . "dired")))) + (advice-remove 'dired #'ignore)) + (find-function-library #'join-line nil t) (with-current-buffer "*Messages*" (save-excursion -- 2.39.2