I’m now using Emacs on my three computers, an Apple iBook, a Windows desktop and a Linux desktop. The problem is keeping a uniform set-up over the three.
I used to use jEdit, which remains an excellent text editor that I would use, and recommend, in an instant. It is, in many ways, more advanced that Emacs. However, I have always struggled to use Emacs, and it bothered me. Why can I not use the text editor most used by coders I respect? After some perseverance, I found how to set up things like CUA-style editing, and felt much more comfortable. Another post here describes a few of the things I learned that helped.
To provide a uniform experience on the three platforms, I decided
to write a configuration file that would be run by the
.emacs file. This file, called
dot-emacs.el, would set up all my preferences, with
machine-specific things like paths being handled programatically
based upon the machine’s hostname. For example:
;; Where is CLISP?
(defun clisp-location () "Get loc. for CLISP on host"
(cond
((equal system-name hostname1)
"/sw/bin/clisp")
((equal system-name hostname2)
"/usr/bin/clisp")
("/usr/bin/clisp"))) ;; Default to sensible value
This is a function that tests the hostname of the computer via the
system-name variable (defined by Emacs rather than
me), and then returns the correct path to CLISP for the host the
code is running on. This code is then used as follows to actually
specify where CLISP is:
(setq inferior-lisp-program (clisp-location))
In addition to specifying paths, we need to use edit modes to make
editing specific types of file more convenient. Instead of
installing these into the site-lisp directory, I store them in
another directory (along with dot-emacs.el). In
dot-emacs.el, I add this directory to the load path
using the following code:
(setq load-path (cons
(expand-file-name (this-path-on-host))
load-path))
where this-path-on-host is a function that returns the
directory where dot-emacs.el is on the current host.
So that changes made to dot-emacs.el on one host can
easily be mirrored to the other hosts, I store
dot-emacs.el and the edit mode files under the control
of CVS. This allows me to
have a uniform environment, regardless of computer, and move to
other computers in the future, if needed.