Skip to content

Commit eed90f3

Browse files
author
Bozhidar Batsov
committed
Simplify var def lookup
The extra gymnastics are not needed now that interactive eval sets the var location metadata.
1 parent 8575110 commit eed90f3

File tree

2 files changed

+5
-36
lines changed

2 files changed

+5
-36
lines changed

cider-interaction.el

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -713,20 +713,11 @@ When called interactively, this operates on point."
713713
"Jump to location give by INFO.
714714
INFO object is returned by `cider-var-info' or `cider-member-info'.
715715
OTHER-BUFFER is passed to `cider-jamp-to'."
716-
(-if-let* ((line (nrepl-dict-get info "line"))
717-
(file (nrepl-dict-get info "file"))
718-
(buffer (unless (cider--tooling-file-p file)
719-
(cider-find-file file))))
720-
(cider-jump-to buffer (cons line nil) other-buffer)
721-
;; var was created interactively and has no file info
722-
(-if-let* ((ns (nrepl-dict-get info "ns"))
723-
(name (nrepl-dict-get info "name"))
724-
(buffer (cider-find-buffer ns))
725-
(pos (cider-locate-def name buffer line)))
726-
(cider-jump-to buffer pos other-buffer)
727-
(-if-let (name (nrepl-dict-get info "name"))
728-
(message "No location found for %s" name)
729-
(message "No source info")))))
716+
(let* ((line (nrepl-dict-get info "line"))
717+
(file (nrepl-dict-get info "file"))
718+
(buffer (unless (cider--tooling-file-p file)
719+
(cider-find-file file))))
720+
(cider-jump-to buffer (cons line nil) other-buffer)))
730721

731722
(defun cider-jump-to-var (&optional var line)
732723
"Jump to the definition of VAR, optionally at a specific LINE.

cider-util.el

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -146,28 +146,6 @@ Unless you specify a BUFFER it will default to the current one."
146146
(pkg-info-version-info 'cider)
147147
(error cider-version)))
148148

149-
(defun cider-find-buffer (ns)
150-
"Find an open buffer by NS."
151-
(->> (cider-util--clojure-buffers)
152-
(--filter (equal ns (with-current-buffer it (clojure-find-ns))))
153-
(car)))
154-
155-
(defun cider-locate-def (name buffer &optional offset-lines)
156-
"Locate the definition of var NAME in BUFFER.
157-
When OFFSET-LINES is non-nil, adjust the returned position by this many
158-
lines. This is a regexp search and currently works only for top level
159-
clojure forms that start with '(def'."
160-
(with-current-buffer buffer
161-
(save-restriction
162-
(widen)
163-
(goto-char (point-min))
164-
(re-search-forward (format "(def.* %s\\( \\|$\\)" name)
165-
nil 'no-error)
166-
(goto-char (match-beginning 0))
167-
(when offset-lines
168-
(forward-line (1- offset-lines)))
169-
(point))))
170-
171149
;;; Strings
172150

173151
(defun cider-string-join (strings &optional separator)

0 commit comments

Comments
 (0)