Emacs.d - ShadowThink

Table of Contents


This Emacs configuration is forked from Steve Purcell. Currently, emacs.d is maintained by Bill Xue, becoming more friendly for previous Vim users.

Emacs itself comes with support for many programming languages. This config adds improved defaults and extended support for the following:

In particular, there’s a nice config for tab autocompletion, and flycheck is used to immediately highlight syntax errors in Ruby, HAML, Python, Javascript, PHP and a number of other languages.


To support all features of numbers of key packages, Emacs 24 and above is required. Other programs are also required by third part packages. Please set up the required package before installation.


To install, clone this repo to ~/.emacs.d, i.e. ensure that the init.el contained in this repo ends up at ~/.emacs.d/init.el:

git clone https://github.com/xueeinstein/emacs.d.git ~/.emacs.d

Upon starting up Emacs for the first time, further third-party packages will be automatically downloaded and installed. If you encounter any errors at that stage, try restarting Emacs, and possibly running M-x package-refresh-contents before doing so.


Emacs basics

Quick file access

Academic writing

Enable reftex-mode at first!

Some handy shortcuts for LaTex editing:

Citation: set bib file at first (open your bib file and do M-x set-as-default-bib), then cite paper use M-x reftex-citation.

Spell checking: install aspell-en dictionary, then do M-x ispell-buffer.

Table of content: do M-x reftex-toc.

Evil group basics

Evil is an extensible vi layer for Emacs. In this configuration, to make it more like my Vim configuration, I setup supplementary package like evil-leader, evil-nerd-commenter, hideshow, neotree, fic-mode and avy. Here, I call them Evil group.

Cursor movement

Inherit basic Vim cursor movement rules. For easy cursor motion, I configure Emacs with avy to support the cursor motion like vim-easymotion.

Code folding

Coding folding is another important feature of Vim. Similarly as my Vim configuration, I use zf to fold code, and zo to unfold code with the help of hideshow. Moreover, hideshow has more powerful code folding functions like hiding or showing all blocks. Summary:

Window splitting and switching

Originally, in Emacs, we split window vertically by typing C-x 3, and split window horizontally by typing C-x 2. After window spliting, Emacs will automatically guide you to the new window which is initialized with a new available buffer. However, sometimes, you want to spliting window and replicate the original buffer such that you can scroll and enlarge the veiw of the current buffer. Here, <leader> h and <leader> v can satisfy your requirements.

Code comment and uncomment


Git tools

In this Emacs config, it has several git tools like magit and vc. It’s recommended to use C-x g to trigger M-x magit-status. Next type h for help. Then you can follow the instruction to do kinds of git operations.

When you write code, diff-hl model works to track modifications. Some useful shortcuts are:

Find files

This function is powered by find-file-in-project. For a given project with version control like git, find-file-in-project will automatically set rot git root directory as the project root directory. Then you can use C-c C-f to trigger M-x ffip and quickly find project files.

Search in files

To search string in files under current folder, you can use helm with ack-grep. Use C-x-f and navigate to your expected directory, within the helm-find-files session, invoke ack-grep with C-s to search a file/directory on highlighted entry in the Helm buffer.

Elpy Basics

Interactive Python


C-c C-d, M-x elpy-doc When point is on a symbol, Elpy will try and find the documentation for that object, and display that. If it can’t find the documentation for whatever reason, it will try and look up the symbol at point in pydoc. If it’s not there, either, it will prompt the user for a string to look up in pydoc.



ESS Basics

Interactive R


Use C-c C-v to pop up a help buffer for an R object or function.


It’s recommended to use C-c C-t ? to see the help information for ESS tracebug. A short tutorial is at https://code.google.com/archive/p/ess-tracebug/wikis/GettingStarted.wiki.

Org Mode

Take Notes

Org files can be converted to pdf or html files easily. With Latex supports, it’s an ideal tool to take notes especially for scientific notes. To enable Latex supports, you need to add following header to your org file.

#+TITLE: Your Title
#+AUTHOR: Your Name
#+EMAIL: [email protected]
#+LaTeX_CLASS: article
#+LaTeX_HEADER: \usepackage[ttscale=.875]{libertine}
#+LaTeX_HEADER: \usepackage{sectsty}
#+LaTeX_HEADER: \sectionfont{\normalfont\scshape}
#+LaTeX_HEADER: \subsectionfont{\normalfont\itshape}
#+OPTIONS: H:2 num:nil toc:nil \n:nil @:t ::t |:t ^:{} _:{} *:t TeX:t LaTeX:t
#+STARTUP: latexpreview

To trigger Org file export dispatcher, use C-c C-e.

To navigate between headings in Org file, use C-c C-j.

To insert tags, move the cursor in a headline that you want to tag, then use C-c C-c.

One handy functionality in org mode is to link other files, and then you can jump to them easily with C-c C-o.

Other useful links:


Organize your life with org mode agenda.

Connect your org agenda with Google Tasks

First, use C-c a G to get TODO list, ten use C-c a e to export as ~/org/gtask.org. Finally, you can use the tool michel-orgmode to push the gtask.org to your Google Tasks as a separate list.

michel-orgmode --push --orgfile ~/org/gtask.org --listname "From Emacs Org"

Time and record your work.

Review your work.

In agenda view


Org-babel is about letting many different languages working together in org mode blocks.

Other Material