commit 55a8ebcd644bedf7330ac6c744ca66a48fea01b1 parent 217b38398bfa523c48f630b06b21427974d93e1d Author: Wilfred Hughes <me@wilfred.me.uk> Date: Fri, 10 Dec 2021 22:09:39 -0800 Fix crash on lambdas with docstrings Spotted when debugging #278. Diffstat:
| M | helpful.el | | | 2 | +- |
| M | test/helpful-unit-test.el | | | 7 | +++++++ |
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git 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 @@ -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.