No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Failed to load latest commit information.
screenshots Add peek to definition screenshot Dec 17, 2017
test Add :before-jump-fn argument Dec 19, 2017
.gitignore Add Cask/Makefile Nov 19, 2017
.travis.yml Add travis workaround Jan 16, 2018
Cask Add test setup and a few tests Nov 20, 2017
LICENSE Add license Nov 19, 2017
Makefile Add test setup and a few tests Nov 20, 2017 Update java example Dec 5, 2017 Update readme Dec 19, 2017
smart-jump-cc-mode.el Tweak cc Aug 4, 2018
smart-jump-clojure-mode.el Fix package lint errors Dec 17, 2017
smart-jump-csharp-mode.el Fix package lint errors Dec 17, 2017
smart-jump-eglot.el Use eglot--managed-mode-hook Aug 22, 2018
smart-jump-elisp-mode.el Register explicitly for xref (#15) Jul 28, 2018
smart-jump-elixir-mode.el Fix package lint errors Dec 17, 2017
smart-jump-elm-mode.el Add elm-mode to smart-jump default registers Dec 9, 2017
smart-jump-erlang-mode.el Fix erlang-mode dependency Dec 13, 2017
smart-jump-go-mode.el Add godef-jump to go-mode Jan 20, 2018
smart-jump-haskell-mode.el Move intero under haskell-mode Dec 21, 2017
smart-jump-js2-mode.el Set up default registers for smart-jump Dec 8, 2017
smart-jump-lisp-mode.el Register `sly` for Common Lisp. Oct 14, 2018
smart-jump-lispy.el Add lispy May 9, 2018
smart-jump-lsp-mode.el Set a default order for lsp-mode Dec 24, 2017
smart-jump-lua-mode.el Add lua-mode Jan 6, 2018
smart-jump-python.el Fix package lint errors Dec 17, 2017
smart-jump-ruby-mode.el Fix package lint errors Dec 17, 2017
smart-jump-rust-mode.el Add rust Dec 24, 2017
smart-jump-scala-mode.el Move ensime under scala-mode Dec 21, 2017
smart-jump-scheme.el Add Scheme Dec 18, 2017
smart-jump-swift-mode.el Add swift-mode Jan 6, 2018
smart-jump-typescript-mode.el Tide: Make tide-references more useable Dec 19, 2017
smart-jump-web-mode.el Tide: Make tide-references more useable Dec 19, 2017
smart-jump.el Support passing explicit hooks into smart-jump-register Aug 22, 2018

Smart Jump


This packages tries to smartly go to definition leveraging several methods to do so.

If one method fails, this package will go on to the next one, eventually falling back to dumb-jump.


Install using use-package.

(use-package smart-jump :ensure t)

Take a look at the examples below to register a smart-jump and then use it with the standard jump keys. (e.g. M-., M-, M-?).

Alternatively, clone this repo, add it to Emacs’ load-path and then require smart-jump.

There’s also some ready made smart-jumps. Just call smart-jump-setup-default-registers.

(use-package smart-jump
  :ensure t


Bare minimum example

Sets up smart-jump for js2-mode with default settings. Defaults will use the built-in xref functions first and fall back to dumb-jump if that fails.

(smart-jump-register :modes '(js2-mode))

Multiple modes

Sets up smart-jump for both emacs-lisp-mode and lisp-interaction-mode.

(smart-jump-register :modes '(emacs-lisp-mode lisp-interaction-mode)
                     :jump-fn 'elisp-slime-nav-find-elisp-thing-at-point
                     :pop-fn 'pop-tag-mark
                     :should-jump t
                     :heuristic 'error
                     :async nil)

Supporting Asynchronous Functions

Sometimes GoToDefinition is written in an asynchronous fashion which makes it tricky to fallback to the next GoToDefinition method. This package supports that case. Just set the :async parameter.

(smart-jump-register :modes 'java-mode
                     :jump-fn 'ggtags-find-tag-dwim
                     :pop-fn 'ggtags-prev-mark
                     :should-jump t
                     :heuristic 'point
                     :async t)
;; This sets a custom timeout.
(smart-jump-register :modes 'csharp-mode
                     :jump-fn 'omnisharp-go-to-definition
                     :pop-fn 'pop-tag-mark
                     :should-jump t
                     :heuristic 'point
                     :async 500)

Finding References with Fallback

(smart-jump-register :modes 'tide-mode
                     :jump-fn 'tide-jump-to-definition
                     :pop-fn 'tide-jump-back
                     :refs-fn 'tide-references
                     :should-jump t
                     :heuristic 'point
                     :async t)

A more complex example

Register different GoToDefinition functions with c-mode.

(smart-jump-register :modes '(c-mode c++-mode)
                     :jump-fn 'ggtags-find-tag-dwim
                     :pop-fn 'ggtags-prev-mark
                     :refs-fn 'ggtags-find-reference
                     :should-jump t
                     :heuristic 'point
                     :async 500
                     :order 2)

(smart-jump-register :modes '(c-mode c++-mode)
                     :jump-fn 'rtags-find-symbol-at-point
                     :pop-fn 'rtags-location-stack-back
                     :refs-fn 'rtags-find-all-references-at-point
                     :should-jump (lambda ()
                                     (fboundp 'rtags-executable-find)
                                     (rtags-executable-find "rc")
                     :heuristic 'point
                     :async 500
                     :order 1)

In this case, the fallback strategy is ->

  • For Jumping

rtags-find-symbol-at-point -> ggtags-find-tag-dwim -> dumb-jump-go

  • For Finding References

rtags-find-all-references-at-point -> ggtags-find-reference -> smart-jump-simple-find-references

The :order keyword in this case designates the sort order of the jumps.

Take a look at this for more examples.


Peek to Definition ./screenshots/peek.png

Help Wanted :)

Look into issue tracker! Add tests! Add more default smart-jump registers.

Running Tests

make test
make lint
make compile