aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilfred Hughes <me@wilfred.me.uk>2018-03-12 23:09:48 +0000
committerWilfred Hughes <me@wilfred.me.uk>2018-03-12 23:10:58 +0000
commitd04a7bc38439e97f5c6a9f8bdcb98ef52a6060b8 (patch)
treeac8a69a44610263ba4a87b3c888e04737b70130f
parent563c511704cb0a05af859ce1fcd2809c9392e48b (diff)
Mark new variable buffers as opened
Fixes #101
-rw-r--r--CHANGELOG.md3
-rw-r--r--helpful.el2
-rw-r--r--test/unit-test.el9
3 files changed, 13 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e03b9cd..7646b87 100644
--- 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
index 04095ec..632a41d 100644
--- 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
index 8043ff1..2a42c10 100644
--- 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