Category Archives: Emacs

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.

Emacs – lldb with gud-lldb.el

since gdb is disabled in latest version of mac,
it is not that easy to enable gdb.
although there is way to enable gdb, once mac os is updated, we have to search new ways again.

it seems like we have to use lldb.
there is a few ways to use lldb with UI,
such as eclipse for c/c++ with lldb plugin.

but for emacs, it has a plugin with lldb


spacemacs – working with previous emacs config

1. fork from branch to you own github account

the reason why we should fork is to commit code changes for spacemacs in future.

move ~/.emacs to ~/.emacs1 as backup file

2. open ~/.emacs.d/init.el, at the end of buffer, add code to load .emacs file

in my computer, I put all .emacs configure into another file named .emacs_mac

;; move these code into the end of init.el
(if (>= emacs-major-version 25)
(load-file \”~/emacs/.emacs_mac_25\”)
(load-file \”~/emacs/.emacs_mac\”))

3. “M-x toggle-debug-on-error” is helpful command when error occurs. since spacemacs may connect to network and some server are not ready.

4. disable ‘M-x’ ‘C-x C-f’ because windows size changes too often.

in following picture you could see three windows, especially last one, when M-x key is press, it will become very large, later on it will be one line only.

here are steps for disabling them.
<1>open ~/.emacs.d/layers/+completion/helm/packages.el
<2>in function “helm/init-helm” search ‘global-set-key’ statement and comment out.

<3>after comment out everything , add following code into ~/.emacs.d/init.el

(ido-mode 0)
(helm-mode 0)

spacemacs – install spacemacs

install spacemacs is very simple.
make sure using emacs version >= 24.5

but the keypoint is to remove “.emacs” file.
it will force emacs to load config from “.emacs.d” folder.

in windows, %HOME% must be set to a path for .emacs.d

$ git clone ~/.emacs.d

> cd %HOME%
> git clone .emacs.d


on mac os, sometime lock file is very annoying.

every time you edit it, emacs will ask you to choose s,p,q,?,

check more details.

Here is code to make it work.
;; for mac os x
(setq auto-save-default nil)
(setq create-lockfiles nil)

Emacs – EShell mode to dired mode

M-x shell and M-x eshell are two major mode we use daily.

however, in the shell mode, it is not easy to switch to dired mode.

but in M-x eshell mode, command “dired .” will open dired mode for current path


xcode 6.1 iphone simulator screen solution

At the beginning, iphone solution is too big to suite small screen.

so I can not see all button and image.

the way to get around it, run simulator. from menu on the top of monitor choose “Windows” -> “Scale” -> 50%

or Use ShortCut, CMD+1, CMD+2,CMD+3

although now simulator screen looks much smaller but at lease I could see all button and image for UI

emacs completion – xrefactory

By default, Emacs just provide some simple auto complete. For example, Alt + /, it will invoke ‘dabbrev-expand’.
and ‘dabbrev-expand’ is to find and complete what you enter once it find match words in all ‘buffer’ opened.

xrefactory is excellent commerce plugin for emacs, xrefactory is free for C/Java.

Here is how to enable xrefactory in emacs.


uncompress the tgz file,tar zxvf xrefactory-1.6.10-src.tgz

go into folder ‘xref-any’ , type command ‘make’, it will compile and finish to get ‘xref’

In .emacs file, add following code (replace ‘path/to’ to the path you want)

(add-to-list ‘load-path “/path/to/xref-any/env/emacs”)
(add-to-list ‘exec-path “/path/to/xref-any/src”)
(load “xrefactory”)
;;(load “/path/to/env/emacs/xrefactory.el”)

run ‘M-x eval-current-buffer’ , Now you could use xrefactory , Press ‘F8’ key to call ‘xref-completion’

xref is very powerfull, but we still has some other tools such as ‘gccsense, gtags’, I will add these two later on.