the phrygian cap


luisbg

@luisbg

luis@debethencourt.com



Ohloh profile for Luis de Bethencourt
Blogalia




<Abril 2014
Lu Ma Mi Ju Vi Sa Do
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30        

Creative Commons License


planet gnome
planet ubuntu
alberto ruiz
andy wingo
jeff fortin
slomo's blog
jan schmidt
vincent's random waffle



"all religions, arts and sciences are branches of the same tree. all these aspirations are directed toward ennobling man's life, lifting it from the sphere of mere physical existence and leading the individual towards freedom." albert einstein

Using emacs with etags



I'm currently dealing with a very obfuscated and over-engineered codebase, with layers upon layers upon layers. There is always a silver linning though and I finally got around to learning how to use etags in emacs. I can't believe I waited this long to learn this feature, specially since it is so easy.

etags lets you quickly locate a definition by its name anywhere in your code base.

1. First, you need to tag the code. Go to the base directory and run

$ etags `find . -name "*.c" -o -name "*.h"`

This will generate a 'TAGS' file.

2. Let emacs know about the tag file

M-x visit-tag-table [location of the TAGS file]

3. With the cursor on a function call do the following

M-. (which is ALT-.)

This will take you to the function definition anywhere in the entire directory structure

4. Now if you want to go back

M-* (which is ALT-SHIFT-*)


Cool, isn't it? It gets better!
That's not all you can do with the TAGS file. Imagine that you are dealing with very long function names or can't quite remember the exact name. No problem. Type the first few characters of the name, then press M-tab. Either the full function name will appear, or a window will pop up displaying a list of possible completions.

If you like this checkout smart-tab. It allows you to use the tab key to indent and tab complete function/variable names.

** Alternatively, you can use 'make tags' to generate the 'TAGS' file.

3 Comentarios


Referencias (TrackBacks)

URL de trackback de esta historia http://luisbg.blogalia.com//trackbacks/71709

Comentarios

1
De: Marius Gedminas Fecha: 2012-04-26 15:07

'make tags' - is that a builtin GNU make rule, or just an assumption that most projects with a Makefile will have a rule for generating tags?



2
De: James Fecha: 2012-04-26 15:36

As with all things emacs, it's worth looking up the emacswiki.org. It's a little while, so things may have changed, but I find etags-table.el very useful for automatically finding tags tables (esp when there are relevant libraries elsewhere). Also etags-select.el is very useful for choosing between multiple matches.



3
De: Luis de Bethencourt Fecha: 2012-04-26 23:18

Marius: I think it is a GNU make rule that just makes use of knowing where all the source code is.

James: Will look at those, sound very promising



Nombre
Correo-e
URL
Dirección IP: 50.19.74.67 (fad3a11e78)
Comentario

©2007-2013 luis de bethencourt guimera
powered by Blogalia