Skip to content

Commit

Permalink
Merge pull request #465 from gtrak/master
Browse files Browse the repository at this point in the history
re #462 - jump-to-def via 'info' op
  • Loading branch information
bbatsov committed Feb 7, 2014
2 parents d919f5b + 1c3d175 commit 56dc504
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

### New features

* [#460](https://github.com/clojure-emacs/cider/issues/316) Support for
* [#460](https://github.com/clojure-emacs/cider/issues/460) Support for
cider-nrepl's complete middleware for CLJ/CLJS autocomplete.
* [#465](https://github.com/clojure-emacs/cider/issues/465) Support for
cider-nrepl's info middleware for jump-to-definition.
* [#469](https://github.com/clojure-emacs/cider/issues/469) Add option
`cider-prompt-save-file-on-load`.
* New interactive command `cider-insert-defun-in-repl`.
Expand Down
26 changes: 23 additions & 3 deletions cider-interaction.el
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,8 @@ Uses `find-file'."
(lambda (buffer err) (message err))
nil))

(defun cider-jump-to-def (var)
"Jump to the definition of the VAR at point."
(defun cider--jump-to-def-eval-fn (var)
"Jump to VAR using the old eval method"
(let ((form (format "(let [ns-symbol '%s
ns-var '%s
ns-file (clojure.core/comp :file
Expand Down Expand Up @@ -531,7 +531,27 @@ Uses `find-file'."
(cider-current-ns) var)))
(cider-tooling-eval form
(cider-jump-to-def-handler (current-buffer))
nrepl-buffer-ns)))
(cider-current-ns))))

(defun cider--jump-to-def-op-fn (var)
"Pass the VAR into the info in order to jump to a definition"
(let* ((val (plist-get (nrepl-send-request-sync
(list "op" "info"
"session" (nrepl-current-session)
"ns" (cider-current-ns)
"symbol" var))
:value))
(val-alist (-partition 2 val))
(file (cadr (assoc "file" val-alist)))
(line (cadr (assoc "line" val-alist))))
(ring-insert find-tag-marker-ring (point-marker))
(cider-jump-to-def-for (vector file file line))))

(defun cider-jump-to-def (var)
"Jump to the definition of the VAR at point."
(if (nrepl-op-supported-p "info")
(cider--jump-to-def-op-fn var)
(cider--jump-to-def-eval-fn var)))

(defun cider-jump (query)
"Jump to the definition of QUERY."
Expand Down

0 comments on commit 56dc504

Please sign in to comment.