snarfed.org

Ryan Barrett's blog

minimal .emacs for fast startup

Wed, 01 Jan 2003 [comments (2)] [history] [rdf] [raw]

gnu.jpg

I spend a fair amount of time ssh-ed into remote, headless linux servers. I often need to use a text editor to edit configuration files. Most don't run X windows, so I can't run emacs, my editor of choice, in graphical mode. I could use emacs -nw, which starts emacs in text mode, but emacs is still fairly heavy by default. These editing sessions are usually quick and simple, and I wouldn't want to wait for a full-blown emacs to start every time.

I used pico for a while, since I use pine as my email client. However, I missed emacs' depth and versatility. I considered vi, but I wasn't exposed to it in the womb, and I'm not sure there's any other way to learn it. :P

More importantly, I didn't like using two different editors. Mental context switches are evil incarnate, and switching between text editors is a big context switch.

So, I set out to make the minimal emacs -nw setup - lightwight, fast to start, and still usable for casual editing. It actually turned out to be fairly easy. I use this command to start emacs:

emacs -nw --no-init-file --no-site-file \
  --load .emacs.minimal


and this elisp in my my minimal .emacs:

; cutoff for word wrap
(setq-default fill-column 79)

; F12 toggles auto-fill mode
(global-set-key [f12] 'auto-fill-mode)

; C-- keybinding for undo (removes the shift)
(global-set-key [(control -)] 'undo)

; turn on pending delete (when a region
; is selected, typing replaces it)
(delete-selection-mode t)

; when on a tab, make the cursor the tab length
(setq-default x-stretch-cursor t)

; avoid garbage collection (default is only 400k)
(setq-default gc-cons-threshold 4000000)

; turn on random customization options
(custom-set-variables
  '(sentence-end-double-space nil)
  '(truncate-partial-width-windows nil)
  '(line-number-mode t)
  '(column-number-mode t)
  '(query-user-mail-address nil)
  '(visible-bell t))


Your .emacs file is fairly personal, so you'll probably want to customize it and add things from your standard .emacs. dotemacs.de is a good resource for writing and refining your .emacs file.

See also:

comment bubble OpenID Guest, Wed 02 Aug 2006

is there a specific reason for you not to use tramp? it suits all my editing-remote-configs-on-headless-machines-via-ssh needs.

comment bubble OpenID ryan, Wed 02 Aug 2006

good question. i tried tramp for a while, and i really liked it.

i didn't stick with it, though, because it's slow. it has to go through the ssh handshake every time i open a file, which can take a while.

i tried both inline (ssh) and external (scp) methods, and i tried tweaking it to make it faster, but it was never quite fast enough.

(i also mention this in why I don't run shells inside Emacs.)

Post a comment...



Simple HTML and wiki markup are allowed.