aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilfred Hughes <me@wilfred.me.uk>2018-09-23 23:19:12 +0100
committerGitHub <noreply@github.com>2018-09-23 23:19:12 +0100
commit500bc280d075d1e3fb86a3ccc8b638b524329adb (patch)
tree49244a4077b0399253d16b9144e3473adfd7f0a6
parent607048aec0a198b3ebe9c2a85bc96e982a15af96 (diff)
parentbb41e5dd9141388338df1508675da89e60d029fc (diff)
Merge pull request #157 from nickdrozd/kbd
Add support for named keyboard macros
-rw-r--r--CHANGELOG.md4
-rw-r--r--helpful.el18
-rw-r--r--test/helpful-unit-test.el7
3 files changed, 27 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 473eede..c8bf223 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# 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
whole surrounding function. This was less useful and significantly
slower.
diff --git a/helpful.el b/helpful.el
index b85008e..7ced389 100644
--- 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)))
@@ -1641,6 +1648,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"
@@ -1666,6 +1678,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)
@@ -1688,6 +1701,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
@@ -1702,6 +1716,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"))))
@@ -1838,7 +1853,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
index dba4e25..d04acca 100644
--- 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."