1 ;;; Indentation style for CLISP sources -*- Emacs-Lisp -*-
2 ;;; Load this file from ~/.emacs or ~/.emacs.el
3 ;;; Tested with XEmacs 21.1.7, Emacs 20,21
7 ;; Tabs are anachronistic.
8 (setq-default indent-tabs-mode nil
)
13 ; Don't use autoloading.
14 ;(autoload 'common-lisp-indent-function "cl-indent" "Common Lisp indent.")
15 ; Load cl-indent.el now. Loading it later would clobber our
16 ; common-lisp-indent-function property settings.
17 (load-library "cl-indent")
19 (setq lisp-indent-function
'common-lisp-indent-function
)
21 ; Each operator's indentation specification can be
22 ; - a symbol, must be an Elisp function,
23 ; - a list (x1 x2 ...), where x1 specifies the indentation of the first
24 ; subform, x2 the indentation of the second subform, and so on.
25 ; ... nil ... = default indentation
26 ; ... &lambda ... = (&whole 4 (&rest 1))
27 ; ... &body) = &rest ,lisp-body-indent
28 ; ... &rest x) = infinite repetition x x x x x ...
29 ; ... n ... = explicit indentation by n spaces, if the
30 ; first subform is already on the second line
31 ; - an integer n, denoting (4 4 ... &body).
32 ; => Special case: 0 is equivalent to (&body), i.e. equivalent to (&rest 2).
33 ; Note a subtle difference between (&rest 2) and (2 &rest 2): If the first
34 ; subform is on the same line as the operator, (&rest 2) indents the second
35 ; subform under it, whereas (2 &rest 2) indents the second subform by 2 spaces
38 (defmacro defindent
(operator indentation
)
39 `(put ',operator
'common-lisp-indent-function
',indentation
))
42 '(lisp-body-indent 2) ; default
43 '(lisp-indent-maximum-backtracking 4) ; needed for flet/labels
44 '(lisp-tag-body-indentation 2) ; for tagbody/prog/prog*
45 '(lisp-tag-indentation 2)) ; for tagbody/prog/prog*
47 (defindent and
(&rest
2))
48 (defindent appease-cerrors
(&rest
2))
49 (defindent assert
(&rest
2))
50 (defindent block
(4 &rest
2)) ; default
51 (defindent case
(4 &rest
(&whole
2 2 2 2 2 2 2 2 2 2 2)))
52 (defindent catch
(4 &rest
2)) ; default
53 (defindent ccase
(4 &rest
(&whole
2 2 2 2 2 2 2 2 2 2 2)))
54 (defindent check-type
(2 2 &rest
2))
55 (defindent compiler-let
((&whole
4 &rest
(&whole
1 1 2)) &body
)) ; default
56 (defindent cond
(&rest
(&whole
2 2 2 2 2 2 2 2 2 2 2)))
57 (defindent ctypecase
(4 &rest
(&whole
2 2 2 2 2 2 2 2 2 2 2)))
58 (defindent decf
(2 2))
59 (defindent declaim
(&rest
2))
60 (defindent declare
(&rest
2))
61 (defindent def-c-enum
(4 &rest
2))
62 (defindent def-c-struct
(4 &rest
2))
63 (defindent defclass
(10 (&whole
10 1 &rest
1) &rest
(&whole
2 &rest
1)))
64 (defindent defconstant
(4 2 2)) ; default
65 (defindent defgeneric
(4 (&whole
4 1 &rest
1) &body
))
66 (defindent define-condition
(18 (&whole
18 1 &rest
1) &rest
(&whole
2 &rest
1)))
67 (defindent define-modify-macro
(4 (&whole
4 1 &rest
1) 4 &body
))
68 (defindent define-setf-expander
(4 (&whole
4 1 &rest
1) &body
))
69 (defindent define-setf-method
(4 (&whole
4 1 &rest
1) &body
))
70 (defindent define-symbol-macro
(4 &body
))
71 (defindent definternational
(4 &body
))
72 (defindent deflanguage
(4))
73 (defindent deflocalized
(4 4 &body
))
74 (defindent defmacro
(4 (&whole
4 1 &rest
1) &body
))
75 (defindent defmethod
lisp-indent-defmethod) ; default
76 (defindent defpackage
(4 &rest
2))
77 (defindent defparameter
(4 2 2)) ; default
78 ; FIXME: How to deal with both short and long forms of defsetf?
79 ;(defindent defsetf (4 (&whole 4 1 &rest 1) 2 &body))
80 ;(defindent defsetf (14 (&whole 14 1 &rest 1) (&whole 14 1 &rest 1) &body))
81 (defindent defstruct
((&whole
4 &rest
(&whole
2 &rest
1)) &rest
(&whole
2 &rest
1))) ; default
82 (defindent deftype
(9 (&whole
9 1 &rest
1) &body
))
83 (defindent defun
(7 (&whole
7 1 &rest
1) &body
))
84 (defindent defvar
(4 2 2)) ; default
85 (defindent destructuring-bind
((&whole
6 1 &rest
1) 4 &body
))
86 (defindent deutsch
(2 1 2 1 2))
87 (defindent do lisp-indent-do
) ; default
88 (defindent do
* lisp-indent-do
) ; default
89 (defindent do-all-symbols
((&whole
4 1 &rest
1) &body
))
90 (defindent do-external-symbols
((&whole
4 1 &rest
1) &body
))
91 (defindent do-symbols
((&whole
4 1 &rest
1) &body
))
92 (defindent dohash
((&whole
4 1 &rest
1) (&whole
4 1 &rest
1) &body
))
93 (defindent dolist
((&whole
4 1 1) &body
))
94 (defindent doseq
((&whole
4 1 1) &body
))
95 (defindent dotimes
((&whole
4 1 1) &body
))
96 (defindent ecase
(4 &rest
(&whole
2 2 2 2 2 2 2 2 2 2 2)))
97 (defindent english
(2 1 2 1 2))
98 (defindent etypecase
(4 &rest
(&whole
2 2 2 2 2 2 2 2 2 2 2)))
99 (defindent eval-when
(4 &body
)) ; default
100 (defindent exit-on-error
(&body
))
101 (defindent fcase
'(6 4 &rest
(&whole
2 &rest
1)))
102 (defindent flet
((&whole
4 &rest
(&whole
1 (&whole
4 1 &rest
1) &body
)) &body
))
103 (defindent formatter
(&body
))
104 (defindent francais
(2 1 2 1 2))
105 (defindent function
(&body
))
106 (defindent generic-flet
((&whole
4 &rest
(&whole
1 (&whole
4 1 &rest
1) &body
)) &body
))
107 (defindent generic-function
((&whole
4 1 &rest
1) &body
))
108 (defindent generic-labels
((&whole
4 &rest
(&whole
1 (&whole
4 1 &rest
1) &body
)) &body
))
110 (defindent handler-bind
(2 &body
))
111 (defindent handler-case
(2 &rest
(&whole
2 (&whole
4 1 &rest
1) &body
)))
112 ; CLISP source indents the two branchs of an 'if' form equally.
113 (defindent if
(4 2 2))
114 (defindent ignore-errors
(&body
))
115 (defindent in-package
(&body
))
116 (defindent incf
(2 2))
117 (defindent labels
((&whole
4 &rest
(&whole
1 (&whole
4 1 &rest
1) &body
)) &body
))
118 (defindent lambda
((&whole
4 1 &rest
1) &body
))
119 (defindent let
((&whole
4 &rest
(&whole
1 2 2)) &body
))
120 (defindent let
* ((&whole
4 &rest
(&whole
1 2 2)) &body
))
121 (defindent load-time-value
(&body
))
122 (defindent locally
(2 &body
))
123 ; CLISP sources don't use the "big" LOOP - its semantics is too unreliable.
124 (defindent loop
(&body
))
125 (defindent loop-finish
())
126 (defindent macrolet
((&whole
4 &rest
(&whole
1 (&whole
4 1 &rest
1) &body
)) &body
))
127 (defindent :method
((&whole
4 1 &rest
1) &body
)) ; for defgeneric etc.
128 (defindent muffle-cerrors
(&rest
2))
129 (defindent multiple-value-bind
((&whole
6 &rest
1) 4 2 &rest
2))
130 (defindent multiple-value-call
(4 2 &rest
2))
131 (defindent multiple-value-list
(2))
132 (defindent multiple-value-prog1
(2 &rest
2))
133 (defindent multiple-value-setq
(4 2)) ; default
134 (defindent nth-value
(2 2))
135 (defindent optimize
(&rest
2))
136 (defindent or
(&rest
2))
138 (defindent print-unreadable-object
((&whole
4 1 &rest
1) &body
))
139 (defindent prog
((&whole
4 1 &rest
1) &rest lisp-indent-tagbody
))
140 (defindent prog
* ((&whole
4 1 &rest
1) &rest lisp-indent-tagbody
))
141 (defindent prog1
(2 &body
))
142 (defindent prog2
(2 2 &body
))
143 (defindent progn
(&body
)) ; default
144 (defindent progv
(4 4 &body
)) ; default
145 (defindent psetf
(7 9 7 9 7 9 7 9 7 9 7 9 7 9 7 9 7 9 7 9 7))
146 (defindent psetq
(7 9 7 9 7 9 7 9 7 9 7 9 7 9 7 9 7 9 7 9 7))
147 (defindent push
(&body
))
148 (defindent pushnew
(&body
))
149 (defindent quote
(2))
150 (defindent remf
(2 2))
151 (defindent restart-bind
((&whole
4 &rest
1) &body
))
152 (defindent restart-case
(4 &rest
(&whole
2 (&whole
4 1 &rest
1) &body
)))
153 (defindent return
(&body
)) ; default
154 (defindent return-from
(2 &body
))
155 (defindent rotatef
(&body
))
156 (defindent setf
(6 8 6 8 6 8 6 8 6 8 6 8 6 8 6 8 6 8 6 8 6))
157 (defindent setq
(6 8 6 8 6 8 6 8 6 8 6 8 6 8 6 8 6 8 6 8 6))
158 (defindent :shadowing-import-from
(4 &rest
2))
159 (defindent shiftf
(&body
))
160 (defindent space
(2))
162 (defindent symbol-macrolet
((&whole
4 &rest
(&whole
1 2 &rest
2)) &body
))
163 (defindent tagbody lisp-indent-tagbody
) ; default
164 (defindent the
(4 2))
165 (defindent the-environment
())
166 (defindent throw
(4 &body
)) ; default
168 (defindent trace
(&body
))
169 (defindent typecase
(4 &rest
(&whole
2 2 2 2 2 2 2 2 2 2 2)))
170 (defindent unless
(4 &body
)) ; default
171 (defindent untrace
(&body
))
172 (defindent unwind-protect
(2 &body
))
173 (defindent when
(4 &body
)) ; default
174 (defindent with-accessors
((&whole
4 1 &rest
1) 4 &body
))
175 (defindent with-condition-restarts
(4 4 &body
))
176 (defindent with-hash-table-iterator
(4 &body
))
177 (defindent with-input-from-string
((&whole
4 1 &rest
1) &body
))
178 (defindent with-keyboard
(&body
))
179 (defindent with-open-file
((&whole
4 1 &rest
1) &body
))
180 (defindent with-open-stream
(4 &body
))
181 (defindent with-output-to-printer
((&whole
4 1 &rest
1) &body
))
182 (defindent with-output-to-string
((&whole
4 1 &rest
1) &body
))
183 (defindent with-package-iterator
((&whole
4 1 &rest
1) &body
))
184 (defindent with-restarts
((&whole
4 &rest
(&whole
2 (&whole
4 1 &rest
1) &body
)) &body
))
185 (defindent with-simple-restart
((&whole
4 1 &rest
1) &body
))
186 (defindent with-slots
((&whole
4 1 &rest
1) 4 &body
))
187 (defindent with-standard-io-syntax
(&body
))
188 (defindent without-floating-point-underflow
(&body
))
190 ;;; Permit the user to load this file using (require 'clisp-indent).
191 (provide 'clisp-indent
)