Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
purcell's emacs configuration plus C/C++ support
Emacs Lisp Common Lisp Scheme Perl Ruby Shell Other
branch: master

This branch is 2 commits ahead, 559 commits behind redguardtoo:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
defuns
site-lisp
snippets
.gitignore
README.org
cl-lib.el
init-ace-jump-mode.el
init-artbollocks-mode.el
init-auctex.el
init-bbdb.el
init-cc-mode.el
init-cmake-mode.el
init-company.el
init-compat.el
init-cperl-mode.el
init-crontab.el
init-csharp-mode.el
init-css.el
init-csv.el
init-ctags.el
init-dired.el
init-doxygen.el
init-eim.el
init-elisp.el
init-elnode.el
init-elpa.el
init-emacs-w3m.el
init-emacspeak.el
init-erlang.el
init-evil.el
init-exec-path.el
init-flymake.el
init-fonts.el
init-frame-hooks.el
init-git.el
init-gnus.el
init-gtags.el
init-gud.el
init-gui-frames.el
init-haml.el
init-haskell.el
init-helm.el
init-hippie-expand.el
init-ibuffer.el
init-ido.el
init-isearch.el
init-javascript.el
init-keyfreq.el
init-linum-mode.el
init-lisp.el
init-lua-mode.el
init-markdown.el
init-maxframe.el
init-misc.el
init-modeline.el
init-move-window-buffer.el
init-moz.el
init-org-mime.el
init-org.el
init-osx-keys.el
init-pomodoro.el
init-proxies.el
init-python-mode.el
init-recentf.el
init-ruby-mode.el
init-semantic.el
init-sessions.el
init-sh.el
init-site-lisp.el
init-slime.el
init-smex.el
init-spelling.el
init-sr-speedbar.el
init-stripe-buffer.el
init-term-mode.el
init-textile.el
init-uniquify.el
init-utils.el
init-web-mode.el
init-which-func.el
init-windows.el
init-workgroups2.el
init-xterm.el
init-yari.el
init-yasnippet.el
init-zencoding-mode.el
init.el

README.org

Warning

  • If you are absolutely newbie and want to use Emacs immediately, please check the section “Install stable version in easiest way”.
  • I’m using Vim key binding. Please see section Tips if you prefer the Emacs key binding.
  • People in Mainland China may need goagent to download packages from ELPA. Run command “http_proxy=http://127.0.0.1:8087 emacs -nw” after starting goagent server (or any proxy server).
  • C++/C developers, you need tell Emacs location of header files. You MUST see section `clang` now!
  • I suggest Windows users using Cygwin version Emacs to avoid overhead of setting up third party tools. But this configuration is still usable even in native windows Emacs if you set up environment variable HOME.
  • My first priority is stable. So I whitelist packages from melpa (melpa-unstable, actually). Modify variable “melpa-include-packages” in init-elpa.el if you want to make some excluded packages at melpa installable. Or search the line containing “(setq package-filter-function nil)” in “init-elpa.el” and un-comment it, which make all packages at melpa installable.
  • In your bug report, please include details of environment (OS, Emacs version …) and the full output of `emacs –debug-init`.
  • If a package is not listed on myelpa, you can download its source code and put it in ~/.emacs.d/site-lisp. There are already some samples there.
  • Remove bundled emacs 22 at first if you are using OS X!

General

