-*- mode: org; -*-
What: Emacs Initialization File (and Builder) Author: Christopher Genovese Version: 2.5.5 Update #: 261 Last Updated: Tue 18 Jan 2011 Tested with: Emacs 23.2.1, 22.2 (Mac OS X 10.5.8)
This emacs initialization has grown over years of use, tweaking, and experimentation. Nonetheless, I’ve worked to maintain a useful organization that will make modification and sharing easier. Although it is a truism that everyone loves their own customizations, it’s my hope (belief) there are features here that are generally useful, and I hope that others can benefit from this init file, in part or in whole.
The following are some of the notable features. These are mostly small things, but I want to highlight them because they might be hard to spot in all this code. Detailed documentation for the features is given in the component files, linked to below.
- Efficient Key Bindings
Like many emacs users, I prefer to avoid mouse use as much as possible. I also try to avoid pinky extension in either hand. And I have attempted to configure commonly used operations to be as parsimoniously represented as possible and to make accessible as many commands as possible.
The keybindings here are, I think, quite efficient and memorable. Note for example: although \M-x works, I have alternate bindings \C-x\C-m and \C-c\C-m that are faster. I have moved help to \M-\C-h, which leaves the easy keys \C-h and \M-h for more commonly used operations delete-backward-char and backward-kill-word. Once you get used to that, you will never hit backspace again. Also, in most cases one can use \C-m instead of return, eliminating a common pinky stretch. \M-<space> (mark-sexp) is very useful even in text modes for grabbing and extending over reasonable units. Rectangles, bookmarks, abbrevs, tags, icicles, org, and several other commonly used features have their own sub-maps that are mnemonically arranged.
See keybindings.el for details.
(Note: My quick-nav mode takes this farther for even greater efficiency.)
See also the note below for an important issue with the keybindings.
- Navigation
Many of the builtin emacs movement commands issue errors at boundary cases (e.g., scroll-up near the beginning of the buffer). I have modified versions of these commands that avoid errors and “do what I mean”.
See file move-funcs.el for examples.
- Help Navigation
The emacs help system is very nice, but to make it convenient it helps to have some navigation keys. \M-\C-h g takes you to the help buffer and g in the help buffer takes you back, leaving the help buffer where it was (q does the same while dismissing the help buffer). Various other keybindings in the help mode have been overridden to provide smooth navigation with a minimum of stretching or disruption.
See file nav-modes.el for details.
- Dired
It took me many years to truly appreciate dired, but now that I have, it has more and more supplanted the shell for many commands. The key to this (excuse the pun :), I think, is some additional functionality that makes common operations easier. This is especially important for the case where subdirectories are listed in the same buffer, which is the default here, because the standard dired setup does not adequately support that case. With this in place, I can do much of what I traditionally did in the shell with dired, and more efficiently.
See file nav-modes.el for details.
- Shell Directory Tracking
The tcsh shell has a directory stack feature that I’ve found very convenient. In particular, it is easy to keep track of and access directories on the stack. This is pretty old code but I’ve been using it continuously for years, so it’s also very stable. Coming version will include a more general mechanism that I’m experimenting with now.
See file shell-mode.el for details.
- Ibuffer
A nice (and flexible) default filter setup, some nice navgation bindings, and a function for classifying files in the IBuffer listing.
See file aux.el for details.
- Icicles
The icicles package is just terrific. I’ve added functionality to ease navigation in the completions buffer, to indicate results sorting, and to fix a problem with default strings.
See file nav-modes.el for details.
- SLIME
Superior Lisp Interaction Mode for Emacs (SLIME) is a nice way to deal with various lisp dialects. Although there is a swank support through lein that does work with SLIME, it forces one to invoke swank externally and then connect using a different mechanism (slime-connect) than with other dialects. Here, I give an alternative interface that lets one add and modify lisp implemenations in a variety of ways, unifying starting and stopping across implementations. Clojure works directly this way, automatically connecting to swank from within emacs.
See file prog-modes.el for details.
- TeX
Addition of commands and tags, including especially support for using make to construct documents.
See file tex-modes.el for details.
- ESS
A simple customization (should be the default, I think) that makes it easier to work in an ess-mode buffer while evaluating expressions.
See file ess-modes.el for details.
- Some Useful Functions
The files *-funcs.el contain a variety of emacs lisp functions that can be useful more generally. The file aliases.el introduces a few scheme/clojure style predicates and other function aliases. The file macros.el has several common and other control-flow macros. The file import-funcs.el has the first version of an import facility for managing requires and autoloads (and other types of loads). It doesn’t do everything I want it to yet but it is functional.
Acknowledgements: This code has been written over many years, inspired by and sometimes with reference to a lot of code written by others in the emacs community. Thanks to all for the good examples and wonderful packages.
Besides the new and modified keybindings set here, there is an important difference between these bindings and the GNU defaults. In particular, the GNU default global map uses C-v/M-v for scrolling, C-w for killing the region, and M-k for kill-sentence, with beginning and end of buffer exiled to M-< and M->. From almost the beginning of my time with emacs, I’ve found these unnatural. Instead, I use the following:
C-w Scrolling down (or beginning of buf when close) C-v Scrolling up (or end of buf when close) M-w Beginning of Buffer M-v End of Buffer M-k Kill region M-c Copy region and save in kill ring
There are some other differences from the default, of course, but these are the major thematic differences. I use all of these commands very frequently. Understanding that everyone likes what they are used, I’d urge you to try these; but if you want the defaults, there are only a handful of places where they are used. Search for “\(?:[MC]-w\|M-k\)” in the main file. In the next version, I will include a new function, called use-gnu-scroll-and-kill-bindings, to rearrange these bindings to the GNU default theme. I will also introduce additional “intelligent” mark and kill commands, which I’ve developed for my quick-nav mode.
The file is crg-emacs-init.el is the standalone “.emacs” file constructed from the other components in this directory. The compiled version crg-emacs-init.elc was byte compiled with Emacs 23.2.1. See below for installation instructions.
During startup, the init file is loaded, followed by the emacs-custom.el file in my-home-lisp-dir (e.g., ~/.emacs.d) and then my-env.el in my-home-lisp-dir, if it exists, for additional environment- or system-specific adjustments that you want to keep out of the main file. (For instance on Mac OS X, one can set the PATH environment variable here if you don’t want to adjust ~/.MacOSX/environment.plist on your system.) (Note the file system-settings.el in the main build can be used for a similar purpose.
The crg-emacs-init.el file is built from the other components in this directory using make. The file includes a hyper-linked table of contents (via linkd-mode) and extensive documentation. The makefile is also documented, but here I will describe the main pieces that are used in a less terse manner.
Files are roughly grouped by name according to the following patterns, matched successively (cond-like):
Pattern | Category |
---|---|
*-funcs.el | Utility functions on a related theme |
*-modes.el | Customizes related group of major or minor modes |
*.el | Support functionality (headers, keybindings, etc.) |
[A-Z][-A-Za-z]* | Configuration data, documentation, or build support |
More specifically, the components are as follows:
Document Structure | |
---|---|
header.el | Documentation and version information |
toc.el | Table of contents |
utility-header.el | Table of contents for utility functions |
Utility Functions | |
aliases.el | Readable aliases for common functions |
predicate-funcs.el | Predicates for list filtering |
list-funcs.el | Operations on lists and vectors |
macros.el | Flow control and other macros |
name-funcs.el | File and directory names |
move-funcs.el | Scrolling and cursor movement commands |
op-funcs.el | Modifications to Emacs’s operation |
import-funcs.el | A simple module import interface |
tool-funcs.el | Miscellaneous useful tools |
setter-funcs.el | Setters and toggles for mode hooks |
Mode Config | |
ess-modes.el | ESS configuration |
nav-modes.el | Navigation and file modes |
prog-modes.el | Programming language modes |
shell-modes.el | Shell/command interpreter modes |
tex-modes.el | TeX/AucTeX configuration |
text-modes.el | Text-based modes |
Settings | |
aux.el | IBuffer setup + miscellaneous features |
faces.el | Face definitions |
imports.el | Library and package import |
keybindings.el | Global keybindings and keymaps |
settings.el | Setup of Emacs’s operating state |
system-settings.el | System specific configuration |
Local Config | |
init.el | Initializes emacs state |
whoami.el | Generated personal settings file |
Build Files | |
Config | Personal configuration settings |
MakeTOC* | Script to make table of contents |
MakeWho* | Script to construct whoami.el |
Makefile | Build manager |
README | Documentation |
VERSION | Version information |
WhoAmI | Base file for personal settings |
- Edit the keys in Config to personalize locations of files and directories, as well as various parameters.
- (Optional) You can add additional customizations to WhoAmI
and add corresponding keys in Config. Config keys are of the
form
KEY: VALUE
and these show up as __KEY__ in WhoAmI. The values will be substituted for the keys directly.
The file WhoAmI is emacs lisp with Config keys in place. These keys will be substituted directly.
Note that the variables that are currently defined in this file should not be removed as they are used later in the code. Take care when changing these definitions.
- (Optional) If you want to byte compile the init file, you should set the location of the emacs executable (make variable EMACS). The current setting is for installation on MacOS X because that’s what I’m currently using.
- (Optional) You should also configure the executable paths for perl and python (variables PERL and PYTHON) in the makefile if these are in non-standard locations. (Note: this step will not be necessary in the next version.) You can also change the default install and archive locations (INSTALL and ARCHIVE, see the makefile for details and more refined options.)
- (Optional) Only if you want to make the full archive, you should set the location of the emacs executable (EMACS) and the directories of the various lisp libraries (EMAPP_LIB, EMACS_LIB, LOCAL_LIB) and the location of the build directory (EMACS_INI), as described in the makefile.
- See Makefile for build and installation options. In short,
you can get a byte-compiled initialization file by typing:
make make install make clean
at the shell prompt. (Verify successful compilation before proceeding to the second step. Emacs will give some compilation warnings, which you can probably ignore).
To get an emacs-lisp source file, type
make elisp make install INSTALL_SUFX=.el make fullclean
This will install a .emacs file in your home directory by default. You can edit the Makefile options to customize the build further.
I have tested this init file both explicitly and through long use on Emacs 22 and 23, on both Mac OS X and Linux. Emacs 22 users may wish to re-byte-compile the main file, as the version included here was compiled with emacs 23.
This configuration takes advantage of several built-in and third party modes/packages when they are available. Links to the source for third party packages are given below. Most of these can be obtained at http://www.emacswiki.org unless otherwise specified. None of these is strictly required for the init file to work. The packages that are referred to, directly or indirectly, are listed below with version information.
Package | Link | Version | Notes |
---|---|---|---|
anything | EmacsWiki | 1.287 | plus anything-config.el |
bookmark+ | EmacsWiki | 3.2.0 | Update #14946 |
ess | R-Project | 5.11 | |
icicles | EmacsWiki | 22.0 | Update #22776 |
linkd | EmacsWiki | 1.64 | Update #629 |
org-mode | OrgMode.org | 7.01h | |
yasnippet | Google Code | 0.6.1c | not the bundle |
cedet | SourceForge | 1.0 | emacs23 uses builtin version |
ecb | SourceForge | 2.40 | |
jde | SourceForge | 2.4.0.1 | emacs23 uncertain |
Package | Link | Version | Notes |
---|---|---|---|
col-highlight.el | EmacsWiki | 22.0 | Update #313 |
constants.el | EmacsWiki | 2.2 | |
crosshairs.el | EmacsWiki | 22.0 | Update #394 |
dired+.el | EmacsWiki | 21.2 | Update #2810 |
filladapt.el | EmacsWiki | 2.12 | |
hexrgb.el | EmacsWiki | 21.0 | Update #733 |
hl-line+.el | EmacsWiki | 22.0 | Update #424 |
icomplete+.el | EmacsWiki | 21.0 | Update #880 (with icicles) |
imenu+.el | EmacsWiki | 21.1 | Update #567 |
info+.el | EmacsWiki | 21.1 | Update #4374 |
lacarte.el | EmacsWiki | 22.0 | Update #632 (with icicles) |
replace+.el | EmacsWiki | 21.0 | Update #1051 |
synonyms.el | EmacsWiki | 1.0 | Update #2440 (with icicles) |
thingatpt+.el | EmacsWiki | 21.0 | Update #831 |