Emacs – Use Etags to investigate Linux Kernel source code

Build TAGS file

Navigate Linux kernel source code folder to generate TAGS file.

find . -name “*.[chCH]” -print | etags –

Set Default TAGS file

Tags-table-list contains list of directories that contain TAGS file, All of Dir should contain TAGS file. Otherwise, search will stop at directory without TAGS file and print error message.

(setq tags-table-list '("~/.emacs.d" "/path/to/linux/kernel/src"))

Find Tag and Jump back

M-x find-tag         — jump to define

M-x xref-pop-mark-stack    — pop mark stack to jump back.

Linux Kernel may have different definition for one variable because of multiple Hardware architecture, we could jump all definition for one variable to find out right hardware architecture to view.