Skip to content

Commit

Permalink
[Fix clojure-emacs#1014] Jump-to other window with prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
EricGebhart committed Mar 20, 2015
1 parent 0081a31 commit 67fd539
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
* Enable annotated completion candidates by default.
* [#1031] (https://github.com/clojure-emacs/cider/pull/1031) Interactive functions prompt with
symbol at point as a default value.
* [#1014] (https://github.com/clojure-emacs/cider/issues/1014) Prefix (C-u) to jump-to-var or
jump-to-resource causes jump to go to other window.

### Bugs fixed

Expand Down
30 changes: 17 additions & 13 deletions cider-interaction.el
Original file line number Diff line number Diff line change
Expand Up @@ -762,14 +762,17 @@ window."
(when pos
(goto-char pos)))))

(defun cider-jump-to-resource (path)
(defun cider-jump-to-resource (other-window path)
"Jump to the resource at the resource-relative PATH.
When called interactively, this operates on point."
(interactive (list (thing-at-point 'filename)))
When called interactively, this operates on point. If a prefix is
given then resource is opened in 'other-window'. "
(interactive (list current-prefix-arg
(read-string "resource: " (thing-at-point 'filename)
nil (thing-at-point 'filename))))
(cider-ensure-op-supported "resource")
(-if-let* ((resource (cider-sync-request:resource path))
(buffer (cider-find-file resource)))
(cider-jump-to buffer)
(cider-jump-to buffer 0 other-window)
(message "Cannot find resource %s" path)))

(defun cider--jump-to-loc-from-info (info &optional other-window)
Expand All @@ -785,22 +788,23 @@ OTHER-WINDOW is passed to `cider-jamp-to'."
(cider-jump-to buffer (cons line nil) other-window)
(message "No source location"))))

(defun cider--jump-to-var (var &optional line)
(defun cider--jump-to-var (var &optional other-window &optional line)
"Jump to the definition of VAR, optionally at a specific LINE."
(-if-let (info (cider-var-info var))
(progn
(if line (setq info (nrepl-dict-put info "line" line)))
(cider--jump-to-loc-from-info info))
(cider--jump-to-loc-from-info info other-window))
(message "Symbol %s not resolved" var)))

(defun cider-jump-to-var (&optional var line)
(defun cider-jump-to-var (other-window &optional var line)
"Jump to the definition of VAR, optionally at a specific LINE.
When called interactively, prompts with symbol at point."
(interactive)
When called interactively, prompts with symbol at point. If prefix-arg
then jump-to-var will go to other-window."
(interactive "P")
(cider-ensure-op-supported "info")
(if var
(cider--jump-to-var var line)
(cider-read-symbol-name "Symbol: " #'cider--jump-to-var)))
(cider--jump-to-var var other-window line)
(cider-read-symbol-name "Symbol: " #'cider--jump-to-var other-window)))

(define-obsolete-function-alias 'cider-jump 'cider-jump-to-var "0.7.0")
(defalias 'cider-jump-back 'pop-tag-mark)
Expand Down Expand Up @@ -1745,10 +1749,10 @@ ready to call."
(cider-repl--replace-input (format "(%s)" f))
(goto-char (- (point-max) 1)))))))

(defun cider-read-symbol-name (prompt callback &optional query)
(defun cider-read-symbol-name (prompt callback &optional arg)
"Read a symbol name using PROMPT with a default of the one at point.
Use CALLBACK as the completing read var callback."
(funcall callback (cider-read-from-minibuffer prompt (cider-symbol-at-point))))
(funcall callback (cider-read-from-minibuffer prompt (cider-symbol-at-point)) arg))

(defun cider-sync-request:toggle-trace-var (symbol)
"Toggle var tracing for SYMBOL."
Expand Down

0 comments on commit 67fd539

Please sign in to comment.