annotate lisp/modes/cl-indent.el @ 39:06f275776fba

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