Dumb Jump is an Emacs "jump to definition" package with support for 40+ programming languages that favors "just working". This means minimal -- and ideally zero -- configuration with absolutely no stored indexes (TAGS) or persistent background processes. Dumb Jump requires at least GNU Emacs
How it works
Dumb Jump uses The Silver Searcher
grep to find potential definitions of a function or variable under point. It uses a set of regular expressions based on the file extension, or
major-mode, of the current buffer. The matches are run through a shared set of heuristic methods to find the best candidate to jump to. If it can't decide it will present the user with a list in a pop-menu, helm, or ivy (see
For the currently supported languages it seems to do a good job of finding what you want. If you find a case where it does not work as expected do not hesitate to open an issue. It can be slow if it needs to use
grep and/or a project is large. Although it can be sped up by installing
ag or installing
rg and/or creating a
.dumbjump file in your project's root directory with paths that should be excluded (see configuration).
There is currently basic support for the following languages:
- Common Lisp
- Emacs Lisp
- Protocol Buffers
If you have any issues with the existing languages, or you want support for another one, then please open an issue. PRs are also welcome. If you'd like to add a language these PRs for lua and rust are good examples.
The recommended way to install Dumb Jump is via
package.el. It's available on MELPA: M-x
If you're using an up-to-date Spacemacs, then you already have Dumb Jump by default just make sure you install
rg (see below) to ensure you have the best experience.
To enable the xref backend, evaluate
(add-hook 'xref-backend-functions #'dumb-jump-xref-activate)
or add it to your initialisation file. Using this, you can now use M-. (or gd when using Evil).
Excluding project directories
Dumb Jump will automatically look for a project root. If it's not finding one then either put a
.dumbjump file in your project root and optionally add excluded directories to make it faster.
Project root directory denoters:
If you want to stop a directory from registering as the project root (and have Dumb Jump keep looking) add an empty
.dumbjumpignore file in that directory.
-tests -node_modules -build -images +../some-lib/src +/usr/lib/src
NOTE When adding paths outside of the project (using
+) ensure you use
dumb-jump-force-searcher of either
'rg (see below). This is required because the default searcher (
git-grep) won't be able to search outside of the project root. This edge case will be fixed in a future release. That is,
git-grep will NOT be set as the default searcher if a
.dumbjump is present with a
+ path outside of the repo.
(setq dumb-jump-default-project "~/code")to change default project if one is not found (defaults to
(setq dumb-jump-quiet t)if Dumb Jump is too chatty.
- To support more languages and/or definition types customize
(setq dumb-jump-force-searcher 'rg)to force the search program Dumb Jump should use. It will always use this searcher. If not set (
nil) Dumb Jump will use
git-grepif it's a git project and if not will try searchers in the following order
grep(first installed wins). This is necessary if you want full control over the searcher Dumb Jump uses.
(setq dumb-jump-prefer-searcher 'rg)to let Dumb Jump know your searcher preference. If set this will still use
git-grepif it's a git project (because it's the fastest), but will you use whatever you set here in any other situation. If not set Dumb Jump will follow the same order as mentioned in the
dumb-jump-force-searcherdescription. At this time setting this value is only necessary if you prefer
(setq dumb-jump-git-grep-search-args "")to set additional command line arguments when using git-grep for searching (defaults to
(setq dumb-jump-ag-search-args "")to set additional command line arguments when using ag for searching (defaults to
(setq dumb-jump-rg-search-args "")to set additional command line arguments when using rg for searching (defaults to
Hydra for effieciency
If you have Hydra installed, the following is an example hydra for easily using Dumb-Jump and not needing to remember the bindings or function names:
(defhydra dumb-jump-hydra (:color blue :columns 3) "Dumb Jump" ("j" dumb-jump-go "Go") ("o" dumb-jump-go-other-window "Other window") ("e" dumb-jump-go-prefer-external "Go external") ("x" dumb-jump-go-prefer-external-other-window "Go external other window") ("i" dumb-jump-go-prompt "Prompt") ("l" dumb-jump-quick-look "Quick look") ("b" dumb-jump-back "Back"))
Debugging a jump
set-variable dumb-jump-debug t
- try to jump
- go to buffer
More details here. Thanks to @cweiske and @Glumanda99
Obsolete commands and options
Older versions of dumb jump didn't use xref, and instead had custom commands. These, while marked obsolete, can still be used:
dumb-jump-go(former) core functionality. Attempts to jump to the definition for the thing under point. This has been replaced in the new interface with
dumb-jump-backjumps back to where you were when you jumped. These are chained so if you go down a rabbit hole you can get back out or where you want to be. This has been replaced with
xref-pop-marker-stack(M-,), but is mostly equivalent.
dumb-jump-gobut only shows tooltip with
contextit does not jump.
dumb-jump-gobut will prefer definitions not in the current buffer
dumb-jump-go-prefer-external-other-windowexpected combination of
dumb-jump-gobut prompts user for function to jump to
A few user options only have an effect when used with the legacy interface. These are:
The minor mode
dumb-jump-mode binds a few of these commands by
If you still use Emacs 24 or older, you won't have xref, and have to use the legacy interface instead. In that case, there will also be no "obsolete" warnings.
I wanted "jump to definition" functionality to "just work" in emacs. I use IntelliJ for Java and this functionality is basically the only thing I miss when I switch back to emacs for work in other languages. There are certainly other packages that offer this type of functionality, but they all require significantly more configuration and are often limited to a particular language. An alternative may be worth setting up if you are in a specific project or language often (see alternatives).
Feedback is very welcome via GitHub issues. I will consider supporting other languages either via issue request or PR. If submitting a PR then please add tests as well.
Opening a PR will use CircleCI to run all the tests against all the supported emacs versions and search programs.
Running tests locally
There are a lot of options for running the tests locally:
requires Cask using your local emacs
cd /path/to/dumb-jump cask make test
requires golang and Cask using your local emacs
cd /path/to/dumb-jump cask make test-concurrent
Docker (latest emacs)
only requires docker and runs tests against emacs 26.1
cd /path/to/dumb-jump cask make test-in-docker
Docker (all supported emacs versions)
only requires docker and runs tests against all supported emacs versions
cd /path/to/dumb-jump cask make test-all-in-docker
Here is a list of potential alternative packages for emacs:
- Tags supports multiple languages
- GNU Global supports multiple languages
- elpy for Python
- robe for Ruby
Most of these were sourced from this emacs StackExchange answer.