Adam's Emacs Dotfiles

I am a big fan of emacs. Over the years I've suckered many coworkers into using my emacs dotfiles. On this page you can find the latest version of my emacs dotfiles, plus some meager associated documentation.

Caveat emptor : Despite appearances, I am not an emacs expert. I probably can't help you with random emacs problems, and you might have different ideas about what should go into your dotfiles.

The gurge.com blog may have additional tips and information.

Please send comments and suggestions to amd@gurge.com

Download
Changelog
Installation
Customization
Tips and Tricks

Download

The latest version is amdelisp-2007-01-20.zip (2.2mb)

Changelog

  • 2007-01-20

    - completion fixes for emacs 22 compat
    - changed nxml indent to 2
    - mapped html/sgml to nxml mode
    - *.rake => ruby mode
    - abtags auto-reloads TAGS files now
    - finally tracked down and fixed pesky loaddefs issue

  • 2006-09-03

    - ruby 1.74.2.14 from Ruby 1.8.4
    - ruby electric Mar 2005 from Dee Zsombor
    - many ruby fixes and enhancements (Rakefile, yaml, indent=2, etc.)
    - cc-mode 5.31.3
    - csharp-mode 0.5.0 from Dylan Moonfire (thanks Brigham)

  • 2006-08-04 - Initial release.

Installation

  1. Download and unzip amdelisp.

  2. If you DO have an existing .emacs file, add this to the top:

    (defvar AMDELISP <path-to-elisp>)
    (load (format "%s/start" AMDELISP))

    For example, if you unzipped amdelisp-2007-01-20.zip into /myfiles/, you would use:

    (defvar AMDELISP "/myfiles/amdelisp-2007-01-20/elisp")
    (load (format "%s/start" AMDELISP))

    The AMDELISP variable is used elsewhere, so it's important that you set it.

  3. If you DON'T have an existing .emacs file, use the one included in the download, and customize the top as indicated in step (2).

  4. Hint for Windows users - remember that emacs looks for the .emacs file in your HOME directory. The easiest way to make this work is to manually set the HOME environment variable.

  5. Run emacs!

Customization

Font

On Windows, add something like this to your .emacs:

(when window-system
  (setq my-font (window-build-font "Andale" 11)))

Colors

I use my own color theme. Try it out with this:

(turn-on-color-theme-amd)

Check out prefs.el to learn how to build your own theme. Mine is complicated because I like to have different colors for Windows, Linux, and the terminal.

Keys

All keys are defined in prefs.el. Look there for examples.

Completion

This is extremely handy but some people don't like the implementation. If you want TAB to complete the current word, add this:

(require 'complete)
(partial-completion-mode t)
(global-set-key-override0 (if is-win32 [tab] "\t") 'clever-hippie-tab)
(global-set-key-override (if is-win32 [tab] "\t") 'clever-nxml-tab 'nxml-mode)

If you press TAB at the start of the line, it will reindent the line instead of trying to complete.

Tabs vs. spaces and indent size

These are usually controlled by the two variables indent-tabs-mode and tab-width. Look in modes.el to learn how to add hooks to different modes to control the indent level. This really sucks.

Window size and location

There are three variables that control window geometry. window-position can be 'left, 'center, or 'right. window-columns is the width of the window. window-fudge is a fudge factor that nudges the window a bit (left right top bottom). Thanks to Arthur van Hoff for this code.

(when window-system
  (setq window-position 'right
    window-columns 87
    window-fudge '(0 12 0 55))

Other stuff

Experiment with this goo and other stuff you see in the sample .emacs:

(menu-bar-mode 0)
(mouse-wheel-mode t)
(blink-cursor-mode 1)
(global-hl-line-mode)
(transient-mark-mode t)

Tips and Tricks

These dotfiles are chock full of useful stuff. Here are a few pointers to help you get started.

Feature List

  • cross platform - works on Windows and Linux, windowed or in a terminal
  • lots of modes - including some simple ones I created (valgrind, svn, mbox, NSIS, ...)
  • customizable - these dotfiles are probably more customizable then others you've seen, because they've been used by so many people over the years
  • speedy - I use autoloads everywhere so emacs starts up quickly
  • make.el - helpers for compiling (try M-s)
  • abtags.el - quickly jump around large numbers of files. Build a TAGS file with ctags, then use abtags-find-file (bound to F7 in my .emacs).
  • TAGS helpers - M-. to lookup a tag, M-, to pop back

File Arrangement

.emacsa sample .emacs file that loads start.el
elisp/abtags.elgreat way to jump around using TAGS files (thanks to Adam Feder)
elisp/added.elstandalone functions I wrote
elisp/linux.ellinux-specific stuff
elisp/make.elhelpers for compiling
elisp/modes.elconfiguration for all modes
elisp/prefs.elthings you actually might want to change (colors, keys, ...)
elisp/start.elentry point that loads the other files
elisp/svn.elsome simple subversion wrappers
elisp/window.elhelpers for controlling where the emacs window appears
elisp/emacslib/contains 3rd party emacs libraries that I use in my dotfiles
elisp/lisp/please ignore, this is just to help generate autoloads
elisp/subdirs.elplease ignore, this helps to load subdirs

3rd party libraries in elisp/emacslib/

apache-modemodes for many apache conf files
asciishow ascii codes when moving the cursor
color-themeskins for emacs
filladapthelper for "filling" lines. Mainly useful to java comments.
gnuservused to allow Windows Explorer to send files to an existing emacs
guess-offsettries to guess the indentation size for c/c++/java/etc.
htmlizeconvert font locked emacs buffers to colored html
jdokuseful for parsing java files
pageralternate pageup/pagedown commands that try to return to the same line
psvnsophisticated svn helpers. I wrote a simpler svn.el.
cc-modec/c++/java/etc. mode
cperl-modeperl
css-modecascading style sheets
nxml-modeXML
php-modephp
python-modepython
ruby-moderuby (can't find the download link)
visual-basic-modevb
html-helper-modevery old, very broken HTML mode. These days I prefer nxml mode for html.
mmm-modevery old, very broken way to combine modes (like, CSS inside HTML)