Journal Articles

CVu Journal Vol 32, #4 - September 2020 + Programming Topics
Browse in : All > Journals > CVu > 324 (9)
All > Topics > Programming (877)
Any of these categories - All of these categories

Note: when you create a new publication type, the articles module will automatically use the templates user-display-[publicationtype].xt and user-summary-[publicationtype].xt. If those templates do not exist when you try to preview or display a new article, you'll get this warning :-) Please place your own templates in themes/yourtheme/modules/articles . The templates will get the extension .xt there.

Title: Jumping around in Emacs

Author: Bob Schmidt

Date: 05 September 2020 18:20:56 +01:00 or Sat, 05 September 2020 18:20:56 +01:00

Summary: Silas S. Brown shares a tip for navigating code.

Body: 

When working with code I didn’t write, I frequently find myself asking “can I check that function really does what its name suggests”, i.e. I need to find the definition of a function (or class etc) that’s mentioned, which might be in another file or directory. My habitual way of handling this has been to run the Unix grep tool from inside Emacs, look at (and, if necessary, search in) these search results, and figure it out. This is a habit that perhaps has some scope for optimisation.

The traditional solution for both Emacs and Vim involves Ctags, but this can be a hassle to set up for each project, especially when multiple programming languages are involved. So I recently started using an Emacs package called dumb-jump which is meant to take you there ‘most of the time’ with little setup. Dumb Jump can use normal grep, or (if installed) optimised versions of grep, such as git-grep which knows to check only tracked files in Git projects, or ‘The Silver Searcher’ maintained by Geoff Greer which has Boyer-Moore string search, mmap() etc and also tries to avoid binaries, editor-created backups etc. Dumb Jump’s setup instructions are in its README [1] and then usage is normally a matter of holding down the Alt key while pressing dot (.) when the cursor is on the name of the thing whose definition you want to see, and then Alt-comma (,) to go back. It helps that dot and comma are next to each other on both the QWERTY and Dvorak keyboard layouts (if using Dvorak, you might have a right-hand Alt Gr key you can use to make the combination easier).

I understand that JetBrains’ products have similar functionality built in, although I haven’t tried it as I’ve been using Emacs since last century (when it was jokingly called Eight Megabytes And Constantly Swapping: it’s hard to believe it’s now considered lightweight compared with modern IDEs, while all the while I was wondering if I need Vim skills to further reduce my memory requirements).

Reference

[1] Dumb Jump: https://github.com/jacktasia/dumb-jump

Silas S. Brown Silas is a partially-sighted Computer Science post-doc in Cambridge who currently works in part-time assistant tuition and part-time for Oracle. He has been an ACCU member since 1994.

Notes: 

More fields may be available via dynamicdata ..