+ (setq font-lock-keywords
+ (list (list (concat "\\("
+ "\\_<[-+]?"
+ "\\(" "[0-9]+/[0-9]+"
+ "\\|" "\\(" "[0-9]+" "\\(\\.[0-9]*\\)?" "\\|"
+ "\\.[0-9]+" "\\)"
+ "\\([dDeEfFlLsS][-+]?[0-9]+\\)?"
+ "\\)"
+ "\\|"
+ "#"
+ "\\(" "x" "[-+]?"
+ "[0-9A-Fa-f]+" "\\(/[0-9A-Fa-f]+\\)?"
+ "\\|" "o" "[-+]?" "[0-7]+" "\\(/[0-7]+\\)?"
+ "\\|" "b" "[-+]?" "[01]+" "\\(/[01]+\\)?"
+ "\\|" "[0-9]+" "r" "[-+]?"
+ "[0-9a-zA-Z]+" "\\(/[0-9a-zA-Z]+\\)?"
+ "\\)"
+ "\\)\\_>")
+ '(0 mdw-number-face))
+ (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
+ '(0 mdw-punct-face)))))
+
+;; Special indentation.
+
+(defcustom mdw-lisp-loop-default-indent 2
+ "Default indent for simple `loop' body."
+ :type 'integer
+ :safe 'integerp)
+(defcustom mdw-lisp-setf-value-indent 2
+ "Default extra indent for `setf' values."
+ :type 'integer :safe 'integerp)
+
+(setq lisp-simple-loop-indentation 0
+ lisp-loop-keyword-indentation 0
+ lisp-loop-forms-indentation 2
+ lisp-lambda-list-keyword-parameter-alignment t)
+
+(defun mdw-indent-funcall
+ (path state &optional indent-point sexp-column normal-indent)
+ "Indent `funcall' more usefully.
+Essentially, treat `funcall foo' as a function name, and align the arguments
+to `foo'."
+ (and (or (not (consp path)) (null (cadr path)))
+ (save-excursion
+ (goto-char (cadr state))
+ (forward-char 1)
+ (let ((start-line (line-number-at-pos)))
+ (and (condition-case nil (progn (forward-sexp 3) t)
+ (scan-error nil))
+ (progn
+ (forward-sexp -1)
+ (and (= start-line (line-number-at-pos))
+ (current-column))))))))
+(progn
+ (put 'funcall 'common-lisp-indent-function 'mdw-indent-funcall)
+ (put 'funcall 'lisp-indent-function 'mdw-indent-funcall))
+
+(defun mdw-indent-setf
+ (path state &optional indent-point sexp-column normal-indent)
+ "Indent `setf' more usefully.
+If the values aren't on the same lines as their variables then indent them
+by `mdw-lisp-setf-value-indent' spaces."
+ (and (or (not (consp path)) (null (cadr path)))
+ (let ((basic-indent (save-excursion
+ (goto-char (cadr state))
+ (forward-char 1)
+ (and (condition-case nil
+ (progn (forward-sexp 2) t)
+ (scan-error nil))
+ (progn
+ (forward-sexp -1)
+ (current-column)))))
+ (offset (if (consp path) (car path)
+ (catch 'done
+ (save-excursion
+ (let ((start path)
+ (count 0))
+ (goto-char (cadr state))
+ (forward-char 1)
+ (while (< (point) start)
+ (condition-case nil (forward-sexp 1)
+ (scan-error (throw 'done nil)))
+ (incf count))
+ (1- count)))))))
+ (and basic-indent offset
+ (list (+ basic-indent
+ (if (oddp offset) 0
+ mdw-lisp-setf-value-indent))
+ basic-indent)))))
+(progn
+ (put 'setf 'common-lisp-indent-functopion 'mdw-indent-setf)
+ (put 'psetf 'common-lisp-indent-function 'mdw-indent-setf)
+ (put 'setq 'common-lisp-indent-function 'mdw-indent-setf)
+ (put 'setf 'lisp-indent-function 'mdw-indent-setf)
+ (put 'setq 'lisp-indent-function 'mdw-indent-setf)
+ (put 'setq-local 'lisp-indent-function 'mdw-indent-setf)
+ (put 'setq-default 'lisp-indent-function 'mdw-indent-setf))
+
+(defadvice common-lisp-loop-part-indentation
+ (around mdw-fix-loop-indentation (indent-point state) activate compile)
+ "Improve `loop' indentation.
+If the first subform is on the same line as the `loop' keyword, then
+align the other subforms beneath it. Otherwise, indent them
+`mdw-lisp-loop-default-indent' columns in from the opening parenthesis."
+
+ (let* ((loop-indentation (save-excursion
+ (goto-char (elt state 1))
+ (current-column))))
+
+ ;; Don't really care about this.
+ (when (and (boundp 'lisp-indent-backquote-substitution-mode)
+ (eq lisp-indent-backquote-substitution-mode 'corrected))
+ (save-excursion
+ (goto-char (elt state 1))
+ (cl-incf loop-indentation
+ (cond ((eq (char-before) ?,) -1)
+ ((and (eq (char-before) ?@)
+ (progn (backward-char)
+ (eq (char-before) ?,)))
+ -2)
+ (t 0)))))
+
+ ;; If the first loop item is on the same line as the `loop' itself then
+ ;; use that as the baseline. Otherwise advance by the default indent.
+ (goto-char (cadr state))
+ (forward-char 1)
+ (let ((baseline-indent
+ (if (= (line-number-at-pos)
+ (if (condition-case nil (progn (forward-sexp 2) t)
+ (scan-error nil))
+ (progn (forward-sexp -1) (line-number-at-pos))
+ -1))
+ (current-column)
+ (+ loop-indentation mdw-lisp-loop-default-indent))))
+
+ (goto-char indent-point)
+ (beginning-of-line)