commit 94a07d49a80f66f8ebc54a49a4b4f6899a65fbe3 parent 209971ba9f576ba080352642cfbf25df5692b1d7 Author: Kisaragi Hiu <mail@kisaragi-hiu.com> Date: Mon, 30 May 2022 09:22:03 +0900 Fix advised native-compiled function being treated as primitives In Emacs 28, subrp is t for a native-compiled function; to check whether a function is a primitive, there is a new function subr-primitive-p. Previously, unadvised functions have an extra check that does the same thing as subr-primitive-p, but that was not applied to advised functions. This applies it to both. Diffstat:
| M | helpful.el | | | 29 | +++++++++++++++-------------- |
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/helpful.el b/helpful.el @@ -1684,20 +1684,21 @@ POSITION-HEADS takes the form ((123 (defun foo)) (456 (defun bar)))." (defun helpful--primitive-p (sym callable-p) "Return t if SYM is defined in C." - (cond - ((and callable-p (helpful--advised-p sym)) - (subrp (helpful--without-advice sym))) - (callable-p - (and (not (and (fboundp 'subr-native-elisp-p) - (subr-native-elisp-p (indirect-function sym)))) - (subrp (indirect-function sym)))) - (t - (let ((filename (find-lisp-object-file-name sym 'defvar))) - (or (eq filename 'C-source) - (and (stringp filename) - (let ((ext (file-name-extension filename))) - (or (equal ext "c") - (equal ext "rs"))))))))) + (let ((subrp (if (fboundp 'subr-primitive-p) + #'subr-primitive-p + #'subrp))) + (cond + ((and callable-p (helpful--advised-p sym)) + (funcall subrp (helpful--without-advice sym))) + (callable-p + (funcall subrp (indirect-function sym))) + (t + (let ((filename (find-lisp-object-file-name sym 'defvar))) + (or (eq filename 'C-source) + (and (stringp filename) + (let ((ext (file-name-extension filename))) + (or (equal ext "c") + (equal ext "rs")))))))))) (defun helpful--sym-value (sym buf) "Return the value of SYM in BUF."