Skip to content

Commit

Permalink
re clojure-emacs#462 - jump-to-def via 'info' op
Browse files Browse the repository at this point in the history
  • Loading branch information
gtrak committed Jan 31, 2014
1 parent c058189 commit 399d343
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions cider-interaction.el
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,7 @@ 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)
(let ((form (format "(let [ns-symbol '%s
ns-var '%s
ns-file (clojure.core/comp :file
Expand Down Expand Up @@ -530,6 +529,28 @@ Uses `find-file'."
(cider-jump-to-def-handler (current-buffer))
nrepl-buffer-ns)))

(defun cider-jump-to-def-op-fn (var)
"Use the info op to jump to a definition"
(let* ((val (plist-get (nrepl-send-request-sync
(list "op" "info"
"session" (nrepl-current-session)
"ns" nrepl-buffer-ns
"symbol" var))
:value))
(val-alist (loop
while val
collect (subseq val 0 2)
do (setf val (nthcdr 2 val))))
(file (cadr (assoc "file" val-alist)))
(line (cadr (assoc "line" val-alist))))
(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."
(interactive "P")
Expand Down

0 comments on commit 399d343

Please sign in to comment.