Most modern popular programming languages are supported (C/C++/Java/Ruby/Perl/Python/C#/Lua/Javascript …).

I will provide a updated and stable set up here. But don’t count on my explaining usage of every package. You need contact the original developer for tech support. Besides, EmacsWiki has all the tips you need.

A guide for newbies is provided at section Quick Guide.

If you need a high level guide on how to become a master. Please check my Mastering Emacs in one year.

Features

  • All key binding and plugins are usable in terminal
  • Real time HTML syntax checker enabled (you need install tidy or tidy-html5). I recommend tidy-html5.
  • git or subversion is NOT needed. You DONOT need run ‘git submodule update’.
  • optimized for cross-platform C++ development with CMake and wxWidgets
  • emacs-w3m (console browser)
  • eim (Chinese pinyin input method)
  • org2blog (post wordpress blog with org-mode)
  • make the configuration work on ALL platforms (Linux/Cygwin/Mac).
  • The configuration work with Emacs version >=24 but still usable with Emacs version 23 (tested with Emacs 23.4.1).
  • evil-mode and its plugins (Vim key binding)
  • yasnippet and my customized snippets (insert code snippet by typing less keys)

Install

Please remove the file “~/.emacs” (“~” means HOME directory).

Uninstall any third party Emacs plugins. For example, please run “apt-get uninstall emacs-w3m” in Ubuntu because all plugins will be managed by my set up.

If you prefer the method described in the section “Install stable version in easiest way”, skip everything below this line and go to that section now.

Download this zip file and extract its content into ~/.emacs.d .

Or run shell command “cd ~; git clone https://github.com/redguardtoo/emacs.d.git .emacs”.

Ensure that the ‘init.el’ contained in this repo ends up at ~/.emacs.d/init.el.

You possibly need run the below command in the terminal at least once to update the content from package repositories:

emacs -nw --batch -l ~/.emacs.d/init.el -f package-refresh-contents

Quick guide

Step 1, Learn OS basics

  • Know what’s environment variable
  • Know what’s pipe, stdout, stdin

Step 2, Read official tutorial at least once

Press “C-h t” (C means Ctrl) and start read tutorial.

  • Know how to move cursor
  • Know how to open help. Press “C-h v” and “C-h f”.

Step 3, Know org-mode basics

Org-mode is a for notes-keeping and planning. Please watch the Carsten Dominik’s talk. It’s really simple. The only hot key you need remember is “Tab”.

Step 4, Solve your first specific problem

For that specific problem, you can visit EmacsWiki for the solution. Newbies can ask for help on http://www.reddit.com/r/emacs/.

Directory structure

init.el is main file which include all the other *.el files.

init-elpa define how and what packages will be installed from elpa/marmalade/melpa by package manager.

The package manager will extract packages into ~/.emacs.d/elpa/.

I also manually download and extract some packages into ~/.emacs.d/site-lisp/. Packages in ~/.emacs.d/site-lisp/ is not visible to Emacs package manager.

My own snippets for Yasnippet is in ~/.emacs.d/snippets.

Other directoris do not matter.

Third party command line tools

These tools are OPTIONAL. Your Emacs will NOT crash if they are not installed.

w3m (web browser in console)

  • needed by `w3m` (w3m is emacs package name written in elisp)
  • install through OS package manager
  • please note only emacs with GUI can display image

lua

  • required by `flymake-lua`
  • install through OS package manager

aspell (RECOMMENDED) or hunspell, and corresponding dictionary (aspell-en, for example)

  • needed by `flyspell`
  • hunspell is the alternative of `aspell`. So you need only install either aspell or hunspell.
  • install through OS package manager
  • I force the dictionary to “en_US” in init-spelling.el. You can modify it in init-spelling.el.

sbcl (lisp environment)

  • needed by lisp `slime`
  • install through OS package manager

tidy (html tidy program) or html5-tidy (RECOMMENDED)

  • needed by `web-mode` for real time HTML syntax check
  • install through OS package manager
  • For html5-tidy, you need download its source code and build it manually

csslint

  • install `node.js` through OS package manager, then `sudo npm install -g csslint`

zip and unzip

  • needed by `org-mode` to export org to odt
  • install through OS package manager

jshint (if you use js-mode instead js2-mode)

  • install `node.js` through OS package manager, then `sudo npm install -g jshint`

xsel

  • needed by my clipboard command `copy-to-x-clipboard` and `paste-from-x-clipboard` under Linux
  • install through OS package manager

CMake

Clang

  • needed by `cpputils-cmake`, `company-clang`
  • install through OS package manager
  • If you use `cpputils-cmake` and `cmake`, `cpputils-cmake` will do all the set up for you. You don’t need read next item! But please spend a few minutes to learn the basics of cmake! There is a one minute step-by-step-guide in README of cpputils-cmake to teach you how to use cmake.
  • If you use `company-clang`, add `(setq company-clang-arguments ‘(“-I/example1/dir” “-I/example2/dir”))` into ~/.emacs.d/init.el

GCC/Make

  • needed by `flymake`
  • install through OS package manager

MozRepl (Firefox addon)

  • needed by MozRepl
  • used by Firefox

CTags

GNU Global

  • needed by `ggtags.el`
  • it creates index files for code navigation
  • more advanced than ctags, supports references and better performance
  • install through OS package manager

pyflakes

  • You need pyflakes for real time python syntax checker like `flymake-python`
  • Install pip through OS package manager, then `pip install pyflakes`
  • On cygwin you need install `setuptool` in order to install `pip`.

libreoffice

  • Only one executable `soffice` needed when converting odt file into doc (Microsoft Word 97)
  • conversion will happen automatically when exporting org-mode to odt
  • The conversion command is in variable `org-export-odt-convert-processes`
  • Install through OS package manager

js-beautify

  • To beautify javascript code (insert extra space, for example)
  • Install pip through OS package manager, then `pip install jsbeautifier`

OS package manager recommended

Install stable version in easiest way

You don’t need git or network any more. All you need are only two zip files.

Here are the exact steps you need follow:

(setq package-archives '(("myelpa" . "~/myelpa/")))

That’s it. You will never need internet connection in the future. I tested it on Emacs 24.3 and Emacs 23.4. These two versions are the most stable ones which I highly recommended!

Please note that your packages are locked. So you cannot upgrade package online in the future unless you comment out above code line again.

I don’t recommend advanced users locking their packages.

Report bug

Please file bug report at https://github.com/redguardtoo/emacs.d. Don’t send me email!

Tips

By default EVIL (Vim emulation in Emacs) is used. You can comment out line containing “(require ‘init-evil)” in init.el to unload it.

Some package cannot be downloaded automatically because of network problem.

You need manually `M-x list-packages` and install it or just `M-x package-refresh-content` and restart Emacs.

If you use `gnus` for email (Gmail, for example). Check ~/.emacs.d/init-gnus.el which includes my most settings except my private stuff. Here is my Gnus tutorial.

To toggle Chinese input method (eim, for example), press `C-` or run command `M-x toggle-input-method`.

FAQ

Please contact the original developer for help. My answer may be outdated soon.

Why auto-completion/intellisense does not work?

I assume you use company-mode. Other plugins have similar set up.

At minimum:

  • You need install clang
  • Make sure your code is syntax correct at the beginning
  • assign reasonable value into company-clang-arguments

Here is sample set up in ~/.emacs:

(setq company-clang-arguments '("-I/home/myname/projs/test-cmake" "-I/home/myname/projs/test-cmake/inc"))

In “friendly” Visual C++, you need do similar set up.

How to use color theme in CLI emacs

TERM=xterm-256color emacs -nw

When editing python code, the computer is not responsive

Don’t open two Emacs instances to edit python files. This is the bug of anaconda-mode (version 20140605.757). UPDATE: the bug is fixed after that version.

My personal custom.el (OPTIONAL)

It’s publicized at http://blog.binchen.org/?p=430. It contains my personal stuff.

About Emacs23

Emacs23 support will be dropped in one year <2015-04-24 Thu>. Currently Emacs 23 will not support below packages:

  • helm
  • org-mode and its third party packages
  • company-mode
Something went wrong with that request. Please try again.