7 ms·
Dumb-jump: an Emacs “jump to definition” package
- iKlsR 10y agoStill learning VIM user here, do we have something like this?
- bch 10y agoOn first blush, this looks like ctags[0] (or etags[1]). In nvi, I go to a function or structure I want to see the definition of and (/me loads nvi to see what I actually do...) ^] (ctrl-bracket) to jump to a definition, and ^T (ctrl-t) to pop that ctag jump off the stack that it maintains. Because it's stack oriented, that means that you can jump through to definitions until you're satisfied, and pop back the same route you took getting to your ultimate destination. [0] https://en.wikipedia.org/wiki/Ctags https://en.wikipedia.org/wiki/Ctags [1] http://ctags.sourceforge.net/ http://ctags.sourceforge.net/
- c3534l 10y agoI have this in my vimrc under vundle: Plugin 'majutsushi/tagbar' Plugin 'xolox/vim-easytags' Plugin 'xolox/vim-misc' Later on I have: nnoremap <silent> <Leader>b :TagbarToggle<CR> I may have also separately installed ctags, but I don't remember. Now you can have an outline of the file you're working on in a small pane to the right. You can use this to navigate or see what arguments a function needs (or what attributes a class has). Whenever you save, ctags are automatically generated so you never have to worry about setting that up. ctrl+] will bring directly to the definition, including if it is in another file entirely. Use ctrl+T to go back to where you came. More often than not, I use this not because I forgot what the code says, but because I made an alteration to how I wanted a function or class to behave and I need to go back and change a line or two.
- GregBuchholz 10y agoAre you aware of '*' and '#', and 'gd'? http://vim.wikia.com/wiki/Go_to_definition_using_g http://vim.wikia.com/wiki/Go_to_definition_using_g
- sillysaurus3 10y agoIt never seems to work for me. If I put the cursor over a word and type gd, it seems to go to the first line that the word is mentioned, not necessarily the definition. It's handy, for sure, but not too reliable. I think it can be improved with some plugins though.
- egjerlow 10y agoThese only work if your definition is in the same file, though.
- Spiritus 10y agoNot exactly similar but https://github.com/ludovicchabant/vim-gutentags https://github.com/ludovicchabant/vim-gutentags is pretty great.
- mrinterweb 10y agoVim can do ctags out of the box. If I remember right, the command is C-] (ctrl+ close bracket) to jump to a ctags definition. For rails projects I wrote a script that kicks off ctags with the following options. "ctags --tag-relative -Rf.git/tags.$$ --exclude=.git --exclude=log --exclude=tmp --exclude=public --languages=ruby --languages=javascript `bundle show --paths` $MY_RUBY_HOME ." I'd wager there is a better way. That's just the way I roll.
- qwertyuiop924 10y agoIt's essentially similar to gd, but in theory project-wide and with a better algorithm.
- soamv 10y agoNice! Just tried it out and it seems to work well. Why does dumb-jump-go want me to save my files before jumping?
- NoGravitas 10y agoI assume because it uses an external tool that looks at your files, not the state of your emacs buffers, to find references.
- deleted 10y ago[deleted]
- mordocai 10y agoNice package! Unfortunately is completely falling on its face for my ruby on rails project, but I'm sure it can be improved.
- mck- 10y agoAgreed. Was so hopeful that it would "just work". Still hopeful that it will improve, because the README just sounds sooo good.
- jacktasia 10y agoSorry to hear it didn't work for you. Would you consider opening an issue on github outlining what you were trying to do? Then you can be more than just hopeful that it will improve.
- jacktasia 10y agoSorry to hear it didn't work for you. Would you consider opening an issue on github outlining what you were trying to do?
- webaholic 10y agoWhat do people use to get something like this for C/C++? Also is there any package for auto-completion in C/C++?
- nodivbyzero 10y agohttp://tuhdo.github.io/c-ide.html http://tuhdo.github.io/c-ide.html
- webaholic 10y agoThanks! This worked the best out of all...
- sase 10y agoRelies on cmake integration but worth a look: https://github.com/atilaneves/cmake-ide https://github.com/atilaneves/cmake-ide
- sillysaurus3 10y agoEmacsTags + CompanyMode and you should be good to go. You'll need to install the correct tags package for your system, but it's only about 10 minutes of minor annoyance. Whenever the point is over a word in a C++ codebase, e.g. FooSystem, it will be underlined, and you can click on it and jump to definition, show all references, etc. Then if you type Foo, CompanyMode should pop up a dialog box that will autocomplete FooManager. I think you can also install a fuzzy matching package for CompanyMode which allows you to type e.g. "FSy" to complete "FooSystem", though I may be confusing Helm and CompanyMode. You may also want to check out the Projectile package. It's for large project navigation, and I think it helps with automatically running ETags / GTags on an as-needed basis.
- jcagalawan 10y agoRTags works pretty well and always jump to the right definition for me. You pass it to a compilation database json file that you can make using CMake. It runs in the background as a daemon and provides robust go-to-definition as well as autocomplete for both C and C++. https://github.com/Andersbakken/rtags https://github.com/Andersbakken/rtags
- drewg123 10y agoI must be missing something, but what is the advantage of this over something like Emacs Tags (https://www.emacswiki.org/emacs/EmacsTags https://www.emacswiki.org/emacs/EmacsTags) ?
- deleted 10y ago[deleted]
- vic8722 10y agoBuilding a tags file is not trivial.For example if you cloned a random repository on github you'd want to just jump around and not have to have the additional step of generating it and keeping it up to date.
- parent5446 10y agoCan't it just be done automatically and on-the-fly using ctags or another appropriate command?
- vic8722 10y agoPerhaps, but I've never seen a straightforward guide to doing that. Particuarly that was generic enough that would automatically work with new projects, but I'd be thrilled to be proven wrong.
- pmontra 10y agoMaybe this changed in the last few years but the problem with TAGS files was that you have to rebuild it at every change you make. I had a cron that rebuilt the ones of the projects I was working on, but it's not efficient and not up to date. Maybe a process that monitors changes to files is a better approach. Still, rebuilding the TAGS file is useless if ag is fast enough. SSDs and lots of RAM to cache files help. The only problem with ag is that it can't find definitions until you save the buffer to a file. Not that ctags does any better. Some tool running inside emacs could do that too but it's not so important.
- 10y ago
- kozikow 10y agoI was planning to write this as a comment here, but it ended up growing so I published it on my blog post: https://kozikow.wordpress.com/2016/05/21/nice-new-emacs-package-dumb-jump-el/ https://kozikow.wordpress.com/2016/05/21/nice-new-emacs-pack... . BTW, did you know that you can just do README.org and github parses it? I noticed that you have org file checked in, but README is in md. For example see https://github.com/kozikow/keyremaplinux https://github.com/kozikow/keyremaplinux .
- jacktasia 10y agoWow, thanks for writing that blog post! You highlight pretty much all the reasons why I made dumb-jump. Please don't hesitate to make issues on github if/when you run into issues/ideas.
- t1amat 10y agoThis is neat, and useful as a general purpose jump-to feature. It's probably worth mentioning that some languages have packages with better functionality for that language, such as tern-mode for JavaScript.
- dilap 10y agothis looks neat. i notice one of the supported languages is go -- if you're doing much go, i recommend installing godef and using go-mode.el. no tags files or anything like that, and works perfectly well for jumping to definition. (i also highly recommend gorename and guru.)
- qwertyuiop924 10y agoAh yes, yet another proof that the Wrong Thing™ isn't necessarily the wrong thing. Sure it's objectively worse than [ce]tags, but haven't you heard? Worse is Better. :-D
- justinmk 10y agoI am not sure "proof" is the appropriate word. > Dumb Jump uses The Silver Searcher ag (and falls back to grep) ... [and] a set of regular expressions If you're going to install ag, you might as well install universal-ctags[1], a revival of ctags with many improved and new parsers. It allowed me to discard my C and javascript ctags config entirely. Combined with gutentags[2] you have a "just works" and "Less Dumb" setup. [1] https://github.com/universal-ctags/ctags https://github.com/universal-ctags/ctags [2] https://github.com/ludovicchabant/vim-gutentags https://github.com/ludovicchabant/vim-gutentags
- gpderetta 10y agoThe advantage of ag is that it is dumb brute (very brute) force. You do not need an up to date index as it will search whatever is on disk. I have rtags set up, but it periodically stops working (too many parsing errors, indexer crashes, etc) or it is just slow, then I fall back to ag. It can search a ~1M lines C++ codebase in seconds (and you can start browsing the results while the search is in progress of course). Of couse it also works if you do not have a project setup, or you just switched to a wildly diverged git branch. I'm definitely going to try this dumb-jump.
- Myrmornis 10y agoThis is cool, I've also been writing a similar emacs package: it uses `git grep` and `git ls-files` to quickly find patterns and file names in the current git repo, and has a simple interface for filtering the search results to narrow down to what you were looking for (and also uses a regexp heuristic for jumping to definitions). https://github.com/dandavison/emacs-search-files https://github.com/dandavison/emacs-search-files
- sdegutis 10y agoI really love how well this works with Cider though, for Clojure projects. It even lets you jump to the definition of Java or Clojure files that live outside your current project, e.g. in third party libraries or even the Java standard library. Why, just today I jumped to the definition of java.time.Month because I had never actually seen a real live Java enum before. (Sure enough, it's defined with the keyword `enum`. Neat!) Cider has become essential to my Clojure workflow at work.
- jekdoce 10y agoFor C/C++ RTags (https://github.com/Andersbakken/rtags https://github.com/Andersbakken/rtags) together with company-mode and fly-check can do jump-to-definition, auto-completion and on-the-fly-syntax-checking. Super easy to use if using cmake as build system. Respond to this comment if you need pointers on how to set things up.
- fizixer 10y agoAny equivalent options for make?
- LazyGrizzly 10y agoFor make you could use bear (https://github.com/rizsotto/Bear https://github.com/rizsotto/Bear). It allows you to generate a compilation database that is equivalent to that of cmake projects.
- peatfreak 10y agoWhy is so much Emacs stuff hosted on GitHub these days? It seems antithetical to the spirit of the project as a whole.
- AceJohnny2 10y agoWhat spirit of the project are you thinking of, and how is hosting stuff on Github antithetical to it?
- anon1385 10y ago>What spirit of the project are you thinking of Free Software: http://www.gnu.org/philosophy/free-sw.html http://www.gnu.org/philosophy/free-sw.html >how is hosting stuff on Github antithetical to it? Github is s a proprietary cloud service: http://www.gnu.org/philosophy/who-does-that-server-really-serve.en.html http://www.gnu.org/philosophy/who-does-that-server-really-se...
- peatfreak 10y agoThanks for providing these links.
- imtringued 10y agoAs opposed to what? Buying a domain and hosting your own server? To answer your question: Some small programs would probably not exist at all without a service like github.
- peatfreak 10y agoIt's not necessary to buy a domain and host one's own server. For example, there is https://savannah.gnu.org/ https://savannah.gnu.org/ , which is where Emacs itself is hosted.