commit 598d4acde5f9812cb3a58a4a996889ae611bd7b7
parent b3c7741480e6a6a22d74e76f951f46f5ed2d86b8
Author: Wilfred Hughes <me@wilfred.me.uk>
Date: Tue, 24 Jul 2018 09:01:55 +0100
Merge pull request #145 from nickdrozd/lambda-callees
helpful--show-callees choked on anonymous functions
Diffstat:
2 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/helpful.el b/helpful.el
@@ -610,8 +610,7 @@ overrides that to include previously opened buffers."
(erase-buffer)
(insert
;; TODO: Macros used, special forms used, global vars used.
- (format "Functions called by %s:\n\n"
- (symbol-name sym)))
+ (format "Functions called by %s:\n\n" sym))
(dolist (sym syms)
(insert " "
(helpful--button
@@ -1532,6 +1531,13 @@ OBJ may be a symbol or a compiled function object."
'symbol sym
'callable-p callable-p))
+(defun helpful--make-callees-button (sym source)
+ (helpful--button
+ "Find callees"
+ 'helpful-callees-button
+ 'symbol sym
+ 'source source))
+
(defun helpful--summary (sym callable-p buf pos)
"Return a one sentence summary for SYM."
(-let* ((primitive-p (helpful--primitive-p sym callable-p))
@@ -1888,11 +1894,7 @@ state of the current symbol."
(when (and helpful--callable-p source (not primitive-p))
(insert
" "
- (helpful--button
- "Find callees"
- 'helpful-callees-button
- 'symbol helpful--sym
- 'source source)))
+ (helpful--make-callees-button helpful--sym source)))
(when (helpful--advised-p helpful--sym)
(helpful--insert-section-break)
diff --git a/test/unit-test.el b/test/unit-test.el
@@ -716,3 +716,19 @@ find the source code."
(apply #'bar 2)))))
(should (memq 'foo result))
(should (memq 'bar result))))
+
+(ert-deftest helpful--callees-button--smoke ()
+ (with-temp-buffer
+ (let ((button (helpful--make-callees-button
+ 'whatever
+ '(defun whatever () (something) (test 5)))))
+ (insert button)
+ (goto-char (point-min))
+ (push-button)))
+ (with-temp-buffer
+ (let ((button (helpful--make-callees-button
+ '(lambda () (interactive) (other-window -1))
+ '(lambda () (interactive) (other-window -1)))))
+ (insert button)
+ (goto-char (point-min))
+ (push-button))))