annotate lisp/modes/cl-indent.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children ac2d302a0011
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;; Lisp mode, and its idiosyncratic commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; Copyright (C) 1987, 1993 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Written by Richard Mlynarik July 1987
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; along with XEmacs; see the file COPYING. If not, write to the Free
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;>> TODO
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; :foo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; bar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; :baz
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;; zap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; &key (like &body)??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; &rest 1 in lambda-lists doesn't work
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; -- really want (foo bar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; baz)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; not (foo bar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; baz)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; Need something better than &rest for such cases
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;; Hairy lisp indentation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (defvar lisp-indent-maximum-backtracking 3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 "*Maximum depth to backtrack out from a sublist for structured indentation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 If this variable is 0, no backtracking will occur and forms such as flet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 may not be correctly indented.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (defvar lisp-tag-indentation 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 "*Indentation of tags relative to containing list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 This variable is used by the function lisp-indent-tagbody.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (defvar lisp-tag-body-indentation 3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 "*Indentation of non-tagged lines relative to containing list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 This variable is used by the function lisp-indent-tagbody to indent normal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 lines (lines without tags).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 The indentation is relative to the indentation of the parenthesis enclosing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 he special form. If the value is t, the body of tags will be indented
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 as a block at the same indentation as the first s-expression following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 the tag. In this case, any forms before the first tag are indented
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 by lisp-body-indent.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (defun common-lisp-indent-function (indent-point state)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (let ((normal-indent (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;; Walk up list levels until we see something
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;; which does special things with subforms.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (let ((depth 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;; Path describes the position of point in terms of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;; list-structure with respect to contining lists.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;; `foo' has a path of (0 4 1) in `((a b c (d foo) f) g)'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (path ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;; set non-nil when somebody works out the indentation to use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 calculated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (last-point indent-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;; the position of the open-paren of the innermost containing list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (containing-form-start (elt state 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;; the column of the above
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 sexp-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;; Move to start of innermost containing list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (goto-char containing-form-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (setq sexp-column (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;; Look over successively less-deep containing forms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (while (and (not calculated)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (< depth lisp-indent-maximum-backtracking))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (let ((containing-sexp (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (parse-partial-sexp (point) indent-point 1 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;; Move to the car of the relevant containing form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (let (tem function method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (if (not (looking-at "\\sw\\|\\s_"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;; This form doesn't seem to start with a symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (setq function nil method nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (setq tem (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (forward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (setq function (downcase (buffer-substring tem (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (goto-char tem)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (setq tem (intern-soft function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 method (get tem 'common-lisp-indent-function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (cond ((and (null method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (string-match ":[^:]+" function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;; The pleblisp package feature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (setq function (substring function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (1+ (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 method (get (intern-soft function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 'common-lisp-indent-function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ((and (null method))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;; backwards compatibility
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (setq method (get tem 'lisp-indent-function)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (let ((n 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;; How far into the containing form is the current form?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (if (< (point) indent-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (while (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (forward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (if (>= (point) indent-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (parse-partial-sexp (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 indent-point 1 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (setq n (1+ n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (error nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (setq path (cons n path)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ;; backwards compatibility.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (cond ((null function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ((null method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (if (null (cdr path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ;; (package prefix was stripped off above)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (setq method (cond ((string-match "\\`def"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 '(4 (&whole 4 &rest 1) &body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ((string-match "\\`\\(with\\|do\\)-"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 '(4 &body))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;; backwards compatibility. Bletch.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ((eq method 'defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (setq method '(4 (&whole 4 &rest 1) &body))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (cond ((and (memq (char-after (1- containing-sexp)) '(?\' ?\`))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (not (eq (char-after (- containing-sexp 2)) ?\#)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ;; No indentation for "'(...)" elements
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (setq calculated (1+ sexp-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ((or (eq (char-after (1- containing-sexp)) ?\,)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (and (eq (char-after (1- containing-sexp)) ?\@)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (eq (char-after (- containing-sexp 2)) ?\,)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ;; ",(...)" or ",@(...)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (setq calculated normal-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ((eq (char-after (1- containing-sexp)) ?\#)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;; "#(...)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (setq calculated (1+ sexp-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ((null method))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 ((integerp method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ;; convenient top-level hack.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 ;; (also compatible with lisp-indent-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ;; The number specifies how many `distinguished'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ;; forms there are before the body starts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 ;; Equivalent to (4 4 ... &body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (setq calculated (cond ((cdr path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 normal-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ((<= (car path) method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ;; `distinguished' form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (list (+ sexp-column 4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 containing-form-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ((= (car path) (1+ method))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ;; first body form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (+ sexp-column lisp-body-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ;; other body form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 normal-indent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ((symbolp method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (setq calculated (funcall method
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 path state indent-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 sexp-column normal-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (setq calculated (lisp-indent-259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 method path state indent-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 sexp-column normal-indent)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (goto-char containing-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (setq last-point containing-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (if (not calculated)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (progn (backward-up-list 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (setq depth (1+ depth)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (error (setq depth lisp-indent-maximum-backtracking))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 calculated)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (defun lisp-indent-report-bad-format (m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (error "%s has a badly-formed %s property: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ;; Love them free variable references!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 function 'common-lisp-indent-function m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ;; Blame the crufty control structure on dynamic scoping
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ;; -- not on me!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (defun lisp-indent-259 (method path state indent-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 sexp-column normal-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (catch 'exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (let ((p path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (containing-form-start (elt state 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 n tem tail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ;; Isn't tail-recursion wonderful?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (while p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ;; This while loop is for destructuring.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 ;; p is set to (cdr p) each iteration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (if (not (consp method)) (lisp-indent-report-bad-format method))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (setq n (1- (car p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 p (cdr p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 tail nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (while n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ;; This while loop is for advancing along a method
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 ;; until the relevant (possibly &rest/&body) pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ;; is reached.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ;; n is set to (1- n) and method to (cdr method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 ;; each iteration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 ; (message "trying %s for %s %s" method p function) (sit-for 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (setq tem (car method))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (or (eq tem 'nil) ;default indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 ; (eq tem '&lambda) ;abbrev for (&whole 4 (&rest 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (and (eq tem '&body) (null (cdr method)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (and (eq tem '&rest)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (consp (cdr method)) (null (cdr (cdr method))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (integerp tem) ;explicit indentation specified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (and (consp tem) ;destructuring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (eq (car tem) '&whole)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (or (symbolp (car (cdr tem)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (integerp (car (cdr tem)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (and (symbolp tem) ;a function to call to do the work.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (null (cdr method)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (lisp-indent-report-bad-format method))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (cond ((and tail (not (consp tem)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 ;; indent tail of &rest in same way as first elt of rest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (throw 'exit normal-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ((eq tem '&body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 ;; &body means (&rest <lisp-body-indent>)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (throw 'exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (if (and (= n 0) ;first body form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (null p)) ;not in subforms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (+ sexp-column
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 lisp-body-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 normal-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 ((eq tem '&rest)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 ;; this pattern holds for all remaining forms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (setq tail (> n 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 n 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 method (cdr method)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 ((> n 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 ;; try next element of pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (setq n (1- n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 method (cdr method))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (if (< n 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 ;; Too few elements in pattern.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (throw 'exit normal-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 ((eq tem 'nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (throw 'exit (list normal-indent containing-form-start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 ; ((eq tem '&lambda)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 ; ;; abbrev for (&whole 4 &rest 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 ; (throw 'exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 ; (cond ((null p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 ; (list (+ sexp-column 4) containing-form-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 ; ((null (cdr p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 ; (+ sexp-column 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 ; (t normal-indent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 ((integerp tem)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (throw 'exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (if (null p) ;not in subforms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (list (+ sexp-column tem) containing-form-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 normal-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 ((symbolp tem) ;a function to call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (throw 'exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (funcall tem path state indent-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 sexp-column normal-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 ;; must be a destructing frob
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (if (not (null p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 ;; descend
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (setq method (cdr (cdr tem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 n nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (setq tem (car (cdr tem)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (throw 'exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (cond (tail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 normal-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 ((eq tem 'nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (list normal-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 containing-form-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 ((integerp tem)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (list (+ sexp-column tem)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 containing-form-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (funcall tem path state indent-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 sexp-column normal-indent))))))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (defun lisp-indent-tagbody (path state indent-point sexp-column normal-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (if (not (null (cdr path)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 normal-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (goto-char indent-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (list (cond ((looking-at "\\sw\\|\\s_")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 ;; a tagbody tag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (+ sexp-column lisp-tag-indentation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 ((integerp lisp-tag-body-indentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (+ sexp-column lisp-tag-body-indentation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 ((eq lisp-tag-body-indentation 't)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (progn (backward-sexp 1) (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (error (1+ sexp-column))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (t (+ sexp-column lisp-body-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 ; (cond ((integerp lisp-tag-body-indentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 ; (+ sexp-column lisp-tag-body-indentation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 ; ((eq lisp-tag-body-indentation 't)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 ; normal-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 ; (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 ; (+ sexp-column lisp-body-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (elt state 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (defun lisp-indent-do (path state indent-point sexp-column normal-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (if (>= (car path) 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (let ((lisp-tag-body-indentation lisp-body-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (funcall (function lisp-indent-tagbody)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 path state indent-point sexp-column normal-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (funcall (function lisp-indent-259)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 '((&whole nil &rest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 ;; the following causes wierd indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 ;;(&whole 1 1 2 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (&whole nil &rest 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 path state indent-point sexp-column normal-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (defun lisp-indent-function-lambda-hack (path state indent-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 sexp-column normal-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 ;; indent (function (lambda () <newline> <body-forms>)) kludgily.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (if (or (cdr path) ; wtf?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (> (car path) 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 ;; line up under previous body form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 normal-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 ;; line up under function rather than under lambda in order to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 ;; conserve horizontal space. (Which is what #' is for.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (backward-up-list 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (if (looking-at "\\(lisp:+\\)?function\\(\\Sw\\|\\S_\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (+ lisp-body-indent -1 (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (+ sexp-column lisp-body-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (error (+ sexp-column lisp-body-indent)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (defun lisp-indent-defmethod (path state indent-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 sexp-column normal-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 ;; Look for a method combination specifier...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (let* ((combined (if (and (>= (car path) 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (null (cdr path)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (goto-char (car (cdr state)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (forward-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (forward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (forward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (forward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (backward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (if (looking-at ":")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (method (if combined
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 '(4 4 (&whole 4 &rest 1) &body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 '(4 (&whole 4 &rest 1) &body))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (funcall (function lisp-indent-259)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 method
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 path state indent-point sexp-column normal-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (let ((l '((block 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (catch 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (case (4 &rest (&whole 2 &rest 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (ccase . case) (ecase . case)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (typecase . case) (etypecase . case) (ctypecase . case)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (catch 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (cond (&rest (&whole 2 &rest 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (block 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (defvar (4 2 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (defconstant . defvar) (defparameter . defvar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (define-modify-macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (4 &body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (define-setf-method
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (4 (&whole 4 &rest 1) &body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (defsetf (4 (&whole 4 &rest 1) 4 &body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (defun (4 (&whole 4 &rest 1) &body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (defmacro . defun) (deftype . defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (defmethod lisp-indent-defmethod)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (defstruct ((&whole 4 &rest (&whole 2 &rest 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 &rest (&whole 2 &rest 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (destructuring-bind
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 ((&whole 6 &rest 1) 4 &body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (do lisp-indent-do)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (do* . do)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (dolist ((&whole 4 2 1) &body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (dotimes . dolist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (eval-when 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (flet ((&whole 4 &rest (&whole 1 (&whole 4 &rest 1) &body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 &body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (labels . flet)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (macrolet . flet)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 ;; `else-body' style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (if (nil nil &body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 ;; single-else style (then and else equally indented)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (if (&rest nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 ;(lambda ((&whole 4 &rest 1) &body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (lambda ((&whole 4 &rest 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 &rest lisp-indent-function-lambda-hack))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (let ((&whole 4 &rest (&whole 1 1 2)) &body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (let* . let)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (compiler-let . let) ;barf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (locally 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 ;(loop ...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (multiple-value-bind
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 ((&whole 6 &rest 1) 4 &body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (multiple-value-call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (4 &body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (multiple-value-list 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (multiple-value-prog1 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (multiple-value-setq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (4 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 ;; Combines the worst features of BLOCK, LET and TAGBODY
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (prog ((&whole 4 &rest 1) &rest lisp-indent-tagbody))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (prog* . prog)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (prog1 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (prog2 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (progn 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (progv (4 4 &body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (return 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (return-from (nil &body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (tagbody lisp-indent-tagbody)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (throw 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (unless 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (5 &body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (when 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (while l
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (put (car (car l)) 'common-lisp-indent-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (if (symbolp (cdr (car l)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (get (cdr (car l)) 'common-lisp-indent-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (car (cdr (car l)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (setq l (cdr l))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 ;(defun foo (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 ; (tagbody
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 ; foo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 ; (bar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 ; baz
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 ; (when (losing)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 ; (with-big-loser
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 ; (yow)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 ; ((lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 ; foo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 ; big)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 ; (flet ((foo (bar baz zap)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 ; (zip))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 ; (zot ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 ; quux))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 ; (do ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 ; ((lose)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 ; (foo 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 ; (quux)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 ; foo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 ; (lose))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 ; (cond ((x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 ; (win 1 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 ; (foo)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 ; (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 ; (lose
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 ; 3))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 ;(put 'while 'common-lisp-indent-function 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 ;(put 'defwrapper'common-lisp-indent-function ...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 ;(put 'def 'common-lisp-indent-function ...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 ;(put 'defflavor 'common-lisp-indent-function ...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 ;(put 'defsubst 'common-lisp-indent-function ...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 ;(put 'with-restart 'common-lisp-indent-function '((1 4 ((* 1))) (2 &body)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 ;(put 'restart-case 'common-lisp-indent-function '((1 4) (* 2 ((0 1) (* 1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 ;(put 'define-condition 'common-lisp-indent-function '((1 6) (2 6 ((* 1))) (3 4 ((* 1))) (4 &body)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 ;(put 'with-condition-handler 'common-lisp-indent-function '((1 4 ((* 1))) (2 &body)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 ;(put 'condition-case 'common-lisp-indent-function '((1 4) (* 2 ((0 1) (1 3) (2 &body)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 ;;;; Turn it on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 ;(setq lisp-indent-function 'common-lisp-indent-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 ;; To disable this stuff, (setq lisp-indent-function 'lisp-indent-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490