commit 5681a5df8e157d0dae9c99df5455755353a68c8b
parent f06fe10b07c8011290488db92653beb910e7cfac
Author: Wilfred Hughes <me@wilfred.me.uk>
Date: Sat, 31 Mar 2018 19:25:37 +0100
Ensure we can find the definitions of interactively defined functions
Diffstat:
3 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
@@ -16,6 +16,9 @@ Wording polish for finding references of primitives.
Fixed some corner cases in references to info manual sections not
being linkified.
+Fixed an issue where the definition of interactively defined functions
+wasn't shown.
+
# v0.8
Added setting `helpful-switch-buffer-function` to allow users to
diff --git a/helpful.el b/helpful.el
@@ -895,10 +895,10 @@ If the source code cannot be found, return the sexp used."
(setq source (propertize source
'helpful-path (buffer-file-name buf)
'helpful-pos start-pos
- 'helpful-pos-is-start t))))
- (when (and buf created)
- (kill-buffer buf))
- (throw 'source source))
+ 'helpful-pos-is-start t)))
+ (when (and buf created)
+ (kill-buffer buf))
+ (throw 'source source)))
(when callable-p
;; Could not find source -- probably defined interactively, or via
diff --git a/test/unit-test.el b/test/unit-test.el
@@ -420,6 +420,15 @@ associated a lambda with a keybinding."
(should
(s-starts-with-p "(defun " source))))
+(ert-deftest helpful--source--interactively-defined-fn ()
+ "We should return the raw sexp for functions where we can't
+find the source code."
+ (eval '(defun test-foo-defined-interactively () 42))
+ (should
+ (not
+ (null
+ (helpful--source #'test-foo-defined-interactively t)))))
+
(ert-deftest helpful--outer-sexp ()
;; If point is in the middle of a form, we should return its position.
(with-temp-buffer