commit d04a7bc38439e97f5c6a9f8bdcb98ef52a6060b8
parent 563c511704cb0a05af859ce1fcd2809c9392e48b
Author: Wilfred Hughes <me@wilfred.me.uk>
Date: Mon, 12 Mar 2018 23:09:48 +0000
Mark new variable buffers as opened
Fixes #101
Diffstat:
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
@@ -1,6 +1,7 @@
# v0.9
-No changes yet.
+Fixed an issue when looking at variable docs where we would visit the
+definition buffer without the user requesting it.
# v0.8
diff --git a/helpful.el b/helpful.el
@@ -996,6 +996,8 @@ buffer."
(condition-case _err
(-let [(sym-buf . sym-pos) (find-definition-noselect sym 'defvar)]
(setq buf sym-buf)
+ (unless (-contains-p initial-buffers buf)
+ (setq opened t))
(setq pos sym-pos))
(search-failed nil)
;; If your current Emacs instance doesn't match the source
diff --git a/test/unit-test.el b/test/unit-test.el
@@ -221,6 +221,15 @@ symbol (not a form)."
variables defined without `defvar'."
(helpful--definition 'helpful-var-without-defvar nil))
+(ert-deftest helpful--definition-buffer-opened ()
+ "Ensure we mark buffers as opened for variables."
+ (require 'python)
+ ;; This test will fail if you already have python.el.gz open in your
+ ;; Emacs instance.
+ (-let [(buf pos opened) (helpful--definition 'python-indent-offset nil)]
+ (should (bufferp buf))
+ (should opened)))
+
(ert-deftest helpful--definition-edebug-fn ()
"Ensure we use the position information set by edebug, if present."
;; Test with both edebug enabled and disabled. The edebug property