Commit | Line | Data |
---|---|---|
c0274f38 ER |
1 | ;;; cl-indent.el --- enhanced lisp-indent mode |
2 | ||
3731a850 | 3 | ;; Copyright (C) 1987, 2000, 2001, 2002, 2003, 2004, |
ceb4c4d3 | 4 | ;; 2005, 2006 Free Software Foundation, Inc. |
e41b2db1 | 5 | |
a7acbbe4 | 6 | ;; Author: Richard Mlynarik <mly@eddie.mit.edu> |
e41b2db1 | 7 | ;; Created: July 1987 |
e5167999 | 8 | ;; Maintainer: FSF |
fd7fa35a | 9 | ;; Keywords: lisp, tools |
e5167999 | 10 | |
745bc783 JB |
11 | ;; This file is part of GNU Emacs. |
12 | ||
13 | ;; GNU Emacs is free software; you can redistribute it and/or modify | |
14 | ;; it under the terms of the GNU General Public License as published by | |
e5167999 | 15 | ;; the Free Software Foundation; either version 2, or (at your option) |
745bc783 JB |
16 | ;; any later version. |
17 | ||
18 | ;; GNU Emacs is distributed in the hope that it will be useful, | |
19 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 | ;; GNU General Public License for more details. | |
22 | ||
23 | ;; You should have received a copy of the GNU General Public License | |
b578f267 | 24 | ;; along with GNU Emacs; see the file COPYING. If not, write to the |
3a35cf56 LK |
25 | ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
26 | ;; Boston, MA 02110-1301, USA. | |
745bc783 | 27 | |
e5167999 ER |
28 | ;;; Commentary: |
29 | ||
e41b2db1 ER |
30 | ;; This package supplies a single entry point, common-lisp-indent-function, |
31 | ;; which performs indentation in the preferred style for Common Lisp code. | |
32 | ;; To enable it: | |
33 | ;; | |
34 | ;; (setq lisp-indent-function 'common-lisp-indent-function) | |
35 | ||
745bc783 JB |
36 | ;;>> TODO |
37 | ;; :foo | |
38 | ;; bar | |
39 | ;; :baz | |
40 | ;; zap | |
41 | ;; &key (like &body)?? | |
42 | ||
43 | ;; &rest 1 in lambda-lists doesn't work | |
44 | ;; -- really want (foo bar | |
45 | ;; baz) | |
46 | ;; not (foo bar | |
47 | ;; baz) | |
48 | ;; Need something better than &rest for such cases | |
49 | ||
e5167999 | 50 | ;;; Code: |
745bc783 | 51 | |
fcad5199 | 52 | (defgroup lisp-indent nil |
ec0421f3 | 53 | "Indentation in Lisp." |
fcad5199 RS |
54 | :group 'lisp) |
55 | ||
56 | ||
57 | (defcustom lisp-indent-maximum-backtracking 3 | |
745bc783 | 58 | "*Maximum depth to backtrack out from a sublist for structured indentation. |
ec0421f3 | 59 | If this variable is 0, no backtracking will occur and forms such as `flet' |
fcad5199 RS |
60 | may not be correctly indented." |
61 | :type 'integer | |
62 | :group 'lisp-indent) | |
745bc783 | 63 | |
fcad5199 | 64 | (defcustom lisp-tag-indentation 1 |
745bc783 | 65 | "*Indentation of tags relative to containing list. |
fcad5199 RS |
66 | This variable is used by the function `lisp-indent-tagbody'." |
67 | :type 'integer | |
68 | :group 'lisp-indent) | |
745bc783 | 69 | |
fcad5199 | 70 | (defcustom lisp-tag-body-indentation 3 |
745bc783 JB |
71 | "*Indentation of non-tagged lines relative to containing list. |
72 | This variable is used by the function `lisp-indent-tagbody' to indent normal | |
73 | lines (lines without tags). | |
74 | The indentation is relative to the indentation of the parenthesis enclosing | |
75 | the special form. If the value is t, the body of tags will be indented | |
76 | as a block at the same indentation as the first s-expression following | |
77 | the tag. In this case, any forms before the first tag are indented | |
fcad5199 RS |
78 | by `lisp-body-indent'." |
79 | :type 'integer | |
80 | :group 'lisp-indent) | |
745bc783 | 81 | |
59e0f579 GM |
82 | (defcustom lisp-backquote-indentation t |
83 | "*Whether or not to indent backquoted lists as code. | |
84 | If nil, indent backquoted lists as data, i.e., like quoted lists." | |
85 | :type 'boolean | |
86 | :group 'lisp-indent) | |
87 | ||
88 | ||
89 | (defcustom lisp-loop-keyword-indentation 3 | |
90 | "*Indentation of loop keywords in extended loop forms." | |
91 | :type 'integer | |
92 | :group 'lisp-indent) | |
93 | ||
94 | ||
95 | (defcustom lisp-loop-forms-indentation 5 | |
96 | "*Indentation of forms in extended loop forms." | |
97 | :type 'integer | |
98 | :group 'lisp-indent) | |
99 | ||
100 | ||
101 | (defcustom lisp-simple-loop-indentation 3 | |
102 | "*Indentation of forms in simple loop forms." | |
103 | :type 'integer | |
104 | :group 'lisp-indent) | |
105 | ||
745bc783 | 106 | \f |
bf92b5a4 | 107 | (defvar lisp-indent-error-function) |
bbf1ae49 | 108 | (defvar lisp-indent-defun-method '(4 &lambda &body)) |
bf92b5a4 | 109 | |
59e0f579 GM |
110 | |
111 | (defun extended-loop-p (loop-start) | |
cb0fd101 | 112 | "True if an extended loop form starts at LOOP-START." |
59e0f579 GM |
113 | (condition-case () |
114 | (save-excursion | |
115 | (goto-char loop-start) | |
116 | (forward-char 1) | |
117 | (forward-sexp 2) | |
118 | (backward-sexp 1) | |
119 | (looking-at "\\sw")) | |
120 | (error t))) | |
121 | ||
122 | ||
123 | (defun common-lisp-loop-part-indentation (indent-point state) | |
124 | "Compute the indentation of loop form constituents." | |
125 | (let* ((loop-indentation (save-excursion | |
126 | (goto-char (elt state 1)) | |
127 | (current-column)))) | |
128 | (goto-char indent-point) | |
129 | (beginning-of-line) | |
130 | (cond ((not (extended-loop-p (elt state 1))) | |
93097873 | 131 | (+ loop-indentation lisp-simple-loop-indentation)) |
59e0f579 GM |
132 | ((looking-at "^\\s-*\\(:?\\sw+\\|;\\)") |
133 | (+ loop-indentation lisp-loop-keyword-indentation)) | |
134 | (t | |
135 | (+ loop-indentation lisp-loop-forms-indentation))))) | |
a1506d29 | 136 | |
59e0f579 | 137 | |
745bc783 JB |
138 | ;;;###autoload |
139 | (defun common-lisp-indent-function (indent-point state) | |
59e0f579 GM |
140 | (if (save-excursion (goto-char (elt state 1)) |
141 | (looking-at "([Ll][Oo][Oo][Pp]")) | |
142 | (common-lisp-loop-part-indentation indent-point state) | |
143 | (common-lisp-indent-function-1 indent-point state))) | |
a1506d29 JB |
144 | |
145 | ||
59e0f579 | 146 | (defun common-lisp-indent-function-1 (indent-point state) |
745bc783 JB |
147 | (let ((normal-indent (current-column))) |
148 | ;; Walk up list levels until we see something | |
149 | ;; which does special things with subforms. | |
150 | (let ((depth 0) | |
151 | ;; Path describes the position of point in terms of | |
eb8c3be9 | 152 | ;; list-structure with respect to containing lists. |
745bc783 JB |
153 | ;; `foo' has a path of (0 4 1) in `((a b c (d foo) f) g)' |
154 | (path ()) | |
155 | ;; set non-nil when somebody works out the indentation to use | |
156 | calculated | |
f620e5e2 RS |
157 | ;; If non-nil, this is an indentation to use |
158 | ;; if nothing else specifies it more firmly. | |
159 | tentative-calculated | |
160 | (last-point indent-point) | |
745bc783 JB |
161 | ;; the position of the open-paren of the innermost containing list |
162 | (containing-form-start (elt state 1)) | |
163 | ;; the column of the above | |
164 | sexp-column) | |
165 | ;; Move to start of innermost containing list | |
166 | (goto-char containing-form-start) | |
167 | (setq sexp-column (current-column)) | |
59e0f579 | 168 | |
745bc783 JB |
169 | ;; Look over successively less-deep containing forms |
170 | (while (and (not calculated) | |
171 | (< depth lisp-indent-maximum-backtracking)) | |
172 | (let ((containing-sexp (point))) | |
173 | (forward-char 1) | |
174 | (parse-partial-sexp (point) indent-point 1 t) | |
175 | ;; Move to the car of the relevant containing form | |
f620e5e2 | 176 | (let (tem function method tentative-defun) |
745bc783 JB |
177 | (if (not (looking-at "\\sw\\|\\s_")) |
178 | ;; This form doesn't seem to start with a symbol | |
179 | (setq function nil method nil) | |
180 | (setq tem (point)) | |
181 | (forward-sexp 1) | |
bbf1ae49 RS |
182 | (setq function (downcase (buffer-substring-no-properties |
183 | tem (point)))) | |
745bc783 JB |
184 | (goto-char tem) |
185 | (setq tem (intern-soft function) | |
186 | method (get tem 'common-lisp-indent-function)) | |
187 | (cond ((and (null method) | |
188 | (string-match ":[^:]+" function)) | |
189 | ;; The pleblisp package feature | |
190 | (setq function (substring function | |
191 | (1+ (match-beginning 0))) | |
192 | method (get (intern-soft function) | |
193 | 'common-lisp-indent-function))) | |
194 | ((and (null method)) | |
195 | ;; backwards compatibility | |
196 | (setq method (get tem 'lisp-indent-function))))) | |
197 | (let ((n 0)) | |
198 | ;; How far into the containing form is the current form? | |
199 | (if (< (point) indent-point) | |
200 | (while (condition-case () | |
201 | (progn | |
202 | (forward-sexp 1) | |
203 | (if (>= (point) indent-point) | |
204 | nil | |
205 | (parse-partial-sexp (point) | |
206 | indent-point 1 t) | |
207 | (setq n (1+ n)) | |
208 | t)) | |
209 | (error nil)))) | |
210 | (setq path (cons n path))) | |
211 | ||
212 | ;; backwards compatibility. | |
213 | (cond ((null function)) | |
214 | ((null method) | |
bbf1ae49 | 215 | (when (null (cdr path)) |
f620e5e2 RS |
216 | ;; (package prefix was stripped off above) |
217 | (cond ((string-match "\\`def" | |
218 | function) | |
219 | (setq tentative-defun t)) | |
410019e5 SS |
220 | ((string-match |
221 | (eval-when-compile | |
222 | (concat "\\`\\(" | |
223 | (regexp-opt '("with" "without" "do")) | |
224 | "\\)-")) | |
225 | function) | |
f620e5e2 | 226 | (setq method '(&lambda &body)))))) |
745bc783 JB |
227 | ;; backwards compatibility. Bletch. |
228 | ((eq method 'defun) | |
bbf1ae49 | 229 | (setq method lisp-indent-defun-method))) |
745bc783 | 230 | |
59e0f579 GM |
231 | (cond ((and (or (eq (char-after (1- containing-sexp)) ?\') |
232 | (and (not lisp-backquote-indentation) | |
233 | (eq (char-after (1- containing-sexp)) ?\`))) | |
893d4ef0 | 234 | (not (eq (char-after (- containing-sexp 2)) ?\#))) |
745bc783 JB |
235 | ;; No indentation for "'(...)" elements |
236 | (setq calculated (1+ sexp-column))) | |
5d80cc9c SS |
237 | ((or (eq (char-after (1- containing-sexp)) ?\,) |
238 | (and (eq (char-after (1- containing-sexp)) ?\@) | |
239 | (eq (char-after (- containing-sexp 2)) ?\,))) | |
240 | ;; ",(...)" or ",@(...)" | |
241 | (setq calculated normal-indent)) | |
893d4ef0 | 242 | ((eq (char-after (1- containing-sexp)) ?\#) |
745bc783 JB |
243 | ;; "#(...)" |
244 | (setq calculated (1+ sexp-column))) | |
f620e5e2 RS |
245 | ((null method) |
246 | ;; If this looks like a call to a `def...' form, | |
247 | ;; think about indenting it as one, but do it | |
248 | ;; tentatively for cases like | |
249 | ;; (flet ((defunp () | |
250 | ;; nil))) | |
251 | ;; Set both normal-indent and tentative-calculated. | |
252 | ;; The latter ensures this value gets used | |
253 | ;; if there are no relevant containing constructs. | |
254 | ;; The former ensures this value gets used | |
255 | ;; if there is a relevant containing construct | |
256 | ;; but we are nested within the structure levels | |
257 | ;; that it specifies indentation for. | |
258 | (if tentative-defun | |
259 | (setq tentative-calculated | |
260 | (common-lisp-indent-call-method | |
261 | function lisp-indent-defun-method | |
262 | path state indent-point | |
263 | sexp-column normal-indent) | |
264 | normal-indent tentative-calculated))) | |
745bc783 JB |
265 | ((integerp method) |
266 | ;; convenient top-level hack. | |
267 | ;; (also compatible with lisp-indent-function) | |
268 | ;; The number specifies how many `distinguished' | |
269 | ;; forms there are before the body starts | |
270 | ;; Equivalent to (4 4 ... &body) | |
271 | (setq calculated (cond ((cdr path) | |
272 | normal-indent) | |
273 | ((<= (car path) method) | |
274 | ;; `distinguished' form | |
275 | (list (+ sexp-column 4) | |
276 | containing-form-start)) | |
277 | ((= (car path) (1+ method)) | |
278 | ;; first body form. | |
279 | (+ sexp-column lisp-body-indent)) | |
280 | (t | |
281 | ;; other body form | |
282 | normal-indent)))) | |
f620e5e2 RS |
283 | (t |
284 | (setq calculated | |
285 | (common-lisp-indent-call-method | |
286 | function method path state indent-point | |
287 | sexp-column normal-indent))))) | |
745bc783 JB |
288 | (goto-char containing-sexp) |
289 | (setq last-point containing-sexp) | |
bbf1ae49 | 290 | (unless calculated |
f620e5e2 RS |
291 | (condition-case () |
292 | (progn (backward-up-list 1) | |
293 | (setq depth (1+ depth))) | |
294 | (error (setq depth lisp-indent-maximum-backtracking)))))) | |
295 | (or calculated tentative-calculated)))) | |
296 | ||
297 | ||
298 | (defun common-lisp-indent-call-method (function method path state indent-point | |
299 | sexp-column normal-indent) | |
300 | (let ((lisp-indent-error-function function)) | |
301 | (if (symbolp method) | |
302 | (funcall method | |
303 | path state indent-point | |
304 | sexp-column normal-indent) | |
305 | (lisp-indent-259 method path state indent-point | |
306 | sexp-column normal-indent)))) | |
745bc783 JB |
307 | |
308 | (defun lisp-indent-report-bad-format (m) | |
309 | (error "%s has a badly-formed %s property: %s" | |
310 | ;; Love those free variable references!! | |
bf92b5a4 | 311 | lisp-indent-error-function 'common-lisp-indent-function m)) |
745bc783 JB |
312 | |
313 | ;; Blame the crufty control structure on dynamic scoping | |
314 | ;; -- not on me! | |
315 | (defun lisp-indent-259 (method path state indent-point | |
316 | sexp-column normal-indent) | |
317 | (catch 'exit | |
318 | (let ((p path) | |
319 | (containing-form-start (elt state 1)) | |
320 | n tem tail) | |
321 | ;; Isn't tail-recursion wonderful? | |
322 | (while p | |
323 | ;; This while loop is for destructuring. | |
324 | ;; p is set to (cdr p) each iteration. | |
325 | (if (not (consp method)) (lisp-indent-report-bad-format method)) | |
326 | (setq n (1- (car p)) | |
327 | p (cdr p) | |
328 | tail nil) | |
329 | (while n | |
330 | ;; This while loop is for advancing along a method | |
331 | ;; until the relevant (possibly &rest/&body) pattern | |
332 | ;; is reached. | |
333 | ;; n is set to (1- n) and method to (cdr method) | |
334 | ;; each iteration. | |
335 | (setq tem (car method)) | |
336 | ||
337 | (or (eq tem 'nil) ;default indentation | |
5d80cc9c | 338 | (eq tem '&lambda) ;lambda list |
745bc783 JB |
339 | (and (eq tem '&body) (null (cdr method))) |
340 | (and (eq tem '&rest) | |
5d80cc9c SS |
341 | (consp (cdr method)) |
342 | (null (cddr method))) | |
745bc783 JB |
343 | (integerp tem) ;explicit indentation specified |
344 | (and (consp tem) ;destructuring | |
345 | (eq (car tem) '&whole) | |
5d80cc9c SS |
346 | (or (symbolp (cadr tem)) |
347 | (integerp (cadr tem)))) | |
745bc783 JB |
348 | (and (symbolp tem) ;a function to call to do the work. |
349 | (null (cdr method))) | |
350 | (lisp-indent-report-bad-format method)) | |
351 | ||
352 | (cond ((and tail (not (consp tem))) | |
353 | ;; indent tail of &rest in same way as first elt of rest | |
354 | (throw 'exit normal-indent)) | |
355 | ((eq tem '&body) | |
356 | ;; &body means (&rest <lisp-body-indent>) | |
357 | (throw 'exit | |
358 | (if (and (= n 0) ;first body form | |
359 | (null p)) ;not in subforms | |
360 | (+ sexp-column | |
361 | lisp-body-indent) | |
362 | normal-indent))) | |
363 | ((eq tem '&rest) | |
364 | ;; this pattern holds for all remaining forms | |
365 | (setq tail (> n 0) | |
366 | n 0 | |
367 | method (cdr method))) | |
368 | ((> n 0) | |
369 | ;; try next element of pattern | |
370 | (setq n (1- n) | |
371 | method (cdr method)) | |
372 | (if (< n 0) | |
373 | ;; Too few elements in pattern. | |
374 | (throw 'exit normal-indent))) | |
375 | ((eq tem 'nil) | |
bec9dc7b CY |
376 | (throw 'exit normal-indent)) |
377 | ((eq tem '&lambda) | |
378 | (throw 'exit | |
379 | (cond ((null p) | |
380 | (list (+ sexp-column 4) containing-form-start)) | |
381 | ((null (cdr p)) | |
382 | (+ sexp-column 1)) | |
383 | (t normal-indent)))) | |
745bc783 JB |
384 | ((integerp tem) |
385 | (throw 'exit | |
386 | (if (null p) ;not in subforms | |
387 | (list (+ sexp-column tem) containing-form-start) | |
388 | normal-indent))) | |
389 | ((symbolp tem) ;a function to call | |
390 | (throw 'exit | |
391 | (funcall tem path state indent-point | |
392 | sexp-column normal-indent))) | |
393 | (t | |
394 | ;; must be a destructing frob | |
395 | (if (not (null p)) | |
396 | ;; descend | |
bbf1ae49 | 397 | (setq method (cddr tem) |
745bc783 | 398 | n nil) |
bbf1ae49 | 399 | (setq tem (cadr tem)) |
745bc783 JB |
400 | (throw 'exit |
401 | (cond (tail | |
402 | normal-indent) | |
403 | ((eq tem 'nil) | |
404 | (list normal-indent | |
405 | containing-form-start)) | |
406 | ((integerp tem) | |
407 | (list (+ sexp-column tem) | |
408 | containing-form-start)) | |
409 | (t | |
410 | (funcall tem path state indent-point | |
411 | sexp-column normal-indent)))))))))))) | |
412 | \f | |
413 | (defun lisp-indent-tagbody (path state indent-point sexp-column normal-indent) | |
414 | (if (not (null (cdr path))) | |
415 | normal-indent | |
416 | (save-excursion | |
417 | (goto-char indent-point) | |
418 | (beginning-of-line) | |
419 | (skip-chars-forward " \t") | |
420 | (list (cond ((looking-at "\\sw\\|\\s_") | |
421 | ;; a tagbody tag | |
422 | (+ sexp-column lisp-tag-indentation)) | |
423 | ((integerp lisp-tag-body-indentation) | |
424 | (+ sexp-column lisp-tag-body-indentation)) | |
425 | ((eq lisp-tag-body-indentation 't) | |
426 | (condition-case () | |
427 | (progn (backward-sexp 1) (current-column)) | |
428 | (error (1+ sexp-column)))) | |
429 | (t (+ sexp-column lisp-body-indent))) | |
430 | ; (cond ((integerp lisp-tag-body-indentation) | |
431 | ; (+ sexp-column lisp-tag-body-indentation)) | |
432 | ; ((eq lisp-tag-body-indentation 't) | |
433 | ; normal-indent) | |
434 | ; (t | |
435 | ; (+ sexp-column lisp-body-indent))) | |
436 | (elt state 1) | |
437 | )))) | |
438 | ||
439 | (defun lisp-indent-do (path state indent-point sexp-column normal-indent) | |
440 | (if (>= (car path) 3) | |
441 | (let ((lisp-tag-body-indentation lisp-body-indent)) | |
442 | (funcall (function lisp-indent-tagbody) | |
5d80cc9c | 443 | path state indent-point sexp-column normal-indent)) |
745bc783 | 444 | (funcall (function lisp-indent-259) |
5d80cc9c SS |
445 | '((&whole nil &rest |
446 | ;; the following causes weird indentation | |
447 | ;;(&whole 1 1 2 nil) | |
448 | ) | |
449 | (&whole nil &rest 1)) | |
450 | path state indent-point sexp-column normal-indent))) | |
745bc783 | 451 | |
59e0f579 | 452 | |
e7c8c428 | 453 | (defun lisp-indent-defmethod (path state indent-point sexp-column |
ec69d5ec GM |
454 | normal-indent) |
455 | "Indentation function defmethod." | |
59e0f579 GM |
456 | (lisp-indent-259 (if (and (>= (car path) 3) |
457 | (null (cdr path)) | |
c2988498 RS |
458 | (save-excursion (goto-char (elt state 1)) |
459 | (forward-char 1) | |
460 | (forward-sexp 3) | |
461 | (backward-sexp) | |
3166fce6 | 462 | (looking-at ":\\|\\sw+"))) |
ec69d5ec GM |
463 | '(4 4 (&whole 4 &rest 4) &body) |
464 | (get 'defun 'common-lisp-indent-function)) | |
465 | path state indent-point sexp-column normal-indent)) | |
466 | ||
467 | ||
745bc783 JB |
468 | (defun lisp-indent-function-lambda-hack (path state indent-point |
469 | sexp-column normal-indent) | |
470 | ;; indent (function (lambda () <newline> <body-forms>)) kludgily. | |
471 | (if (or (cdr path) ; wtf? | |
472 | (> (car path) 3)) | |
473 | ;; line up under previous body form | |
474 | normal-indent | |
475 | ;; line up under function rather than under lambda in order to | |
476 | ;; conserve horizontal space. (Which is what #' is for.) | |
477 | (condition-case () | |
478 | (save-excursion | |
479 | (backward-up-list 2) | |
480 | (forward-char 1) | |
481 | (if (looking-at "\\(lisp:+\\)?function\\(\\Sw\\|\\S_\\)") | |
482 | (+ lisp-body-indent -1 (current-column)) | |
483 | (+ sexp-column lisp-body-indent))) | |
484 | (error (+ sexp-column lisp-body-indent))))) | |
485 | ||
59e0f579 | 486 | |
745bc783 JB |
487 | \f |
488 | (let ((l '((block 1) | |
5d80cc9c SS |
489 | (case (4 &rest (&whole 2 &rest 1))) |
490 | (ccase . case) (ecase . case) | |
5d80cc9c SS |
491 | (typecase . case) (etypecase . case) (ctypecase . case) |
492 | (catch 1) | |
493 | (cond (&rest (&whole 2 &rest 1))) | |
494 | (defvar (4 2 2)) | |
5e9e032a | 495 | (defclass (6 4 (&whole 2 &rest 1) (&whole 2 &rest 1))) |
5d80cc9c | 496 | (defconstant . defvar) |
2ac6f2c8 | 497 | (defcustom (4 2 2 2)) |
5d80cc9c | 498 | (defparameter . defvar) |
5e9e032a SS |
499 | (defconst . defcustom) |
500 | (define-condition . defclass) | |
b6f053c6 | 501 | (define-modify-macro (4 &lambda &body)) |
5d80cc9c SS |
502 | (defsetf (4 &lambda 4 &body)) |
503 | (defun (4 &lambda &body)) | |
504 | (define-setf-method . defun) | |
505 | (define-setf-expander . defun) | |
506 | (defmacro . defun) (defsubst . defun) (deftype . defun) | |
ec69d5ec | 507 | (defmethod lisp-indent-defmethod) |
5d80cc9c SS |
508 | (defpackage (4 2)) |
509 | (defstruct ((&whole 4 &rest (&whole 2 &rest 1)) | |
510 | &rest (&whole 2 &rest 1))) | |
511 | (destructuring-bind | |
512 | ((&whole 6 &rest 1) 4 &body)) | |
513 | (do lisp-indent-do) | |
514 | (do* . do) | |
515 | (dolist ((&whole 4 2 1) &body)) | |
516 | (dotimes . dolist) | |
517 | (eval-when 1) | |
518 | (flet ((&whole 4 &rest (&whole 1 &lambda &body)) &body)) | |
519 | (labels . flet) | |
520 | (macrolet . flet) | |
e7c8c428 | 521 | (generic-flet . flet) (generic-labels . flet) |
bbf1ae49 | 522 | (handler-case (4 &rest (&whole 2 &lambda &body))) |
09a4d958 | 523 | (restart-case . handler-case) |
5d80cc9c SS |
524 | ;; `else-body' style |
525 | (if (nil nil &body)) | |
526 | ;; single-else style (then and else equally indented) | |
527 | (if (&rest nil)) | |
528 | (lambda (&lambda &rest lisp-indent-function-lambda-hack)) | |
529 | (let ((&whole 4 &rest (&whole 1 1 2)) &body)) | |
530 | (let* . let) | |
531 | (compiler-let . let) ;barf | |
09a4d958 | 532 | (handler-bind . let) (restart-bind . let) |
5d80cc9c | 533 | (locally 1) |
59e0f579 | 534 | ;(loop lisp-indent-loop) |
2180ea97 | 535 | (:method (&lambda &body)) ; in `defgeneric' |
5e9e032a SS |
536 | (multiple-value-bind ((&whole 6 &rest 1) 4 &body)) |
537 | (multiple-value-call (4 &body)) | |
5d80cc9c SS |
538 | (multiple-value-prog1 1) |
539 | (multiple-value-setq (4 2)) | |
540 | (multiple-value-setf . multiple-value-setq) | |
7dd21017 | 541 | (pprint-logical-block (4 2)) |
5d80cc9c SS |
542 | (print-unreadable-object ((&whole 4 1 &rest 1) &body)) |
543 | ;; Combines the worst features of BLOCK, LET and TAGBODY | |
544 | (prog (&lambda &rest lisp-indent-tagbody)) | |
545 | (prog* . prog) | |
546 | (prog1 1) | |
547 | (prog2 2) | |
548 | (progn 0) | |
549 | (progv (4 4 &body)) | |
550 | (return 0) | |
551 | (return-from (nil &body)) | |
10b97bf7 | 552 | (symbol-macrolet . let) |
5d80cc9c SS |
553 | (tagbody lisp-indent-tagbody) |
554 | (throw 1) | |
555 | (unless 1) | |
556 | (unwind-protect (5 &body)) | |
f0d527fc | 557 | (when 1) |
e7c8c428 SS |
558 | (with-accessors . multiple-value-bind) |
559 | (with-condition-restarts . multiple-value-bind) | |
44c705d4 | 560 | (with-output-to-string (4 2)) |
5e9e032a | 561 | (with-slots . multiple-value-bind) |
f0d527fc | 562 | (with-standard-io-syntax (2))))) |
e7c8c428 SS |
563 | (dolist (el l) |
564 | (put (car el) 'common-lisp-indent-function | |
565 | (if (symbolp (cdr el)) | |
566 | (get (cdr el) 'common-lisp-indent-function) | |
567 | (car (cdr el)))))) | |
745bc783 JB |
568 | |
569 | \f | |
570 | ;(defun foo (x) | |
571 | ; (tagbody | |
572 | ; foo | |
573 | ; (bar) | |
574 | ; baz | |
575 | ; (when (losing) | |
576 | ; (with-big-loser | |
577 | ; (yow) | |
578 | ; ((lambda () | |
579 | ; foo) | |
580 | ; big))) | |
581 | ; (flet ((foo (bar baz zap) | |
582 | ; (zip)) | |
583 | ; (zot () | |
584 | ; quux)) | |
585 | ; (do () | |
586 | ; ((lose) | |
587 | ; (foo 1)) | |
588 | ; (quux) | |
589 | ; foo | |
590 | ; (lose)) | |
591 | ; (cond ((x) | |
592 | ; (win 1 2 | |
593 | ; (foo))) | |
594 | ; (t | |
595 | ; (lose | |
596 | ; 3)))))) | |
5d80cc9c | 597 | |
745bc783 JB |
598 | |
599 | ;(put 'while 'common-lisp-indent-function 1) | |
600 | ;(put 'defwrapper'common-lisp-indent-function ...) | |
601 | ;(put 'def 'common-lisp-indent-function ...) | |
602 | ;(put 'defflavor 'common-lisp-indent-function ...) | |
603 | ;(put 'defsubst 'common-lisp-indent-function ...) | |
604 | ||
605 | ;(put 'with-restart 'common-lisp-indent-function '((1 4 ((* 1))) (2 &body))) | |
606 | ;(put 'restart-case 'common-lisp-indent-function '((1 4) (* 2 ((0 1) (* 1))))) | |
968880c4 | 607 | ;(put 'define-condition 'common-lisp-indent-function '((1 6) (2 6 ((&whole 1))) (3 4 ((&whole 1))) (4 &body))) |
745bc783 JB |
608 | ;(put 'with-condition-handler 'common-lisp-indent-function '((1 4 ((* 1))) (2 &body))) |
609 | ;(put 'condition-case 'common-lisp-indent-function '((1 4) (* 2 ((0 1) (1 3) (2 &body))))) | |
968880c4 DL |
610 | ;(put 'defclass 'common-lisp-indent-function '((&whole 2 &rest (&whole 2 &rest 1) &rest (&whole 2 &rest 1))) |
611 | ;(put 'defgeneric 'common-lisp-indent-function 'defun) | |
745bc783 | 612 | |
ab5796a9 | 613 | ;;; arch-tag: 7914d50f-92ec-4476-93fc-0f043a380e03 |
c0274f38 | 614 | ;;; cl-indent.el ends here |