Emacs Configuration

Introduction

Emacs is an extensible, customizable, free/libre text editor. 1 For more information, check Gnu Emacs.

For Emacs beginners, it's hard to have a suitable Emacs configuration. There are some good popular kits which are helpful for people to use, such as emacs24-starter-kit, emacs prelude and Steven Purcell's emacs.d. This is the note of my configuration and it should be updated frequently.

Why Emacs

Why do I want to use Emacs? Because it's fast and efficient. There are tons of pages introducing how useful Emacs can be. In terms of my use of Emacs, it can give you a relatively integral experiences dealing with most of tasks you are facing efficiently.

Emacs Configuration

My Emacs Configuration is based on Steven Purcell's emacs.d 2 project whose framework is clean and clear. Purcell is a web developer so most of his configurations are for web development. I am a robotics guy and I am more interested in different topics. I work on programming a lot with C/C++, Python and MATLAB and also write papers using LaTeX. GitHub and SVN are extremely useful for my development. Plus, email is necessary for everyone. This Emacs configuration is helpful for these things plus some other useful tools which are capable of making your workflow more efficient.

There are three different installation modes: full, text and programming. The default installation mode is full. When selecting text, corresponding configurations and packages about Python, C/C++, MATLAB, ROS, HTML and XML won't be loaded. When selecting programming, corresponding configurations and packages about Markdown, TeX, Email and Blog won't be loaded. Make an option before starting.

Programming

C/C++

  • K&R indent style for C/C++ programming;
  • Three key-bindings for embedded programming with microcontroller:
    1. C-x C m: make;
    2. C-x C f: make flash;
    3. C-x C c: make clean.
  • company-c-headers is configured to enable the completion of C/C++ header file names using Company mode for Emacs and .emacs.d/cc-mode-header-custom.el can be used to customize the include paths.
  • CEDET Configuration
    1. Semantic is configured for C/C++ programming. See Semantic in CEDET, for details.
    2. EDE mode is enabled for C/C++ project and project local variables can be stored in .emacs.d/cc-mode-projects.el.
  • cmake-mode, as well as company-cmake, are configured for editing CMake source files.

Python

  • Jedi is configured for Python programming and .emacs.d/jedi-custom.el can be used to customize Jedi, like adding some special sys.path when starting Jedi server. See Documentation of Jedi, for details;
  • IPython is used as Python shell interpreter. See IPython for details;
  • autopep8 is required for automatically formatting Python code to conform to the PEP 8 style guide. See autopep8 package for details.

MATLAB

matlab mode package is configured for editing .m-files and launching MATLAB shell.

ROS (Robot Operating System)

  • rosemacs is configured for ROS users;
  • yaml-mode, nxml-mode and cmake-mode are configured for editing YAML files, XML files and CMakeLists.txt respectively.

Writing

Org mode

Org mode is for keeping notes, maintaining TODO lists, planning projects, and authoring documents with a fast and effective plain-text system. 3 Most of my Org mode configurations are from Purcell. Furthermore, I added these following settings:

  • MobileOrg is configured to synchronize the contents on a mobile platform with those stored in Dropbox on a computer. Directories can be customized by setting some variables in init-org.el;
  • org-bullets is used for Org mode in Emacs to show org-mode bullets as UTF-8 characters;
  • Size of heading fonts is customized for better view;

TeX

  • AUCTeX is configured for writing and formatting TeX files in Emacs. See homepage of AUCTeX for details.
    • XeLaTeX is configured to be the default TeX engine. After compiling the source files, a synctex.gz file will be generated for forward and inverse search;
    • Skim is required for Mac users, Okular is required for Ubuntu users and Sumatra PDF is required for Windows users to view generated PDF files.
  • company-math is configured for math unicode symbols and latex tags completion. See README in company-math for details;

Markdown

markdown-mode is configured to support Markdown in Emacs. See README in markdown-mode, for details.

Notes Management

Deft is configured to manage my notes in Emacs. See README in Deft for details.

  • Notes directory can be customized by setting deft-directory in init-deft.el;
  • C-x N: launch Deft;
  • C-c n: use Deft to find notes.

Blog

blog-admin is configured to write blogs in Emacs with Hexo framework. See README in blog-admin for details.

Version Control

Git

  • git-blamed, git-messenger and git-timemachine are useful tools for using Git in Emacs;
  • Magit is a very power interface to Git in Emacs. See Magit homepage for details;
  • gist, github-browse-file, github-clone and some other packages are installed for GitHub in Emacs;
  • C-x v p: use git-messenger to pop up messages;
  • C-x g: invoke Magit.

SVN

Emacs has built-in version control interface which is pretty nice for SVN. psvn is also installed for using SVN in Emacs. git-svn is recommended for SVN users (see git-svn, for more details).

  • C-x v d: vc-directory – show all files which are not up to date.

Email

Gnus is configured to be an email client in Emacs. Most of my configurations are from Chen Bin. See this article for details. In addition, I configured BBDB for its new version with company mode for address completion.

Tools

  • company-mode is configured for completion. See homepage of company-mode for details;
  • dired+ and dired-sort are configured to enhance Emacs directory editor;
  • iedit is configured to edit multiple regions simultaneously in a buffer or a region. Use C-c ; to invoke iedit-mode;
  • fill-column-indicator is configured to graphically indicates the fill column;
  • Flycheck is configured to do syntax checking for Emacs. See homepage of Flycheck for details;
  • Flyspell is configured to do spell checking in Emacs. See homepage of Flyspell for details. Use M-c to correct spelling of the word at a point or a region;
  • Default font settings can be found in init-fonts.el. The sizes of fonts for different operating systems are set differently to ensure the table with Chinese characters in Org mode can be aligned well;
  • Use C-x C-b to invoke ibuffer;
  • Ivy, Counsel and Swiper are configured. See README in swiper, for details;
  • BBDB is used to manage address book for email and gmail2bbdb is installed to import name and email from Gmail contacts into BBDB file;
  • MultiTerm is configured to be the interface to the terminal. See Multi Term on Emacs Wiki, for details. Use C-x M to invoke multi-term;
  • Projectile is configured to manage projects in Emacs. See README in Projectile, for details. Hit C-c p and wait for a little bit, user can get a menu of Projectile.
  • Smex is configured to enhance M-x for Emacs;
  • Tramp mode is configured for ssh;
  • whitespace-cleanup-mode is installed and whitespace is showed by default;
  • YASnippet is configured to be a template system for Emacs. Use C-c k to expand using YASnippet.
Last Updated 2017-08-27 Sun 13:40.
Render by hexo-renderer-org with Emacs 25.2.1 (Org mode 8.2.10)