aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilfred Hughes <me@wilfred.me.uk>2021-12-10 22:09:39 -0800
committerWilfred Hughes <me@wilfred.me.uk>2021-12-10 22:10:04 -0800
commit55a8ebcd644bedf7330ac6c744ca66a48fea01b1 (patch)
treec3c257ada47455f7116a9c406812fb1203a43202
parent217b38398bfa523c48f630b06b21427974d93e1d (diff)
Fix crash on lambdas with docstrings
Spotted when debugging #278.
-rw-r--r--helpful.el2
-rw-r--r--test/helpful-unit-test.el7
2 files changed, 8 insertions, 1 deletions
diff --git a/helpful.el b/helpful.el
index 3e064d7..b54914f 100644
--- a/helpful.el
+++ b/helpful.el
@@ -2257,7 +2257,7 @@ state of the current symbol."
(insert (helpful--format-docstring docstring)))
(when version-info
(insert "\n\n" (s-word-wrap 70 version-info)))
- (when (helpful--in-manual-p helpful--sym)
+ (when (and (symbolp helpful--sym) (helpful--in-manual-p helpful--sym))
(insert "\n\n")
(insert (helpful--make-manual-button helpful--sym)))))
diff --git a/test/helpful-unit-test.el b/test/helpful-unit-test.el
index 510396c..0cfef04 100644
--- a/test/helpful-unit-test.el
+++ b/test/helpful-unit-test.el
@@ -566,6 +566,13 @@ associated a lambda with a keybinding."
(with-current-buffer buf
(helpful-update))))
+(ert-deftest helpful--unnamed-func-with-docstring ()
+ (let* ((fun (lambda (x) "Foo" x))
+ (buf (helpful--buffer fun t)))
+ ;; Don't crash when we show the buffer.
+ (with-current-buffer buf
+ (helpful-update))))
+
(ert-deftest helpful--unnamed-compiled-func ()
"Ensure we handle unnamed byte-compiled functions.