aboutsummaryrefslogtreecommitdiff
path: root/helpful.el
diff options
context:
space:
mode:
authorKisaragi Hiu <mail@kisaragi-hiu.com>2022-05-30 09:22:03 +0900
committerWilfred Hughes <me@wilfred.me.uk>2022-07-04 10:22:11 -0700
commit94a07d49a80f66f8ebc54a49a4b4f6899a65fbe3 (patch)
tree17af230e108b56a080f4fd3683049731b45e2506 /helpful.el
parent209971ba9f576ba080352642cfbf25df5692b1d7 (diff)
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 (limited to 'helpful.el')
-rw-r--r--helpful.el29
1 files changed, 15 insertions, 14 deletions
diff --git a/helpful.el b/helpful.el
index ad3fa21..c1b5550 100644
--- 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."