A blog about skating and cycling, or vice versa

Loitering with indent#

Wed, 08 Aug 2007 22:55:35 +0000

It's been one of those dependency^Wdistraction hell weeks. I'll spare you the details, because that way lies Rant, but by mid-afternoon today I found I'd upgraded Emacs to version 22 and was trying to write a new MUA by sticking bits of mel-base and ltk together, and getting really weird "stairstep" indentation for lists of keywords. This turned out to be nothing to do with stale fasls/elc files (first suspect) or with SLIME (second suspect) or with cl-indent (third suspect), but the underlying Emacs lisp indentation engine has had some changes to "try to align a constant-symbol under the last preceding constant symbol" which has had a completely undesirable knock-on effect on CL.

So, without further ado: my .emacs file now says

(require 'slime)

;; emacs 22 lisp indentation, if left to its own devices, indents ;; lists of keywords in a "stairstep" fashion like so ;; (list :foo :bar ;; :baz :quux ;; :bum :ki) ;; ;; this appears to be intentional (see comment "try to align a ;; constant-symbol under the last preceding constant symbol" in ;; lisp-mode.el) and perhaps it's even useful for elisp, but it makes ;; make-instance (for example) look bloody silly

(defun my-cl-indent-function (indent-point state) (let ((normal-indent (current-column))) (if (save-excursion (goto-char indent-point) (skip-chars-forward " \t") (looking-at ":")) normal-indent (common-lisp-indent-function indent-point state))))

(slime-setup) (add-hook 'lisp-mode-hook (lambda () (setq lisp-indent-function 'my-cl-indent-function)) 'append)

You need the hook (and you need it to run last) as SLIME also installs its own hook to make lisp-indent-fuction buffer-local and set it to common-lisp-indent-function