Skip to content

Commit

Permalink
[clojure-emacs#1032] Combine jump-to-var and jump-to-resource into on…
Browse files Browse the repository at this point in the history
…e function
  • Loading branch information
EricGebhart committed Mar 21, 2015
1 parent e96925e commit 5fc2847
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
* [#958](https://github.com/clojure-emacs/cider/pull/958) Reuse existing repl
buffers with dead processes. Users are now informed about existing zombie repl
buffers and are offered the choice to reuse those for new connections.
* [#1032](https://github.com/clojure-emacs/cider/issues/1032) New function jump-to-resource-or-var
combines the functionality of jump-to-var and jump-to-resource.

### Changes

Expand Down
26 changes: 26 additions & 0 deletions cider-interaction.el
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,32 @@ window."
(when pos
(goto-char pos)))))

(defun cider-jump-to-resource-or-var (symbol-file &optional other-window)
"Try to jump to the variable at point.
If variable is not found, try to jump to resource of the same name.
When called interactively, A prompt is given with a default value of
thing at point. If a prefix is given then the result is opened in 'other-window'. "
(interactive
(list (read-string "Jump to: " (thing-at-point 'filename)
nil (thing-at-point 'filename))
current-prefix-arg))
(-if-let (info (cider-var-info symbol-file))
(cider--jump-to-loc-from-info info other-window)
(progn
(cider-ensure-op-supported "resource")
(-if-let* ((resource (cider-sync-request:resource symbol-file))
(buffer (cider-find-file resource)))
(cider-jump-to buffer 0 other-window)
(message "Resource or variable %s not resolved" symbol-file)))))

(defun cider-jump-to-resource-or-var-other-window (symbol-file)
"jump to var or resource at point, place results in other window."
(interactive
(list (read-string "Jump to: " (thing-at-point 'filename)
nil (thing-at-point 'filename))))
(cider-jump-to-resource-or-var symbol-file t))


(defun cider-jump-to-resource (path)
"Jump to the resource at the resource-relative PATH.
When called interactively, this operates on point."
Expand Down

0 comments on commit 5fc2847

Please sign in to comment.