helpful

a fork of Wilfred's helpful
git clone https://git.trogloxene.org/helpful.git
Log | Files | Refs | README

commit bb41e5dd9141388338df1508675da89e60d029fc
parent a0e052896b2b4dd4f4bc6bef0065f9c6eaa2a75d
Author: Nick Drozd <nicholasdrozd@gmail.com>
Date:   Wed, 12 Sep 2018 19:13:57 -0500

Add support for named keyboard macros

Diffstat:
MCHANGELOG.md | 2++
Mhelpful.el | 18+++++++++++++++++-
Mtest/helpful-unit-test.el | 7++++++-
3 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md @@ -1,5 +1,7 @@ # v0.14 (unreleased) +Named keyboard macros are now supported. + Function callees are now sorted. Fixed an issue where source code of primitive variables included the diff --git a/helpful.el b/helpful.el @@ -346,6 +346,13 @@ source code to primitives." 'symbol nil 'help-echo "Toggle edebug (re-evaluates definition)") +(defun helpful--kbd-macro-p (sym) + "Is SYM a keyboard macro?" + (and (symbolp sym) + (let ((func (symbol-function sym))) + (or (stringp func) + (vectorp func))))) + (defun helpful--edebug-p (sym) "Does function SYM have its definition patched by edebug?" (let ((fn-def (indirect-function sym))) @@ -1630,6 +1637,11 @@ OBJ may be a symbol or a compiled function object." "special form" 'helpful-info-button 'info-node "(elisp)Special Forms")) + (keyboard-macro-button + (helpful--button + "keyboard macro" + 'helpful-info-button + 'info-node "(elisp)Keyboard Macros")) (interactive-button (helpful--button "interactive" @@ -1655,6 +1667,7 @@ OBJ may be a symbol or a compiled function object." alias-button)) ((and callable-p (commandp sym) autoloaded-p) (format "an %s, %s" interactive-button autoload-button)) + ((helpful--kbd-macro-p sym) "a") ((and callable-p (commandp sym)) (format "an %s" interactive-button)) ((and callable-p autoloaded-p) @@ -1677,6 +1690,7 @@ OBJ may be a symbol or a compiled function object." 'callable-p callable-p))) ((not callable-p) "variable") ((macrop sym) "macro") + ((helpful--kbd-macro-p sym) keyboard-macro-button) (t "function"))) (defined (cond @@ -1691,6 +1705,7 @@ OBJ may be a symbol or a compiled function object." (helpful--buffer-button buf pos))))) (primitive-p "defined in C source code") + ((helpful--kbd-macro-p sym) "") (t "without a source file")))) @@ -1827,7 +1842,8 @@ state of the current symbol." (insert (helpful--summary helpful--sym helpful--callable-p buf pos)) - (when helpful--callable-p + (when (and helpful--callable-p + (not (helpful--kbd-macro-p helpful--sym))) (helpful--insert-section-break) (insert (helpful--heading "Signature") diff --git a/test/helpful-unit-test.el b/test/helpful-unit-test.el @@ -137,7 +137,12 @@ symbol (not a form)." ;; We should not crash when looking at macros. (helpful-callable 'when) ;; Special forms should work too. - (helpful-callable 'if)) + (helpful-callable 'if) + ;; Named keyboard macros (strings and vectors). + (fset 'aaa "aaa") + (helpful-callable 'aaa) + (fset 'backspace-return [backspace return]) + (helpful-callable 'backspace-return)) (ert-deftest helpful-callable--with-C-source () "Smoke test for special forms when we have the Emacs C source loaded."