aboutsummaryrefslogtreecommitdiff
path: root/helpful.el
diff options
context:
space:
mode:
authorWilfred Hughes <me@wilfred.me.uk>2018-10-01 21:09:43 -0700
committerWilfred Hughes <me@wilfred.me.uk>2018-10-01 21:10:34 -0700
commitc818ea5b33439fb523d247cdf010dd5744e6feb3 (patch)
treefb24bad0c51655f25f2f992154d0b3e2c93c7efb /helpful.el
parent09e6afb6b86512669ff8013d5a454295bdfe8399 (diff)
Fix function aliases of primitive functions
Fixes #159
Diffstat (limited to 'helpful.el')
-rw-r--r--helpful.el15
1 files changed, 11 insertions, 4 deletions
diff --git a/helpful.el b/helpful.el
index d4c5611..2ecc9ab 100644
--- a/helpful.el
+++ b/helpful.el
@@ -200,10 +200,17 @@ press \\[keyboard-quit] to gracefully stop the printing."
Return SYM otherwise."
(let ((depth 0))
(if (and (symbolp sym) callable-p)
- (while (and (symbolp (symbol-function sym))
- (< depth 10))
- (setq sym (symbol-function sym))
- (setq depth (1+ depth)))
+ (progn
+ ;; Follow the chain of symbols until we find a symbol that
+ ;; isn't pointing to a symbol.
+ (while (and (symbolp (symbol-function sym))
+ (< depth 10))
+ (setq sym (symbol-function sym))
+ (setq depth (1+ depth)))
+ ;; If this is an alias to a primitive, return the
+ ;; primitive's symbol.
+ (when (subrp (symbol-function sym))
+ (setq sym (intern (subr-name (symbol-function sym))))))
(setq sym (indirect-variable sym))))
sym)