helpful

a fork of Wilfred's helpful
git clone https://git.trogloxene.org/helpful.git
Log | Files | Refs | README

commit 967dc742f866005da2e61fbd548bfdbf32d788fe
parent dae62eed7d7abfaaaf1746ced458d428b724d702
Author: Wilfred Hughes <me@wilfred.me.uk>
Date:   Sun, 10 Dec 2017 20:32:43 +0000

Only try to kill the buffer we've created

If buf (the buffer containing the symbol definition) is nil, we end up
killing the current buffer. The current buffer is the buffer that
we're trying to write into.

Fixes #58

Diffstat:
Mhelpful.el | 10++++++----
Mtest/unit-test.el | 6++++--
2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/helpful.el b/helpful.el @@ -429,10 +429,12 @@ for killing the newly created buffer." "Return the path where SYM is defined." (-let* ((initial-buffers (buffer-list)) ((buf . _) (helpful--definition sym callable-p)) - (path (when buf (buffer-file-name buf)))) - ;; If we've just created this buffer, close it. - (unless (-contains-p initial-buffers buf) - (kill-buffer buf)) + (path)) + (when buf + (setq path (buffer-file-name buf)) + ;; If we've just created this buffer, close it. + (unless (-contains-p initial-buffers buf) + (kill-buffer buf))) path)) (defun helpful--source-pos (sym callable-p) diff --git a/test/unit-test.el b/test/unit-test.el @@ -40,10 +40,12 @@ "We should not crash on a function without a docstring." (should (null (helpful--docstring #'test-foo-no-docstring t)))) -(ert-deftest helpful--interacively-defined-fn () +(ert-deftest helpful--interactively-defined-fn () "We should not crash on a function without source code." (eval '(defun test-foo-defined-interactively () 42)) - (helpful-function #'test-foo-defined-interactively)) + (with-temp-buffer + (helpful-function #'test-foo-defined-interactively) + (should (equal (buffer-name) "*helpful function: test-foo-defined-interactively*")))) (defun test-foo-usage-docstring () "\n\n(fn &rest ARGS)"