annotate lisp/modes/cl-indent.el @ 171:929b76928fce r20-3b12

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