From c818ea5b33439fb523d247cdf010dd5744e6feb3 Mon Sep 17 00:00:00 2001 From: Wilfred Hughes Date: Mon, 1 Oct 2018 21:09:43 -0700 Subject: Fix function aliases of primitive functions Fixes #159 --- CHANGELOG.md | 3 +++ helpful.el | 15 +++++++++++---- test/helpful-unit-test.el | 3 +++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 95c30cf..e6830fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,9 @@ narrowed. Navigation keybindings now work in callee list buffers. +Fixed an issue where we didn't show function aliases as aliases when +they pointed to a primitive function. + # v0.13 Buffer-local variables are now highlighted, and it's possible to see 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) diff --git a/test/helpful-unit-test.el b/test/helpful-unit-test.el index d04acca..60d024e 100644 --- a/test/helpful-unit-test.el +++ b/test/helpful-unit-test.el @@ -416,6 +416,9 @@ and that buffer has been killed, handle it gracefully." (eq (helpful--canonical-symbol 'not t) 'null)) (should + (eq (helpful--canonical-symbol 'search-forward-regexp t) + 're-search-forward)) + (should (eq (helpful--canonical-symbol 'emacs-bzr-version nil) 'emacs-repository-version))) -- cgit v1.0