Helmut Eller wrote:
Maybe you can post your changes here or send them to the Emacs developers. If the Emacs guys are too slow for our taste, we can re-add the file to SLIME.
Here's a patch against the removed file (which may also match the one in the Emacs sources). The default settings of the new configuration variables match the old behavior, here are the settings we're using internally:
;; Indentation control (setq lisp-indent-function 'common-lisp-indent-function) (setq lisp-loop-keyword-indentation 6);align keywords just after "loop " (setq lisp-loop-forms-indentation 6) (setq lisp-loop-simple-tail-indentation 2) (setq lisp-loop-collector-added-indentation 2) (setq lisp-simple-loop-indentation 2) ;; The following really needs to be put in a hook because it keeps ;; getting overwritten. (put 'if 'common-lisp-indent-function '(2 2 2)) (setq slime-conservative-indentation nil)
Index: cl-indent.el =================================================================== RCS file: /project/slime/cvsroot/slime/Attic/cl-indent.el,v retrieving revision 1.2 diff -u -r1.2 cl-indent.el --- cl-indent.el 26 Oct 2004 00:43:42 -0000 1.2 +++ cl-indent.el 4 Apr 2005 14:43:12 -0000 @@ -101,6 +101,18 @@ :group 'lisp-indent)
+(defcustom lisp-loop-simple-tail-indentation 3 + "*Indentation of forms in loops of the form (LOOP ... DOING <forms>)." + :type 'integer + :group 'lisp-indent) + + +(defcustom lisp-loop-collector-added-indentation 0 + "*Additional indentation for collect and similar keywords in loop bodies." + :type 'integer + :group 'lisp-indent) + + (defcustom lisp-simple-loop-indentation 3 "*Indentation of forms in simple loop forms." :type 'integer @@ -122,6 +134,63 @@ (looking-at "\sw")) (error t)))
+(defun extended-loop-with-simple-tail-p (loop-start) + (interactive "d") + (condition-case () + (save-excursion + (goto-char loop-start) + (forward-char 1) + (forward-sexp 2) + (backward-sexp 1) + ;; Accumulate the pattern of keywords and lists in the body + (let ((pat ())) + (condition-case () + (while (not (and (eobp) (looking-at "\s-)"))) + (if (looking-at "\sw") + (save-excursion + (let ((word (downcase (thing-at-point 'word)))) + (if (or (string= word "do") + (string= word "doing")) + (push 'do pat) + (push 'keyword pat)))) + (push 'list pat)) + (forward-sexp 2) + (backward-sexp 1)) + (error t)) + (setq pat (nreverse pat)) + (let ((after-first-do (memq 'do pat))) + (if (and after-first-do + (not (or (memq 'do (cdr after-first-do)) + (memq 'keyword (cdr after-first-do))))) + t + nil)))) + (error t))) + +(defvar common-lisp-loop-collect-keyword-alist + ;;This is an alist solely so that we can use assoc-ignore-case. + '(("append" t) + ("appending" t) + ("collect" t) + ("collecting" t) + ("count" t) + ("counting" t) + ("maximize" t) + ("maximizing" t) + ("minimize" t) + ("minimizing" t) + ("nconc" t) + ("nconcing" t) + ("sum" t) + ("summing" t)) + "Alist of all of the value accumulation keywords in loop.") + +(defvar common-lisp-loop-conditional-keyword-alist + ;;This is an alist solely so that we can use assoc-ignore-case. + '(("else" t) + ("if" t) + ("when" t) + ("unless" t)) + "Alist of all of the conditional execution keywords in loop.")
(defun common-lisp-loop-part-indentation (indent-point state) "Compute the indentation of loop form constituents." @@ -132,8 +201,33 @@ (beginning-of-line) (cond ((not (extended-loop-p (elt state 1))) (+ loop-indentation lisp-simple-loop-indentation)) - ((looking-at "^\s-*\(:?\sw+\|;\)") - (+ loop-indentation lisp-loop-keyword-indentation)) + ((looking-at "^\s-*\(:?\sw+\)") + (if (zerop lisp-loop-collector-added-indentation) + (+ loop-indentation lisp-loop-keyword-indentation) + ;; Some people like to specially indent a collection keyword + ;; which follows a conditional keyword. + (if (and (assoc-ignore-case (downcase (save-excursion + (skip-chars-forward "^a-zA-Z") + (thing-at-point 'word))) + common-lisp-loop-collect-keyword-alist) + (save-excursion + (backward-sexp 2) + (and (looking-at "\sw") + (assoc-ignore-case (downcase (thing-at-point 'word)) + common-lisp-loop-conditional-keyword-alist)))) + (+ loop-indentation lisp-loop-keyword-indentation + lisp-loop-collector-added-indentation) + (+ loop-indentation lisp-loop-keyword-indentation)))) + ;; Change from previous behavior -- indent comments as forms, not keywords. + ;; Since the default indentation values are the same, this will only affect + ;; people with customized indentation. IMHO, this version works much better with + ;; lisp-loop-simple-tail-indentation. + ((looking-at "^\s-*;") + (if (extended-loop-with-simple-tail-p (elt state 1)) + (+ loop-indentation lisp-loop-simple-tail-indentation) + (+ loop-indentation lisp-loop-forms-indentation))) + ((extended-loop-with-simple-tail-p (elt state 1)) + (+ loop-indentation lisp-loop-simple-tail-indentation)) (t (+ loop-indentation lisp-loop-forms-indentation)))))