Skip to content

Commit

Permalink
add dumb-jump-go-other-window #80
Browse files Browse the repository at this point in the history
  • Loading branch information
jacktasia committed Aug 25, 2016
1 parent c22244c commit 48ddd7b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
26 changes: 24 additions & 2 deletions dumb-jump.el
Expand Up @@ -46,6 +46,11 @@
(define-key map (kbd "C-M-q") 'dumb-jump-quick-look)
map))

(defcustom dumb-jump-window
'current
"Which window to use when jumping valid options are 'current (default) or 'other."
:group 'dumb-jump)

(defcustom dumb-jump-selector
'popup
"Which selector to use when there is multiple choices. `ivy` also supported"
Expand Down Expand Up @@ -848,6 +853,20 @@ denoter file/dir is found or uses dumb-jump-default-profile"
(interactive)
(dumb-jump-go t))

;;;###autoload
(defun dumb-jump-go-other-window ()
"Like 'dumb-jump-go' but use 'find-file-other-window' instead of 'find-file'."
(interactive)
(let ((dumb-jump-window 'other))
(dumb-jump-go)))

;;;###autoload
(defun dumb-jump-go-current-window ()
"Like dumb-jump-go but always use 'find-file'."
(interactive)
(let ((dumb-jump-window 'current))
(dumb-jump-go)))

;;;###autoload
(defun dumb-jump-go (&optional use-tooltip)
"Go to the function/variable declaration for thing at point"
Expand Down Expand Up @@ -958,8 +977,11 @@ denoter file/dir is found or uses dumb-jump-default-profile"
(if (fboundp 'xref-push-marker-stack)
(xref-push-marker-stack)
(ring-insert find-tag-marker-ring (point-marker)))
(unless (string= thefile (buffer-file-name))
(find-file thefile))

(if (eq dumb-jump-window 'other)
(find-file-other-window thefile)
(unless (string= thefile (buffer-file-name))
(find-file thefile)))
(goto-char (point-min))
(forward-line (1- theline))
(forward-char pos)
Expand Down
20 changes: 20 additions & 0 deletions test/dumb-jump-test.el
Expand Up @@ -304,6 +304,26 @@
(mock (dumb-jump-goto-file-line * 3 9))
(should (string= go-js-file (dumb-jump-go)))))))

(ert-deftest dumb-jump-go-other-window-test ()
(let ((js-file (f-join test-data-dir-proj1 "src" "js" "fake2.js"))
(go-js-file (f-join test-data-dir-proj1 "src" "js" "fake.js")))
(with-current-buffer (find-file-noselect js-file t)
(goto-char (point-min))
(forward-char 13)
(with-mock
(mock (dumb-jump-goto-file-line * 3 9))
(should (string= go-js-file (dumb-jump-go-other-window)))))))

(ert-deftest dumb-jump-go-current-window-test ()
(let ((js-file (f-join test-data-dir-proj1 "src" "js" "fake2.js"))
(go-js-file (f-join test-data-dir-proj1 "src" "js" "fake.js")))
(with-current-buffer (find-file-noselect js-file t)
(goto-char (point-min))
(forward-char 13)
(with-mock
(mock (dumb-jump-goto-file-line * 3 9))
(should (string= go-js-file (dumb-jump-go-current-window)))))))

(ert-deftest dumb-jump-quick-look-test ()
(let ((js-file (f-join test-data-dir-proj1 "src" "js" "fake2.js"))
(go-js-file (f-join test-data-dir-proj1 "src" "js" "fake.js")))
Expand Down

0 comments on commit 48ddd7b

Please sign in to comment.