Mercurial > emacs
annotate lisp/emacs-lisp/cl-indent.el @ 108220:0b37f86b040e
Use define-minor-mode where applicable.
* mh-show.el (mh-showing-mode): Move function to mh-e.el.
* mh-e.el (mh-showing-mode):
* url-dired.el (url-dired-minor-mode):
* org-table.el (orgtbl-mode):
* view.el (view-mode):
* type-break.el (type-break-query-mode)
(type-break-mode-line-message-mode):
* textmodes/reftex.el (reftex-mode):
* term/vt100.el (vt100-wide-mode):
* tar-mode.el (tar-subfile-mode):
* savehist.el (savehist-mode):
* ibuf-ext.el (ibuffer-auto-mode):
* composite.el (auto-composition-mode):
* progmodes/vhdl-mode.el (vhdl-electric-mode, vhdl-stutter-mode):
Use define-minor-mode.
(vhdl-mode): Use static mode-line format.
(vhdl-mode-line-update): Delete.
(vhdl-create-mode-menu, vhdl-activate-customizations)
(vhdl-hs-minor-mode): Don't bother calling it.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Sun, 02 May 2010 22:29:46 -0400 |
parents | 1d1d5d9bd884 |
children | 280c8ae2476d 376148b31b5e |
rev | line source |
---|---|
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
257
diff
changeset
|
1 ;;; cl-indent.el --- enhanced lisp-indent mode |
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
257
diff
changeset
|
2 |
103498
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
3 ;; Copyright (C) 1987, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, |
106815 | 4 ;; 2008, 2009, 2010 Free Software Foundation, Inc. |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
5 |
14040 | 6 ;; Author: Richard Mlynarik <mly@eddie.mit.edu> |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
7 ;; Created: July 1987 |
845 | 8 ;; Maintainer: FSF |
9 ;; Keywords: lisp, tools | |
10 | |
257 | 11 ;; This file is part of GNU Emacs. |
12 | |
94655
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; GNU Emacs is free software: you can redistribute it and/or modify |
257 | 14 ;; it under the terms of the GNU General Public License as published by |
94655
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
15 ;; the Free Software Foundation, either version 3 of the License, or |
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
16 ;; (at your option) any later version. |
257 | 17 |
18 ;; GNU Emacs is distributed in the hope that it will be useful, | |
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 ;; GNU General Public License for more details. | |
22 | |
23 ;; You should have received a copy of the GNU General Public License | |
94655
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
257 | 25 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
26 ;;; Commentary: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
27 |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
28 ;; This package supplies a single entry point, common-lisp-indent-function, |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
29 ;; which performs indentation in the preferred style for Common Lisp code. |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
30 ;; To enable it: |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
31 ;; |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
32 ;; (setq lisp-indent-function 'common-lisp-indent-function) |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
33 |
257 | 34 ;;>> TODO |
35 ;; :foo | |
36 ;; bar | |
37 ;; :baz | |
38 ;; zap | |
39 ;; &key (like &body)?? | |
40 | |
41 ;; &rest 1 in lambda-lists doesn't work | |
42 ;; -- really want (foo bar | |
43 ;; baz) | |
44 ;; not (foo bar | |
45 ;; baz) | |
46 ;; Need something better than &rest for such cases | |
47 | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
48 ;;; Code: |
257 | 49 |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
50 (defgroup lisp-indent nil |
63972
d07b7088d847
(lisp-indent-maximum-backtracking): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
56736
diff
changeset
|
51 "Indentation in Lisp." |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
52 :group 'lisp) |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
53 |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
54 |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
55 (defcustom lisp-indent-maximum-backtracking 3 |
103513
93c102cc8dd2
Remove leading "*" from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
103498
diff
changeset
|
56 "Maximum depth to backtrack out from a sublist for structured indentation. |
63972
d07b7088d847
(lisp-indent-maximum-backtracking): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
56736
diff
changeset
|
57 If this variable is 0, no backtracking will occur and forms such as `flet' |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
58 may not be correctly indented." |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
59 :type 'integer |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
60 :group 'lisp-indent) |
257 | 61 |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
62 (defcustom lisp-tag-indentation 1 |
103513
93c102cc8dd2
Remove leading "*" from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
103498
diff
changeset
|
63 "Indentation of tags relative to containing list. |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
64 This variable is used by the function `lisp-indent-tagbody'." |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
65 :type 'integer |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
66 :group 'lisp-indent) |
257 | 67 |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
68 (defcustom lisp-tag-body-indentation 3 |
103513
93c102cc8dd2
Remove leading "*" from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
103498
diff
changeset
|
69 "Indentation of non-tagged lines relative to containing list. |
257 | 70 This variable is used by the function `lisp-indent-tagbody' to indent normal |
71 lines (lines without tags). | |
72 The indentation is relative to the indentation of the parenthesis enclosing | |
73 the special form. If the value is t, the body of tags will be indented | |
74 as a block at the same indentation as the first s-expression following | |
75 the tag. In this case, any forms before the first tag are indented | |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
76 by `lisp-body-indent'." |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
77 :type 'integer |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
78 :group 'lisp-indent) |
257 | 79 |
43859
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
80 (defcustom lisp-backquote-indentation t |
103513
93c102cc8dd2
Remove leading "*" from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
103498
diff
changeset
|
81 "Whether or not to indent backquoted lists as code. |
43859
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
82 If nil, indent backquoted lists as data, i.e., like quoted lists." |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
83 :type 'boolean |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
84 :group 'lisp-indent) |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
85 |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
86 |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
87 (defcustom lisp-loop-keyword-indentation 3 |
103513
93c102cc8dd2
Remove leading "*" from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
103498
diff
changeset
|
88 "Indentation of loop keywords in extended loop forms." |
43859
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
89 :type 'integer |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
90 :group 'lisp-indent) |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
91 |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
92 |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
93 (defcustom lisp-loop-forms-indentation 5 |
103513
93c102cc8dd2
Remove leading "*" from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
103498
diff
changeset
|
94 "Indentation of forms in extended loop forms." |
43859
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
95 :type 'integer |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
96 :group 'lisp-indent) |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
97 |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
98 |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
99 (defcustom lisp-simple-loop-indentation 3 |
103513
93c102cc8dd2
Remove leading "*" from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
103498
diff
changeset
|
100 "Indentation of forms in simple loop forms." |
43859
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
101 :type 'integer |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
102 :group 'lisp-indent) |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
103 |
257 | 104 |
103498
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
105 (defvar lisp-indent-defun-method '(4 &lambda &body) |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
106 "Indentation for function with `common-lisp-indent-function' property `defun'.") |
22212
b95ba3830bc9
(lisp-indent-error-function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
22180
diff
changeset
|
107 |
43859
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
108 |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
109 (defun extended-loop-p (loop-start) |
47298
c6dddb2746ee
* emacs-lisp/cl-indent.el (extended-loop-p): Doc fix.
John Paul Wallington <jpw@pobox.com>
parents:
45573
diff
changeset
|
110 "True if an extended loop form starts at LOOP-START." |
43859
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
111 (condition-case () |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
112 (save-excursion |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
113 (goto-char loop-start) |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
114 (forward-char 1) |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
115 (forward-sexp 2) |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
116 (backward-sexp 1) |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
117 (looking-at "\\sw")) |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
118 (error t))) |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
119 |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
120 |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
121 (defun common-lisp-loop-part-indentation (indent-point state) |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
122 "Compute the indentation of loop form constituents." |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
123 (let* ((loop-indentation (save-excursion |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
124 (goto-char (elt state 1)) |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
125 (current-column)))) |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
126 (goto-char indent-point) |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
127 (beginning-of-line) |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
128 (cond ((not (extended-loop-p (elt state 1))) |
43920
af0b9648d018
(common-lisp-loop-part-indentation):
Gerd Moellmann <gerd@gnu.org>
parents:
43859
diff
changeset
|
129 (+ loop-indentation lisp-simple-loop-indentation)) |
43859
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
130 ((looking-at "^\\s-*\\(:?\\sw+\\|;\\)") |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
131 (+ loop-indentation lisp-loop-keyword-indentation)) |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
132 (t |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
133 (+ loop-indentation lisp-loop-forms-indentation))))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47298
diff
changeset
|
134 |
43859
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
135 |
257 | 136 ;;;###autoload |
137 (defun common-lisp-indent-function (indent-point state) | |
103498
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
138 "Function to indent the arguments of a Lisp function call. |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
139 This is suitable for use as the value of the variable |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
140 `lisp-indent-function'. INDENT-POINT is the point at which the |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
141 indentation function is called, and STATE is the |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
142 `parse-partial-sexp' state at that position. Browse the |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
143 `lisp-indent' customize group for options affecting the behavior |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
144 of this function. |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
145 |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
146 If the indentation point is in a call to a Lisp function, that |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
147 function's common-lisp-indent-function property specifies how |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
148 this function should indent it. Possible values for this |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
149 property are: |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
150 |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
151 * defun, meaning indent according to `lisp-indent-defun-method'; |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
152 i.e., like (4 &lambda &body), as explained below. |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
153 |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
154 * any other symbol, meaning a function to call. The function should |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
155 take the arguments: PATH STATE INDENT-POINT SEXP-COLUMN NORMAL-INDENT. |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
156 PATH is a list of integers describing the position of point in terms of |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
157 list-structure with respect to the containing lists. For example, in |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
158 ((a b c (d foo) f) g), foo has a path of (0 3 1). In other words, |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
159 to reach foo take the 0th element of the outermost list, then |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
160 the 3rd element of the next list, and finally the 1st element. |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
161 STATE and INDENT-POINT are as in the arguments to |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
162 `common-lisp-indent-function'. SEXP-COLUMN is the column of |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
163 the open parenthesis of the innermost containing list. |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
164 NORMAL-INDENT is the column the indentation point was |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
165 originally in. This function should behave like `lisp-indent-259'. |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
166 |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
167 * an integer N, meaning indent the first N arguments like |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
168 function arguments, and any further arguments like a body. |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
169 This is equivalent to (4 4 ... &body). |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
170 |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
171 * a list. The list element in position M specifies how to indent the Mth |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
172 function argument. If there are fewer elements than function arguments, |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
173 the last list element applies to all remaining arguments. The accepted |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
174 list elements are: |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
175 |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
176 * nil, meaning the default indentation. |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
177 |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
178 * an integer, specifying an explicit indentation. |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
179 |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
180 * &lambda. Indent the argument (which may be a list) by 4. |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
181 |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
182 * &rest. When used, this must be the penultimate element. The |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
183 element after this one applies to all remaining arguments. |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
184 |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
185 * &body. This is equivalent to &rest lisp-body-indent, i.e., indent |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
186 all remaining elements by `lisp-body-indent'. |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
187 |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
188 * &whole. This must be followed by nil, an integer, or a |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
189 function symbol. This indentation is applied to the |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
190 associated argument, and as a base indent for all remaining |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
191 arguments. For example, an integer P means indent this |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
192 argument by P, and all remaining arguments by P, plus the |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
193 value specified by their associated list element. |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
194 |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
195 * a symbol. A function to call, with the 6 arguments specified above. |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
196 |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
197 * a list, with elements as described above. This applies when the |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
198 associated function argument is itself a list. Each element of the list |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
199 specifies how to indent the associated argument. |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
200 |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
201 For example, the function `case' has an indent property |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
202 \(4 &rest (&whole 2 &rest 1)), meaning: |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
203 * indent the first argument by 4. |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
204 * arguments after the first should be lists, and there may be any number |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
205 of them. The first list element has an offset of 2, all the rest |
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
206 have an offset of 2+1=3." |
43859
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
207 (if (save-excursion (goto-char (elt state 1)) |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
208 (looking-at "([Ll][Oo][Oo][Pp]")) |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
209 (common-lisp-loop-part-indentation indent-point state) |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
210 (common-lisp-indent-function-1 indent-point state))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47298
diff
changeset
|
211 |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47298
diff
changeset
|
212 |
43859
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
213 (defun common-lisp-indent-function-1 (indent-point state) |
257 | 214 (let ((normal-indent (current-column))) |
215 ;; Walk up list levels until we see something | |
216 ;; which does special things with subforms. | |
217 (let ((depth 0) | |
218 ;; Path describes the position of point in terms of | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
2307
diff
changeset
|
219 ;; list-structure with respect to containing lists. |
257 | 220 ;; `foo' has a path of (0 4 1) in `((a b c (d foo) f) g)' |
103498
4470991d3249
(lisp-indent-defun-method, common-lisp-indent-function): Add doc strings.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
221 ;; (Surely (0 3 1)?). |
257 | 222 (path ()) |
223 ;; set non-nil when somebody works out the indentation to use | |
224 calculated | |
45573
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
225 ;; If non-nil, this is an indentation to use |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
226 ;; if nothing else specifies it more firmly. |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
227 tentative-calculated |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
228 (last-point indent-point) |
257 | 229 ;; the position of the open-paren of the innermost containing list |
230 (containing-form-start (elt state 1)) | |
231 ;; the column of the above | |
232 sexp-column) | |
233 ;; Move to start of innermost containing list | |
234 (goto-char containing-form-start) | |
235 (setq sexp-column (current-column)) | |
43859
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
236 |
257 | 237 ;; Look over successively less-deep containing forms |
238 (while (and (not calculated) | |
239 (< depth lisp-indent-maximum-backtracking)) | |
240 (let ((containing-sexp (point))) | |
241 (forward-char 1) | |
242 (parse-partial-sexp (point) indent-point 1 t) | |
243 ;; Move to the car of the relevant containing form | |
45573
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
244 (let (tem function method tentative-defun) |
257 | 245 (if (not (looking-at "\\sw\\|\\s_")) |
246 ;; This form doesn't seem to start with a symbol | |
247 (setq function nil method nil) | |
248 (setq tem (point)) | |
249 (forward-sexp 1) | |
22858
77090a500417
(lisp-indent-defun-method): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
22756
diff
changeset
|
250 (setq function (downcase (buffer-substring-no-properties |
77090a500417
(lisp-indent-defun-method): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
22756
diff
changeset
|
251 tem (point)))) |
257 | 252 (goto-char tem) |
253 (setq tem (intern-soft function) | |
254 method (get tem 'common-lisp-indent-function)) | |
255 (cond ((and (null method) | |
256 (string-match ":[^:]+" function)) | |
257 ;; The pleblisp package feature | |
258 (setq function (substring function | |
259 (1+ (match-beginning 0))) | |
260 method (get (intern-soft function) | |
261 'common-lisp-indent-function))) | |
262 ((and (null method)) | |
263 ;; backwards compatibility | |
264 (setq method (get tem 'lisp-indent-function))))) | |
265 (let ((n 0)) | |
266 ;; How far into the containing form is the current form? | |
267 (if (< (point) indent-point) | |
268 (while (condition-case () | |
269 (progn | |
270 (forward-sexp 1) | |
271 (if (>= (point) indent-point) | |
272 nil | |
273 (parse-partial-sexp (point) | |
274 indent-point 1 t) | |
275 (setq n (1+ n)) | |
276 t)) | |
277 (error nil)))) | |
278 (setq path (cons n path))) | |
279 | |
280 ;; backwards compatibility. | |
281 (cond ((null function)) | |
282 ((null method) | |
22858
77090a500417
(lisp-indent-defun-method): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
22756
diff
changeset
|
283 (when (null (cdr path)) |
45573
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
284 ;; (package prefix was stripped off above) |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
285 (cond ((string-match "\\`def" |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
286 function) |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
287 (setq tentative-defun t)) |
55636
c2f8040b4ece
(common-lisp-indent-function-1): Indent "without-" forms just
Sam Steingold <sds@gnu.org>
parents:
52401
diff
changeset
|
288 ((string-match |
c2f8040b4ece
(common-lisp-indent-function-1): Indent "without-" forms just
Sam Steingold <sds@gnu.org>
parents:
52401
diff
changeset
|
289 (eval-when-compile |
c2f8040b4ece
(common-lisp-indent-function-1): Indent "without-" forms just
Sam Steingold <sds@gnu.org>
parents:
52401
diff
changeset
|
290 (concat "\\`\\(" |
c2f8040b4ece
(common-lisp-indent-function-1): Indent "without-" forms just
Sam Steingold <sds@gnu.org>
parents:
52401
diff
changeset
|
291 (regexp-opt '("with" "without" "do")) |
c2f8040b4ece
(common-lisp-indent-function-1): Indent "without-" forms just
Sam Steingold <sds@gnu.org>
parents:
52401
diff
changeset
|
292 "\\)-")) |
c2f8040b4ece
(common-lisp-indent-function-1): Indent "without-" forms just
Sam Steingold <sds@gnu.org>
parents:
52401
diff
changeset
|
293 function) |
45573
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
294 (setq method '(&lambda &body)))))) |
257 | 295 ;; backwards compatibility. Bletch. |
296 ((eq method 'defun) | |
22858
77090a500417
(lisp-indent-defun-method): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
22756
diff
changeset
|
297 (setq method lisp-indent-defun-method))) |
257 | 298 |
43859
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
299 (cond ((and (or (eq (char-after (1- containing-sexp)) ?\') |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
300 (and (not lisp-backquote-indentation) |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
301 (eq (char-after (1- containing-sexp)) ?\`))) |
26047
e6efd0ace0f3
(common-lisp-indent-function): Use `eq' instead of `eql'.
Gerd Moellmann <gerd@gnu.org>
parents:
23725
diff
changeset
|
302 (not (eq (char-after (- containing-sexp 2)) ?\#))) |
257 | 303 ;; No indentation for "'(...)" elements |
304 (setq calculated (1+ sexp-column))) | |
29797
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
305 ((or (eq (char-after (1- containing-sexp)) ?\,) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
306 (and (eq (char-after (1- containing-sexp)) ?\@) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
307 (eq (char-after (- containing-sexp 2)) ?\,))) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
308 ;; ",(...)" or ",@(...)" |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
309 (setq calculated normal-indent)) |
26047
e6efd0ace0f3
(common-lisp-indent-function): Use `eq' instead of `eql'.
Gerd Moellmann <gerd@gnu.org>
parents:
23725
diff
changeset
|
310 ((eq (char-after (1- containing-sexp)) ?\#) |
257 | 311 ;; "#(...)" |
312 (setq calculated (1+ sexp-column))) | |
45573
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
313 ((null method) |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
314 ;; If this looks like a call to a `def...' form, |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
315 ;; think about indenting it as one, but do it |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
316 ;; tentatively for cases like |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
317 ;; (flet ((defunp () |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
318 ;; nil))) |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
319 ;; Set both normal-indent and tentative-calculated. |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
320 ;; The latter ensures this value gets used |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
321 ;; if there are no relevant containing constructs. |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
322 ;; The former ensures this value gets used |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
323 ;; if there is a relevant containing construct |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
324 ;; but we are nested within the structure levels |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
325 ;; that it specifies indentation for. |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
326 (if tentative-defun |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
327 (setq tentative-calculated |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
328 (common-lisp-indent-call-method |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
329 function lisp-indent-defun-method |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
330 path state indent-point |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
331 sexp-column normal-indent) |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
332 normal-indent tentative-calculated))) |
257 | 333 ((integerp method) |
334 ;; convenient top-level hack. | |
335 ;; (also compatible with lisp-indent-function) | |
336 ;; The number specifies how many `distinguished' | |
337 ;; forms there are before the body starts | |
338 ;; Equivalent to (4 4 ... &body) | |
339 (setq calculated (cond ((cdr path) | |
340 normal-indent) | |
341 ((<= (car path) method) | |
342 ;; `distinguished' form | |
343 (list (+ sexp-column 4) | |
344 containing-form-start)) | |
345 ((= (car path) (1+ method)) | |
346 ;; first body form. | |
347 (+ sexp-column lisp-body-indent)) | |
348 (t | |
349 ;; other body form | |
350 normal-indent)))) | |
45573
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
351 (t |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
352 (setq calculated |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
353 (common-lisp-indent-call-method |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
354 function method path state indent-point |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
355 sexp-column normal-indent))))) |
257 | 356 (goto-char containing-sexp) |
357 (setq last-point containing-sexp) | |
22858
77090a500417
(lisp-indent-defun-method): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
22756
diff
changeset
|
358 (unless calculated |
45573
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
359 (condition-case () |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
360 (progn (backward-up-list 1) |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
361 (setq depth (1+ depth))) |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
362 (error (setq depth lisp-indent-maximum-backtracking)))))) |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
363 (or calculated tentative-calculated)))) |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
364 |
257 | 365 |
45573
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
366 (defun common-lisp-indent-call-method (function method path state indent-point |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
367 sexp-column normal-indent) |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
368 (let ((lisp-indent-error-function function)) |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
369 (if (symbolp method) |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
370 (funcall method |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
371 path state indent-point |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
372 sexp-column normal-indent) |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
373 (lisp-indent-259 method path state indent-point |
54fb43cbbd73
(common-lisp-indent-function-1):
Richard M. Stallman <rms@gnu.org>
parents:
43920
diff
changeset
|
374 sexp-column normal-indent)))) |
257 | 375 |
103513
93c102cc8dd2
Remove leading "*" from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
103498
diff
changeset
|
376 ;; Dynamically bound in common-lisp-indent-call-method. |
93c102cc8dd2
Remove leading "*" from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
103498
diff
changeset
|
377 (defvar lisp-indent-error-function) |
93c102cc8dd2
Remove leading "*" from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
103498
diff
changeset
|
378 |
257 | 379 (defun lisp-indent-report-bad-format (m) |
380 (error "%s has a badly-formed %s property: %s" | |
381 ;; Love those free variable references!! | |
22212
b95ba3830bc9
(lisp-indent-error-function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
22180
diff
changeset
|
382 lisp-indent-error-function 'common-lisp-indent-function m)) |
257 | 383 |
384 ;; Blame the crufty control structure on dynamic scoping | |
385 ;; -- not on me! | |
386 (defun lisp-indent-259 (method path state indent-point | |
387 sexp-column normal-indent) | |
388 (catch 'exit | |
389 (let ((p path) | |
390 (containing-form-start (elt state 1)) | |
391 n tem tail) | |
392 ;; Isn't tail-recursion wonderful? | |
393 (while p | |
394 ;; This while loop is for destructuring. | |
395 ;; p is set to (cdr p) each iteration. | |
396 (if (not (consp method)) (lisp-indent-report-bad-format method)) | |
397 (setq n (1- (car p)) | |
398 p (cdr p) | |
399 tail nil) | |
400 (while n | |
401 ;; This while loop is for advancing along a method | |
402 ;; until the relevant (possibly &rest/&body) pattern | |
403 ;; is reached. | |
404 ;; n is set to (1- n) and method to (cdr method) | |
405 ;; each iteration. | |
406 (setq tem (car method)) | |
407 | |
408 (or (eq tem 'nil) ;default indentation | |
29797
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
409 (eq tem '&lambda) ;lambda list |
257 | 410 (and (eq tem '&body) (null (cdr method))) |
411 (and (eq tem '&rest) | |
29797
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
412 (consp (cdr method)) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
413 (null (cddr method))) |
257 | 414 (integerp tem) ;explicit indentation specified |
415 (and (consp tem) ;destructuring | |
416 (eq (car tem) '&whole) | |
29797
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
417 (or (symbolp (cadr tem)) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
418 (integerp (cadr tem)))) |
257 | 419 (and (symbolp tem) ;a function to call to do the work. |
420 (null (cdr method))) | |
421 (lisp-indent-report-bad-format method)) | |
422 | |
423 (cond ((and tail (not (consp tem))) | |
424 ;; indent tail of &rest in same way as first elt of rest | |
425 (throw 'exit normal-indent)) | |
426 ((eq tem '&body) | |
427 ;; &body means (&rest <lisp-body-indent>) | |
428 (throw 'exit | |
429 (if (and (= n 0) ;first body form | |
430 (null p)) ;not in subforms | |
431 (+ sexp-column | |
432 lisp-body-indent) | |
433 normal-indent))) | |
434 ((eq tem '&rest) | |
435 ;; this pattern holds for all remaining forms | |
436 (setq tail (> n 0) | |
437 n 0 | |
438 method (cdr method))) | |
439 ((> n 0) | |
440 ;; try next element of pattern | |
441 (setq n (1- n) | |
442 method (cdr method)) | |
443 (if (< n 0) | |
444 ;; Too few elements in pattern. | |
445 (throw 'exit normal-indent))) | |
446 ((eq tem 'nil) | |
73497
c1427878fdcf
* emacs-lisp/cl-indent.el (lisp-indent-259): Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents:
73496
diff
changeset
|
447 (throw 'exit (if (consp normal-indent) |
c1427878fdcf
* emacs-lisp/cl-indent.el (lisp-indent-259): Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents:
73496
diff
changeset
|
448 normal-indent |
c1427878fdcf
* emacs-lisp/cl-indent.el (lisp-indent-259): Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents:
73496
diff
changeset
|
449 (list normal-indent containing-form-start)))) |
73496
f93751296dc3
* emacs-lisp/cl-indent.el (lisp-indent-259): Indent nil's in the
Chong Yidong <cyd@stupidchicken.com>
parents:
68648
diff
changeset
|
450 ((eq tem '&lambda) |
f93751296dc3
* emacs-lisp/cl-indent.el (lisp-indent-259): Indent nil's in the
Chong Yidong <cyd@stupidchicken.com>
parents:
68648
diff
changeset
|
451 (throw 'exit |
f93751296dc3
* emacs-lisp/cl-indent.el (lisp-indent-259): Indent nil's in the
Chong Yidong <cyd@stupidchicken.com>
parents:
68648
diff
changeset
|
452 (cond ((null p) |
f93751296dc3
* emacs-lisp/cl-indent.el (lisp-indent-259): Indent nil's in the
Chong Yidong <cyd@stupidchicken.com>
parents:
68648
diff
changeset
|
453 (list (+ sexp-column 4) containing-form-start)) |
f93751296dc3
* emacs-lisp/cl-indent.el (lisp-indent-259): Indent nil's in the
Chong Yidong <cyd@stupidchicken.com>
parents:
68648
diff
changeset
|
454 ((null (cdr p)) |
f93751296dc3
* emacs-lisp/cl-indent.el (lisp-indent-259): Indent nil's in the
Chong Yidong <cyd@stupidchicken.com>
parents:
68648
diff
changeset
|
455 (+ sexp-column 1)) |
f93751296dc3
* emacs-lisp/cl-indent.el (lisp-indent-259): Indent nil's in the
Chong Yidong <cyd@stupidchicken.com>
parents:
68648
diff
changeset
|
456 (t normal-indent)))) |
257 | 457 ((integerp tem) |
458 (throw 'exit | |
459 (if (null p) ;not in subforms | |
460 (list (+ sexp-column tem) containing-form-start) | |
461 normal-indent))) | |
462 ((symbolp tem) ;a function to call | |
463 (throw 'exit | |
464 (funcall tem path state indent-point | |
465 sexp-column normal-indent))) | |
466 (t | |
467 ;; must be a destructing frob | |
468 (if (not (null p)) | |
469 ;; descend | |
22858
77090a500417
(lisp-indent-defun-method): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
22756
diff
changeset
|
470 (setq method (cddr tem) |
257 | 471 n nil) |
22858
77090a500417
(lisp-indent-defun-method): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
22756
diff
changeset
|
472 (setq tem (cadr tem)) |
257 | 473 (throw 'exit |
474 (cond (tail | |
475 normal-indent) | |
476 ((eq tem 'nil) | |
477 (list normal-indent | |
478 containing-form-start)) | |
479 ((integerp tem) | |
480 (list (+ sexp-column tem) | |
481 containing-form-start)) | |
482 (t | |
483 (funcall tem path state indent-point | |
484 sexp-column normal-indent)))))))))))) | |
485 | |
486 (defun lisp-indent-tagbody (path state indent-point sexp-column normal-indent) | |
487 (if (not (null (cdr path))) | |
488 normal-indent | |
489 (save-excursion | |
490 (goto-char indent-point) | |
491 (beginning-of-line) | |
492 (skip-chars-forward " \t") | |
493 (list (cond ((looking-at "\\sw\\|\\s_") | |
494 ;; a tagbody tag | |
495 (+ sexp-column lisp-tag-indentation)) | |
496 ((integerp lisp-tag-body-indentation) | |
497 (+ sexp-column lisp-tag-body-indentation)) | |
498 ((eq lisp-tag-body-indentation 't) | |
499 (condition-case () | |
500 (progn (backward-sexp 1) (current-column)) | |
501 (error (1+ sexp-column)))) | |
502 (t (+ sexp-column lisp-body-indent))) | |
503 ; (cond ((integerp lisp-tag-body-indentation) | |
504 ; (+ sexp-column lisp-tag-body-indentation)) | |
505 ; ((eq lisp-tag-body-indentation 't) | |
506 ; normal-indent) | |
507 ; (t | |
508 ; (+ sexp-column lisp-body-indent))) | |
509 (elt state 1) | |
510 )))) | |
511 | |
512 (defun lisp-indent-do (path state indent-point sexp-column normal-indent) | |
513 (if (>= (car path) 3) | |
514 (let ((lisp-tag-body-indentation lisp-body-indent)) | |
515 (funcall (function lisp-indent-tagbody) | |
29797
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
516 path state indent-point sexp-column normal-indent)) |
257 | 517 (funcall (function lisp-indent-259) |
29797
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
518 '((&whole nil &rest |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
519 ;; the following causes weird indentation |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
520 ;;(&whole 1 1 2 nil) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
521 ) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
522 (&whole nil &rest 1)) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
523 path state indent-point sexp-column normal-indent))) |
257 | 524 |
43859
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
525 |
40952
2ca1b56f3bb1
Indent properly `generic-flet', `generic-labels', `with-accessors',
Sam Steingold <sds@gnu.org>
parents:
38826
diff
changeset
|
526 (defun lisp-indent-defmethod (path state indent-point sexp-column |
38826
f2ff22369238
(lisp-indent-defmethod): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
37764
diff
changeset
|
527 normal-indent) |
f2ff22369238
(lisp-indent-defmethod): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
37764
diff
changeset
|
528 "Indentation function defmethod." |
43859
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
529 (lisp-indent-259 (if (and (>= (car path) 3) |
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
530 (null (cdr path)) |
41256
4a78098c3bd7
(lisp-indent-defmethod): At first three elements, act like defun.
Richard M. Stallman <rms@gnu.org>
parents:
40952
diff
changeset
|
531 (save-excursion (goto-char (elt state 1)) |
4a78098c3bd7
(lisp-indent-defmethod): At first three elements, act like defun.
Richard M. Stallman <rms@gnu.org>
parents:
40952
diff
changeset
|
532 (forward-char 1) |
4a78098c3bd7
(lisp-indent-defmethod): At first three elements, act like defun.
Richard M. Stallman <rms@gnu.org>
parents:
40952
diff
changeset
|
533 (forward-sexp 3) |
4a78098c3bd7
(lisp-indent-defmethod): At first three elements, act like defun.
Richard M. Stallman <rms@gnu.org>
parents:
40952
diff
changeset
|
534 (backward-sexp) |
56736
3b66605ad268
(lisp-indent-defmethod): Correct
Eli Zaretskii <eliz@gnu.org>
parents:
55636
diff
changeset
|
535 (looking-at ":\\|\\sw+"))) |
38826
f2ff22369238
(lisp-indent-defmethod): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
37764
diff
changeset
|
536 '(4 4 (&whole 4 &rest 4) &body) |
f2ff22369238
(lisp-indent-defmethod): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
37764
diff
changeset
|
537 (get 'defun 'common-lisp-indent-function)) |
f2ff22369238
(lisp-indent-defmethod): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
37764
diff
changeset
|
538 path state indent-point sexp-column normal-indent)) |
f2ff22369238
(lisp-indent-defmethod): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
37764
diff
changeset
|
539 |
f2ff22369238
(lisp-indent-defmethod): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
37764
diff
changeset
|
540 |
257 | 541 (defun lisp-indent-function-lambda-hack (path state indent-point |
542 sexp-column normal-indent) | |
543 ;; indent (function (lambda () <newline> <body-forms>)) kludgily. | |
544 (if (or (cdr path) ; wtf? | |
545 (> (car path) 3)) | |
546 ;; line up under previous body form | |
547 normal-indent | |
548 ;; line up under function rather than under lambda in order to | |
549 ;; conserve horizontal space. (Which is what #' is for.) | |
550 (condition-case () | |
551 (save-excursion | |
552 (backward-up-list 2) | |
553 (forward-char 1) | |
554 (if (looking-at "\\(lisp:+\\)?function\\(\\Sw\\|\\S_\\)") | |
555 (+ lisp-body-indent -1 (current-column)) | |
556 (+ sexp-column lisp-body-indent))) | |
557 (error (+ sexp-column lisp-body-indent))))) | |
558 | |
43859
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
559 |
257 | 560 |
561 (let ((l '((block 1) | |
29797
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
562 (case (4 &rest (&whole 2 &rest 1))) |
103513
93c102cc8dd2
Remove leading "*" from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
103498
diff
changeset
|
563 (ccase . case) |
93c102cc8dd2
Remove leading "*" from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
103498
diff
changeset
|
564 (ecase . case) |
93c102cc8dd2
Remove leading "*" from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
103498
diff
changeset
|
565 (typecase . case) |
93c102cc8dd2
Remove leading "*" from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
103498
diff
changeset
|
566 (etypecase . case) |
93c102cc8dd2
Remove leading "*" from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
103498
diff
changeset
|
567 (ctypecase . case) |
29797
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
568 (catch 1) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
569 (cond (&rest (&whole 2 &rest 1))) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
570 (defvar (4 2 2)) |
30651
61c2f9fcb8f6
* emacs-lisp/cl-indent.el (toplevel): Indent `defclass',
Sam Steingold <sds@gnu.org>
parents:
29797
diff
changeset
|
571 (defclass (6 4 (&whole 2 &rest 1) (&whole 2 &rest 1))) |
29797
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
572 (defconstant . defvar) |
27231
e9725bb98b6e
Add defclass, define-condition, defmethod, symbol-macrolet.
Dave Love <fx@gnu.org>
parents:
26047
diff
changeset
|
573 (defcustom (4 2 2 2)) |
29797
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
574 (defparameter . defvar) |
30651
61c2f9fcb8f6
* emacs-lisp/cl-indent.el (toplevel): Indent `defclass',
Sam Steingold <sds@gnu.org>
parents:
29797
diff
changeset
|
575 (defconst . defcustom) |
61c2f9fcb8f6
* emacs-lisp/cl-indent.el (toplevel): Indent `defclass',
Sam Steingold <sds@gnu.org>
parents:
29797
diff
changeset
|
576 (define-condition . defclass) |
42252
63b6d0453539
(define-modify-macro): Better indent spec.
Richard M. Stallman <rms@gnu.org>
parents:
41256
diff
changeset
|
577 (define-modify-macro (4 &lambda &body)) |
29797
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
578 (defsetf (4 &lambda 4 &body)) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
579 (defun (4 &lambda &body)) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
580 (define-setf-method . defun) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
581 (define-setf-expander . defun) |
103513
93c102cc8dd2
Remove leading "*" from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
103498
diff
changeset
|
582 (defmacro . defun) |
93c102cc8dd2
Remove leading "*" from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
103498
diff
changeset
|
583 (defsubst . defun) |
93c102cc8dd2
Remove leading "*" from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
103498
diff
changeset
|
584 (deftype . defun) |
38826
f2ff22369238
(lisp-indent-defmethod): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
37764
diff
changeset
|
585 (defmethod lisp-indent-defmethod) |
29797
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
586 (defpackage (4 2)) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
587 (defstruct ((&whole 4 &rest (&whole 2 &rest 1)) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
588 &rest (&whole 2 &rest 1))) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
589 (destructuring-bind |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
590 ((&whole 6 &rest 1) 4 &body)) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
591 (do lisp-indent-do) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
592 (do* . do) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
593 (dolist ((&whole 4 2 1) &body)) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
594 (dotimes . dolist) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
595 (eval-when 1) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
596 (flet ((&whole 4 &rest (&whole 1 &lambda &body)) &body)) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
597 (labels . flet) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
598 (macrolet . flet) |
103513
93c102cc8dd2
Remove leading "*" from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
103498
diff
changeset
|
599 (generic-flet . flet) |
93c102cc8dd2
Remove leading "*" from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
103498
diff
changeset
|
600 (generic-labels . flet) |
22858
77090a500417
(lisp-indent-defun-method): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
22756
diff
changeset
|
601 (handler-case (4 &rest (&whole 2 &lambda &body))) |
22756
6103b46f200a
Indent `restart-case', `handler-bind' and `restart-bind' correctly.
Richard M. Stallman <rms@gnu.org>
parents:
22731
diff
changeset
|
602 (restart-case . handler-case) |
29797
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
603 ;; `else-body' style |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
604 (if (nil nil &body)) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
605 ;; single-else style (then and else equally indented) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
606 (if (&rest nil)) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
607 (lambda (&lambda &rest lisp-indent-function-lambda-hack)) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
608 (let ((&whole 4 &rest (&whole 1 1 2)) &body)) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
609 (let* . let) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
610 (compiler-let . let) ;barf |
103513
93c102cc8dd2
Remove leading "*" from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
103498
diff
changeset
|
611 (handler-bind . let) |
93c102cc8dd2
Remove leading "*" from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
103498
diff
changeset
|
612 (restart-bind . let) |
29797
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
613 (locally 1) |
43859
e8da4031d520
(lisp-loop-keyword-indentation)
Gerd Moellmann <gerd@gnu.org>
parents:
42252
diff
changeset
|
614 ;(loop lisp-indent-loop) |
37764
b1fec0dc2aa1
(toplevel): indent the :method sub-form of `defgeneric' correctly.
Sam Steingold <sds@gnu.org>
parents:
37389
diff
changeset
|
615 (:method (&lambda &body)) ; in `defgeneric' |
30651
61c2f9fcb8f6
* emacs-lisp/cl-indent.el (toplevel): Indent `defclass',
Sam Steingold <sds@gnu.org>
parents:
29797
diff
changeset
|
616 (multiple-value-bind ((&whole 6 &rest 1) 4 &body)) |
61c2f9fcb8f6
* emacs-lisp/cl-indent.el (toplevel): Indent `defclass',
Sam Steingold <sds@gnu.org>
parents:
29797
diff
changeset
|
617 (multiple-value-call (4 &body)) |
29797
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
618 (multiple-value-prog1 1) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
619 (multiple-value-setq (4 2)) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
620 (multiple-value-setf . multiple-value-setq) |
27872
277f4365f2fa
Indent `pprint-logical-block' properly.
Gerd Moellmann <gerd@gnu.org>
parents:
27802
diff
changeset
|
621 (pprint-logical-block (4 2)) |
29797
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
622 (print-unreadable-object ((&whole 4 1 &rest 1) &body)) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
623 ;; Combines the worst features of BLOCK, LET and TAGBODY |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
624 (prog (&lambda &rest lisp-indent-tagbody)) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
625 (prog* . prog) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
626 (prog1 1) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
627 (prog2 2) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
628 (progn 0) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
629 (progv (4 4 &body)) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
630 (return 0) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
631 (return-from (nil &body)) |
50700
ad311d8949c4
`symbol-macrolet' is similar to `let', not `multiple-value-bind'.
Sam Steingold <sds@gnu.org>
parents:
49598
diff
changeset
|
632 (symbol-macrolet . let) |
29797
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
633 (tagbody lisp-indent-tagbody) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
634 (throw 1) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
635 (unless 1) |
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
636 (unwind-protect (5 &body)) |
22180
485917486caf
Indent `with-standard-io-syntax' correctly.
Richard M. Stallman <rms@gnu.org>
parents:
21750
diff
changeset
|
637 (when 1) |
40952
2ca1b56f3bb1
Indent properly `generic-flet', `generic-labels', `with-accessors',
Sam Steingold <sds@gnu.org>
parents:
38826
diff
changeset
|
638 (with-accessors . multiple-value-bind) |
2ca1b56f3bb1
Indent properly `generic-flet', `generic-labels', `with-accessors',
Sam Steingold <sds@gnu.org>
parents:
38826
diff
changeset
|
639 (with-condition-restarts . multiple-value-bind) |
23725
222d58586999
indent `with-output-to-string' as a CL
Karl Heuer <kwzh@gnu.org>
parents:
22913
diff
changeset
|
640 (with-output-to-string (4 2)) |
30651
61c2f9fcb8f6
* emacs-lisp/cl-indent.el (toplevel): Indent `defclass',
Sam Steingold <sds@gnu.org>
parents:
29797
diff
changeset
|
641 (with-slots . multiple-value-bind) |
22180
485917486caf
Indent `with-standard-io-syntax' correctly.
Richard M. Stallman <rms@gnu.org>
parents:
21750
diff
changeset
|
642 (with-standard-io-syntax (2))))) |
40952
2ca1b56f3bb1
Indent properly `generic-flet', `generic-labels', `with-accessors',
Sam Steingold <sds@gnu.org>
parents:
38826
diff
changeset
|
643 (dolist (el l) |
2ca1b56f3bb1
Indent properly `generic-flet', `generic-labels', `with-accessors',
Sam Steingold <sds@gnu.org>
parents:
38826
diff
changeset
|
644 (put (car el) 'common-lisp-indent-function |
2ca1b56f3bb1
Indent properly `generic-flet', `generic-labels', `with-accessors',
Sam Steingold <sds@gnu.org>
parents:
38826
diff
changeset
|
645 (if (symbolp (cdr el)) |
2ca1b56f3bb1
Indent properly `generic-flet', `generic-labels', `with-accessors',
Sam Steingold <sds@gnu.org>
parents:
38826
diff
changeset
|
646 (get (cdr el) 'common-lisp-indent-function) |
2ca1b56f3bb1
Indent properly `generic-flet', `generic-labels', `with-accessors',
Sam Steingold <sds@gnu.org>
parents:
38826
diff
changeset
|
647 (car (cdr el)))))) |
257 | 648 |
649 | |
650 ;(defun foo (x) | |
651 ; (tagbody | |
652 ; foo | |
653 ; (bar) | |
654 ; baz | |
655 ; (when (losing) | |
656 ; (with-big-loser | |
657 ; (yow) | |
658 ; ((lambda () | |
659 ; foo) | |
660 ; big))) | |
661 ; (flet ((foo (bar baz zap) | |
662 ; (zip)) | |
663 ; (zot () | |
664 ; quux)) | |
665 ; (do () | |
666 ; ((lose) | |
667 ; (foo 1)) | |
668 ; (quux) | |
669 ; foo | |
670 ; (lose)) | |
671 ; (cond ((x) | |
672 ; (win 1 2 | |
673 ; (foo))) | |
674 ; (t | |
675 ; (lose | |
676 ; 3)))))) | |
29797
3bf98b923af0
handle print-unreadable-object
Sam Steingold <sds@gnu.org>
parents:
27872
diff
changeset
|
677 |
257 | 678 |
679 ;(put 'while 'common-lisp-indent-function 1) | |
680 ;(put 'defwrapper'common-lisp-indent-function ...) | |
681 ;(put 'def 'common-lisp-indent-function ...) | |
682 ;(put 'defflavor 'common-lisp-indent-function ...) | |
683 ;(put 'defsubst 'common-lisp-indent-function ...) | |
684 | |
685 ;(put 'with-restart 'common-lisp-indent-function '((1 4 ((* 1))) (2 &body))) | |
686 ;(put 'restart-case 'common-lisp-indent-function '((1 4) (* 2 ((0 1) (* 1))))) | |
34187
e2fb02d21aee
Remove erroneous spec for condition-case.
Dave Love <fx@gnu.org>
parents:
30651
diff
changeset
|
687 ;(put 'define-condition 'common-lisp-indent-function '((1 6) (2 6 ((&whole 1))) (3 4 ((&whole 1))) (4 &body))) |
257 | 688 ;(put 'with-condition-handler 'common-lisp-indent-function '((1 4 ((* 1))) (2 &body))) |
689 ;(put 'condition-case 'common-lisp-indent-function '((1 4) (* 2 ((0 1) (1 3) (2 &body))))) | |
34187
e2fb02d21aee
Remove erroneous spec for condition-case.
Dave Love <fx@gnu.org>
parents:
30651
diff
changeset
|
690 ;(put 'defclass 'common-lisp-indent-function '((&whole 2 &rest (&whole 2 &rest 1) &rest (&whole 2 &rest 1))) |
e2fb02d21aee
Remove erroneous spec for condition-case.
Dave Love <fx@gnu.org>
parents:
30651
diff
changeset
|
691 ;(put 'defgeneric 'common-lisp-indent-function 'defun) |
257 | 692 |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79704
diff
changeset
|
693 ;; arch-tag: 7914d50f-92ec-4476-93fc-0f043a380e03 |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
257
diff
changeset
|
694 ;;; cl-indent.el ends here |