diff options
author | Roman Scherer <roman@burningswell.com> | 2014-08-08 15:51:25 +0200 |
---|---|---|
committer | Roman Scherer <roman@burningswell.com> | 2014-08-21 10:08:46 +0200 |
commit | c442e8133a78625f611fa9ca523d5a892f31963e (patch) | |
tree | 1dfccf63528dcfdbe9b036cea181708249e7e49e /cider-interaction.el | |
parent | c8e9dd1c02636002c910895ba419e4bb584765ee (diff) |
Don't move point when clearing or highlighting test results
When running tests with cider-test failing tests are highlighted in the source
files, or if tests are passing again previous highlights are cleared. The code
that does this is using the `cider-find-var` function to find the buffer for a
vars under test and then does it's job.
`cider-find-var` used to move point to the line at which the var was found. This
is a problematic side effect, because code using `cider-find-var` to find the
buffer can't use save-excursion because it doesn't know which buffer to safe
beforehand.
This PR removes the `goto-line` in `cider-find-var` and returns just the buffer
without any side effect. The `cider-company-location` uses similar code as
`cider-find-var` but with `save-excursion` wrapped around it.
Diffstat (limited to 'cider-interaction.el')
-rw-r--r-- | cider-interaction.el | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/cider-interaction.el b/cider-interaction.el index 117f6b5b..b6debc36 100644 --- a/cider-interaction.el +++ b/cider-interaction.el @@ -636,17 +636,13 @@ path or an entry within a zip/jar archive." (set-auto-mode) (current-buffer)))))))) -(defun cider-find-var (var) - "Return a buffer visiting the definition for VAR, or nil if not found." +(defun cider-find-var-file (var) + "Return the buffer visiting the file in which VAR is defined, or nil if +not found." (cider-ensure-op-supported "info") (-when-let* ((info (cider-var-info var)) - (file (cadr (assoc "file" info))) - (line (cadr (assoc "line" info))) - (buffer (cider-find-file file))) - (with-current-buffer buffer - (goto-char (point-min)) - (forward-line (1- line)) - buffer))) + (file (cadr (assoc "file" info)))) + (cider-find-file file))) (defun cider-jump-to (buffer &optional pos) "Push current point onto marker ring, and jump to BUFFER to position POS. @@ -790,9 +786,14 @@ as it's not obvious from their names alone which is which." Returns the cons of the buffer itself and the location of VAR's definition in the buffer." - (-when-let (buffer (cider-find-var var)) + (-when-let* ((info (cider-var-info var)) + (file (cadr (assoc "file" info))) + (line (cadr (assoc "line" info))) + (buffer (cider-find-file file))) (with-current-buffer buffer - (cons buffer (point))))) + (save-excursion + (goto-line line) + (cons buffer (point)))))) (defun cider-company-docsig (thing) "Return signature for THING." |