1 ;;; cl-specs.el --- Edebug specs for cl.el -*- no-byte-compile: t -*-
3 ;; Copyright (C) 1993, 2001, 2002, 2003, 2004, 2005,
4 ;; 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
5 ;; Author: Daniel LaLiberte <liberte@holonexus.org>
6 ;; Keywords: lisp, tools, maint
9 ;; cl-specs.el|Daniel LaLiberte|liberte@holonexus.org
10 ;; |Edebug specs for cl.el
12 ;; This file is part of GNU Emacs.
14 ;; GNU Emacs is free software: you can redistribute it and/or modify
15 ;; it under the terms of the GNU General Public License as published by
16 ;; the Free Software Foundation, either version 3 of the License, or
17 ;; (at your option) any later version.
19 ;; GNU Emacs is distributed in the hope that it will be useful,
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;; GNU General Public License for more details.
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
29 ;; These specs are to be used with edebug.el version 3.3 or later and
30 ;; cl.el version 2.03 or later, by Dave Gillespie <daveg@synaptics.com>.
32 ;; This file need not be byte-compiled, but it shouldn't hurt.
37 ;; Do the above provide before the following require.
38 ;; Otherwise if you load this before edebug if cl is already loaded
39 ;; an infinite loading loop would occur.
44 (def-edebug-spec block
(symbolp body
))
45 (def-edebug-spec return
(&optional form
))
46 (def-edebug-spec return-from
(symbolp &optional form
))
50 (def-edebug-spec case
(form &rest
(sexp body
)))
51 (def-edebug-spec ecase case
)
53 ((&rest
&or symbolp
(symbolp &optional form form
))
55 cl-declarations body
))
56 (def-edebug-spec do
* do
)
57 (def-edebug-spec dolist
58 ((symbolp form
&optional form
) cl-declarations body
))
59 (def-edebug-spec dotimes dolist
)
60 (def-edebug-spec do-symbols
61 ((symbolp &optional form form
) cl-declarations body
))
62 (def-edebug-spec do-all-symbols
63 ((symbolp &optional form
) cl-declarations body
))
67 (def-edebug-spec multiple-value-list
(form))
68 (def-edebug-spec multiple-value-call
(function-form body
))
69 (def-edebug-spec multiple-value-bind
70 ((&rest symbolp
) form cl-declarations body
))
71 (def-edebug-spec multiple-value-setq
((&rest symbolp
) form
))
72 (def-edebug-spec multiple-value-prog1
(form body
))
76 (def-edebug-spec lexical-let let
)
77 (def-edebug-spec lexical-let
* let
)
79 (def-edebug-spec psetq setq
)
80 (def-edebug-spec progv
(form form body
))
82 (def-edebug-spec flet
((&rest
(defun*)) cl-declarations body
))
83 (def-edebug-spec labels flet
)
85 (def-edebug-spec macrolet
86 ((&rest
(&define name
(&rest arg
) cl-declarations-or-string def-body
))
87 cl-declarations body
))
89 (def-edebug-spec symbol-macrolet
90 ((&rest
(symbol sexp
)) cl-declarations body
))
92 (def-edebug-spec destructuring-bind
93 (&define cl-macro-list def-form cl-declarations def-body
))
97 (def-edebug-spec setf
(&rest
[place form
])) ;; sexp is not specific enough
98 (def-edebug-spec psetf setf
)
100 (def-edebug-spec letf
;; *not* available in Common Lisp
101 ((&rest
(gate place
&optional form
))
103 (def-edebug-spec letf
* letf
)
106 (def-edebug-spec defsetf
108 [&or
[symbolp
&optional stringp
]
109 [cl-lambda-list
(symbolp)]]
110 cl-declarations-or-string def-body
))
112 (def-edebug-spec define-setf-method
113 (&define name cl-lambda-list cl-declarations-or-string def-body
))
115 (def-edebug-spec define-modify-macro
116 (&define name cl-lambda-list
;; should exclude &key
117 symbolp
&optional stringp
))
119 (def-edebug-spec callf
(function* place
&rest form
))
120 (def-edebug-spec callf2
(function* form place
&rest form
))
122 ;; Other operations on places
124 (def-edebug-spec remf
(place form
))
126 (def-edebug-spec incf
(place &optional form
))
127 (def-edebug-spec decf incf
)
128 (def-edebug-spec push
(form place
)) ; different for CL
129 (def-edebug-spec pushnew
131 &or
[[&or
":test" ":test-not" ":key"] function-form
]
133 (def-edebug-spec pop
(place)) ; different for CL
135 (def-edebug-spec shiftf
(&rest place
)) ;; really [&rest place] form
136 (def-edebug-spec rotatef
(&rest place
))
139 ;; Functions with function args. These are only useful if the
140 ;; function arg is quoted with ' instead of function.
142 (def-edebug-spec some
(function-form form
&rest form
))
143 (def-edebug-spec every some
)
144 (def-edebug-spec notany some
)
145 (def-edebug-spec notevery some
)
149 (def-edebug-spec map
(form function-form form
&rest form
))
150 (def-edebug-spec maplist
(function-form form
&rest form
))
151 (def-edebug-spec mapc maplist
)
152 (def-edebug-spec mapl maplist
)
153 (def-edebug-spec mapcan maplist
)
154 (def-edebug-spec mapcon maplist
)
158 (def-edebug-spec reduce
(function-form form
&rest form
))
160 ;; Types and assertions
162 (def-edebug-spec cl-type-spec
(sexp)) ;; not worth the trouble to specify, yet.
164 (def-edebug-spec deftype defmacro
*)
165 (def-edebug-spec check-type
(place cl-type-spec
&optional stringp
))
166 ;; (def-edebug-spec assert (form &optional form stringp &rest form))
167 (def-edebug-spec assert
(form &rest form
))
168 (def-edebug-spec typecase
(form &rest
([&or cl-type-spec
"otherwise"] body
)))
169 (def-edebug-spec etypecase typecase
)
171 (def-edebug-spec ignore-errors t
)
173 ;; Time of Evaluation
175 (def-edebug-spec eval-when
176 ((&rest
&or
"compile" "load" "eval") body
))
177 (def-edebug-spec load-time-value
(form &optional
&or
"t" "nil"))
181 (def-edebug-spec cl-decl-spec
182 ((symbolp &rest sexp
)))
184 (def-edebug-spec cl-declarations
185 (&rest
("declare" &rest cl-decl-spec
)))
187 (def-edebug-spec cl-declarations-or-string
188 (&or stringp cl-declarations
))
190 (def-edebug-spec declaim
(&rest cl-decl-spec
))
191 (def-edebug-spec declare
(&rest cl-decl-spec
)) ;; probably not needed.
192 (def-edebug-spec locally
(cl-declarations &rest form
))
193 (def-edebug-spec the
(cl-type-spec form
))
195 ;;======================================================
198 (def-edebug-spec cl-lambda-list
200 [&optional
["&optional" cl-
&optional-arg
&rest cl-
&optional-arg
]]
201 [&optional
["&rest" arg
]]
202 [&optional
["&key" [cl-
&key-arg
&rest cl-
&key-arg
]
203 &optional
"&allow-other-keys"]]
204 [&optional
["&aux" &rest
205 &or
(symbolp &optional def-form
) symbolp
]]
208 (def-edebug-spec cl-
&optional-arg
209 (&or
(arg &optional def-form arg
) arg
))
211 (def-edebug-spec cl-
&key-arg
212 (&or
([&or
(symbolp arg
) arg
] &optional def-form arg
) arg
))
214 ;; The lambda list for macros is different from that of normal lambdas.
215 ;; Note that &environment is only allowed as first or last items in the
218 (def-edebug-spec cl-macro-list
219 (([&optional
"&environment" arg
]
221 [&optional
["&optional" &rest
222 &or
(cl-macro-arg &optional def-form cl-macro-arg
) arg
]]
223 [&optional
[[&or
"&rest" "&body"] cl-macro-arg
]]
224 [&optional
["&key" [&rest
225 [&or
([&or
(symbolp cl-macro-arg
) arg
]
226 &optional def-form cl-macro-arg
)
228 &optional
"&allow-other-keys"]]
229 [&optional
["&aux" &rest
230 &or
(symbolp &optional def-form
) symbolp
]]
231 [&optional
"&environment" arg
]
234 (def-edebug-spec cl-macro-arg
235 (&or arg cl-macro-list1
))
237 (def-edebug-spec cl-macro-list1
238 (([&optional
"&whole" arg
] ;; only allowed at lower levels
240 [&optional
["&optional" &rest
241 &or
(cl-macro-arg &optional def-form cl-macro-arg
) arg
]]
242 [&optional
[[&or
"&rest" "&body"] cl-macro-arg
]]
243 [&optional
["&key" [&rest
244 [&or
([&or
(symbolp cl-macro-arg
) arg
]
245 &optional def-form cl-macro-arg
)
247 &optional
"&allow-other-keys"]]
248 [&optional
["&aux" &rest
249 &or
(symbolp &optional def-form
) symbolp
]]
253 (def-edebug-spec defun
*
254 ;; Same as defun but use cl-lambda-list.
256 ("setf" :name setf name
)]
258 cl-declarations-or-string
259 [&optional
("interactive" interactive
)]
261 (def-edebug-spec defsubst
* defun
*)
263 (def-edebug-spec defmacro
*
264 (&define name cl-macro-list cl-declarations-or-string def-body
))
265 (def-edebug-spec define-compiler-macro defmacro
*)
268 (def-edebug-spec function
*
269 (&or symbolp cl-lambda-expr
))
271 (def-edebug-spec cl-lambda-expr
272 (&define
("lambda" cl-lambda-list
273 ;;cl-declarations-or-string
274 ;;[&optional ("interactive" interactive)]
277 ;; Redefine function-form to also match function*
278 (def-edebug-spec function-form
279 ;; form at the end could also handle "function",
280 ;; but recognize it specially to avoid wrapping function forms.
281 (&or
([&or
"quote" "function"] &or symbolp lambda-expr
)
282 ("function*" function
*)
285 ;;======================================================
287 ;; (def-edebug-spec defstruct (&rest sexp)) would be sufficient, but...
289 ;; defstruct may contain forms that are evaluated when a structure is created.
290 (def-edebug-spec defstruct
291 (&define
; makes top-level form not be wrapped
295 (&or
[":conc-name" symbolp
]
296 [":constructor" symbolp
&optional cl-lambda-list
]
298 [":predicate" symbolp
]
299 [":include" symbolp
&rest sexp
];; not finished
300 ;; The following are not supported.
301 ;; [":print-function" ...]
303 ;; [":initial-offset" ...]
306 ;; All the above is for the following def-form.
307 &rest
&or symbolp
(symbolp def-form
&optional
":read-only" sexp
)))
309 ;;======================================================
312 ;; The loop macro is very complex, and a full spec is found below.
313 ;; The following spec only minimally specifies that
314 ;; parenthesized forms are executable, but single variables used as
315 ;; expressions will be missed. You may want to use this if the full
316 ;; spec causes problems for you.
318 (def-edebug-spec loop
319 (&rest
&or symbolp form
))
321 ;; Below is a complete spec for loop, in several parts that correspond
322 ;; to the syntax given in CLtL2. The specs do more than specify where
323 ;; the forms are; it also specifies, as much as Edebug allows, all the
324 ;; syntactically valid loop clauses. The disadvantage of this
325 ;; completeness is rigidity, but the "for ... being" clause allows
326 ;; arbitrary extensions of the form: [symbolp &rest &or symbolp form].
328 (def-edebug-spec loop
329 ([&optional
["named" symbolp
]]
339 (def-edebug-spec loop-with
342 [&optional
["=" form
]]
343 &rest
["and" loop-var
345 [&optional
["=" form
]]]))
347 (def-edebug-spec loop-for-as
348 ([&or
"for" "as"] loop-for-as-subclause
349 &rest
["and" loop-for-as-subclause
]))
351 (def-edebug-spec loop-for-as-subclause
355 [[&or
"in" "on" "in-ref" "across-ref"]
356 form
&optional
["by" function-form
]]
358 ["=" form
&optional
["then" form
]]
363 [[&or
"element" "elements"]
364 [&or
"of" "in" "of-ref"] form
365 &optional
"using" ["index" symbolp
]];; is this right?
366 [[&or
"hash-key" "hash-keys"
367 "hash-value" "hash-values"]
369 hash-table-p
&optional
["using" ([&or
"hash-value" "hash-values"
370 "hash-key" "hash-keys"] sexp
)]]
372 [[&or
"symbol" "present-symbol" "external-symbol"
373 "symbols" "present-symbols" "external-symbols"]
374 [&or
"in" "of"] package-p
]
376 ;; Extensions for Emacs Lisp, including Lucid Emacs.
377 [[&or
"frame" "frames"
381 [[&or
"window" "windows"]
382 [&or
"of" "in"] form
]
384 [[&or
"overlay" "overlays"
387 &optional
[[&or
"from" "to"] form
]]
389 [[&or
"interval" "intervals"]
391 &optional
[[&or
"from" "to"] form
]
394 [[&or
"key-code" "key-codes"
396 "key-binding" "key-bindings"]
398 &optional
["using" ([&or
"key-code" "key-codes"
400 "key-binding" "key-bindings"]
402 ;; For arbitrary extensions, recognize anything else.
403 [symbolp
&rest
&or symbolp form
]
406 ;; arithmetic - must be last since all parts are optional.
407 [[&optional
[[&or
"from" "downfrom" "upfrom"] form
]]
408 [&optional
[[&or
"to" "downto" "upto" "below" "above"] form
]]
409 [&optional
["by" form
]]
412 (def-edebug-spec loop-initial-final
414 ;; [&optional &or "do" "doing"] ;; CLtL2 doesn't allow this.
415 &rest loop-non-atomic-expr
]
417 [[&optional
&or
"do" "doing"] &rest loop-non-atomic-expr
]
420 (def-edebug-spec loop-and-clause
421 (loop-clause &rest
["and" loop-clause
]))
423 (def-edebug-spec loop-clause
425 [[&or
"while" "until" "always" "never" "thereis"] form
]
427 [[&or
"collect" "collecting"
430 "concat" "vconcat"] form
431 [&optional
["into" loop-var
]]]
433 [[&or
"count" "counting"
435 "maximize" "maximizing"
436 "minimize" "minimizing"] form
437 [&optional
["into" loop-var
]]
440 [[&or
"if" "when" "unless"]
442 [&optional
["else" loop-and-clause
]]
445 [[&or
"do" "doing"] &rest loop-non-atomic-expr
]
451 (def-edebug-spec loop-non-atomic-expr
454 (def-edebug-spec loop-var
455 ;; The symbolp must be last alternative to recognize e.g. (a b . c)
457 ;; (loop-var . [&or nil loop-var])
458 ;; (symbolp . [&or nil loop-var])
459 ;; (symbolp . loop-var)
460 ;; (symbolp . (symbolp . [&or nil loop-var]))
461 ;; (symbolp . (symbolp . loop-var))
462 ;; (symbolp . (symbolp . symbolp)) == (symbolp symbolp . symbolp)
463 (&or
(loop-var .
[&or nil loop-var
]) [gate symbolp
]))
465 (def-edebug-spec loop-type-spec
466 (&optional
["of-type" loop-d-type-spec
]))
468 (def-edebug-spec loop-d-type-spec
469 (&or
(loop-d-type-spec .
[&or nil loop-d-type-spec
]) cl-type-spec
))
471 ;; arch-tag: b29aa3c2-cf67-4af8-9ee1-318fea61b478
472 ;;; cl-specs.el ends here