Emacs C source Navigation
Created at 2016-08-11T03:35:32.000Z

[Update]: Later on, I found cscope, which is easier to use out-of-box with xcscope.el on Emacs.

  • Minimal navigation
    • C-c s d: cscope-find-global-definition
    • C-c s u: cscope-pop-mark
    • C-c s c: cscope-find-functions-calling-this-function
    • C-c s t: cscope-find-this-text-string


Recently, I started to read some of C projects from the Internet, such as, Linux, glibc, musl, Qemu. Just a quick summery to note to myself.

  • Generate TAGS file
$ find . -type f -iname "*.[chS]" | xargs etags --append
  • Minimal navigation
    • M-.: find-tag
    • C-u M-.: go to next match of find-tag
    • M-*: pop back to the point before find-tag
    • visit-tags-table: add new TAGS file to tags-file-name and tags-table-list
    • select-tags-table: choose and set to tags-file-name from tags-table-list

Notes

  • I tried etags-select-find-tag from etags-select, but it didn't work some cases (e.g. net_device does only shows net_device_stats).
  • I tried helm-etags-select from helm-mode, but completion search is too slow for navigating linux kernel source. So, I disabled it as below:
(require 'helm-config)
(helm-mode)
(setcdr (assoc 'find-tag helm-completing-read-handlers-alist) nil) 
;;  see https://github.com/emacs-helm/helm/wiki#customize-helm-mode

References