commit b3c7741480e6a6a22d74e76f951f46f5ed2d86b8
parent 89668dd787248c7f0d35d4ab26f4a61f2efefdcb
Author: Wilfred Hughes <me@wilfred.me.uk>
Date: Mon, 23 Jul 2018 23:43:55 +0100
Don't describe special forms as functions
Fixes #142
Diffstat:
3 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
@@ -5,6 +5,9 @@ all the different values of a buffer-local variable.
Variable values are now shown before docstrings.
+Fixed an issue where special forms were incorrectly described as
+functions.
+
# v0.12
Added a 'pretty view' for string values, keymap values, and hooks.
diff --git a/helpful.el b/helpful.el
@@ -1550,6 +1550,11 @@ OBJ may be a symbol or a compiled function object."
"alias"
'helpful-info-button
'info-node "(elisp)Variable Aliases")))
+ (special-form-button
+ (helpful--button
+ "special form"
+ 'helpful-info-button
+ 'info-node "(elisp)Special Forms"))
(interactive-button
(helpful--button
"interactive"
@@ -1592,6 +1597,8 @@ OBJ may be a symbol or a compiled function object."
"a")))
(kind
(cond
+ ((special-form-p sym)
+ special-form-button)
(alias-p
(format "for %s,"
(helpful--button
diff --git a/test/unit-test.el b/test/unit-test.el
@@ -610,6 +610,14 @@ find the source code."
summary
"-select is a function alias for -filter, defined in dash.el."))))
+(ert-deftest helpful--summary--special-form ()
+ "Ensure we describe special forms correctly"
+ (-let* ((summary (helpful--summary 'if t nil nil)))
+ ;; Strip properties to make assertion messages more readable.
+ (set-text-properties 0 (1- (length summary)) nil summary)
+ (should
+ (s-starts-with-p "if is a special form defined in" summary))))
+
(ert-deftest helpful--bound-p ()
;; Functions.
(should (helpful--bound-p 'message))