Fix vertical cursor motion when the newline is covered by a display string.
[emacs.git] / lisp / emacs-lisp / cl.el
blob526475eb1bda51956d2c7743564cd52b741424fc
1 ;;; cl.el --- Common Lisp extensions for Emacs
3 ;; Copyright (C) 1993, 2001-2011 Free Software Foundation, Inc.
5 ;; Author: Dave Gillespie <daveg@synaptics.com>
6 ;; Version: 2.02
7 ;; Keywords: extensions
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24 ;;; Commentary:
26 ;; These are extensions to Emacs Lisp that provide a degree of
27 ;; Common Lisp compatibility, beyond what is already built-in
28 ;; in Emacs Lisp.
30 ;; This package was written by Dave Gillespie; it is a complete
31 ;; rewrite of Cesar Quiroz's original cl.el package of December 1986.
33 ;; Bug reports, comments, and suggestions are welcome!
35 ;; This file contains the portions of the Common Lisp extensions
36 ;; package which should always be present.
39 ;;; Future notes:
41 ;; Once Emacs 19 becomes standard, many things in this package which are
42 ;; messy for reasons of compatibility can be greatly simplified. For now,
43 ;; I prefer to maintain one unified version.
46 ;;; Change Log:
48 ;; Version 2.02 (30 Jul 93):
49 ;; * Added "cl-compat.el" file, extra compatibility with old package.
50 ;; * Added `lexical-let' and `lexical-let*'.
51 ;; * Added `define-modify-macro', `callf', and `callf2'.
52 ;; * Added `ignore-errors'.
53 ;; * Changed `(setf (nthcdr N PLACE) X)' to work when N is zero.
54 ;; * Merged `*gentemp-counter*' into `*gensym-counter*'.
55 ;; * Extended `subseq' to allow negative START and END like `substring'.
56 ;; * Added `in-ref', `across-ref', `elements of-ref' loop clauses.
57 ;; * Added `concat', `vconcat' loop clauses.
58 ;; * Cleaned up a number of compiler warnings.
60 ;; Version 2.01 (7 Jul 93):
61 ;; * Added support for FSF version of Emacs 19.
62 ;; * Added `add-hook' for Emacs 18 users.
63 ;; * Added `defsubst*' and `symbol-macrolet'.
64 ;; * Added `maplist', `mapc', `mapl', `mapcan', `mapcon'.
65 ;; * Added `map', `concatenate', `reduce', `merge'.
66 ;; * Added `revappend', `nreconc', `tailp', `tree-equal'.
67 ;; * Added `assert', `check-type', `typecase', `typep', and `deftype'.
68 ;; * Added destructuring and `&environment' support to `defmacro*'.
69 ;; * Added destructuring to `loop', and added the following clauses:
70 ;; `elements', `frames', `overlays', `intervals', `buffers', `key-seqs'.
71 ;; * Renamed `delete' to `delete*' and `remove' to `remove*'.
72 ;; * Completed support for all keywords in `remove*', `substitute', etc.
73 ;; * Added `most-positive-float' and company.
74 ;; * Fixed hash tables to work with latest Lucid Emacs.
75 ;; * `proclaim' forms are no longer compile-time-evaluating; use `declaim'.
76 ;; * Syntax for `warn' declarations has changed.
77 ;; * Improved implementation of `random*'.
78 ;; * Moved most sequence functions to a new file, cl-seq.el.
79 ;; * Moved `eval-when' into cl-macs.el.
80 ;; * Moved `pushnew' and `adjoin' to cl.el for most common cases.
81 ;; * Moved `provide' forms down to ends of files.
82 ;; * Changed expansion of `pop' to something that compiles to better code.
83 ;; * Changed so that no patch is required for Emacs 19 byte compiler.
84 ;; * Made more things dependent on `optimize' declarations.
85 ;; * Added a partial implementation of struct print functions.
86 ;; * Miscellaneous minor changes.
88 ;; Version 2.00:
89 ;; * First public release of this package.
92 ;;; Code:
94 (defvar cl-optimize-speed 1)
95 (defvar cl-optimize-safety 1)
98 ;;;###autoload
99 (defvar custom-print-functions nil
100 "This is a list of functions that format user objects for printing.
101 Each function is called in turn with three arguments: the object, the
102 stream, and the print level (currently ignored). If it is able to
103 print the object it returns true; otherwise it returns nil and the
104 printer proceeds to the next function on the list.
106 This variable is not used at present, but it is defined in hopes that
107 a future Emacs interpreter will be able to use it.")
109 (defun cl-unload-function ()
110 "Stop unloading of the Common Lisp extensions."
111 (message "Cannot unload the feature `cl'")
112 ;; stop standard unloading!
115 ;;; Generalized variables.
116 ;; These macros are defined here so that they
117 ;; can safely be used in .emacs files.
119 (defmacro incf (place &optional x)
120 "Increment PLACE by X (1 by default).
121 PLACE may be a symbol, or any generalized variable allowed by `setf'.
122 The return value is the incremented value of PLACE."
123 (if (symbolp place)
124 (list 'setq place (if x (list '+ place x) (list '1+ place)))
125 (list 'callf '+ place (or x 1))))
127 (defmacro decf (place &optional x)
128 "Decrement PLACE by X (1 by default).
129 PLACE may be a symbol, or any generalized variable allowed by `setf'.
130 The return value is the decremented value of PLACE."
131 (if (symbolp place)
132 (list 'setq place (if x (list '- place x) (list '1- place)))
133 (list 'callf '- place (or x 1))))
135 ;; Autoloaded, but we haven't loaded cl-loaddefs yet.
136 (declare-function cl-do-pop "cl-macs" (place))
138 (defmacro pop (place)
139 "Remove and return the head of the list stored in PLACE.
140 Analogous to (prog1 (car PLACE) (setf PLACE (cdr PLACE))), though more
141 careful about evaluating each argument only once and in the right order.
142 PLACE may be a symbol, or any generalized variable allowed by `setf'."
143 (if (symbolp place)
144 (list 'car (list 'prog1 place (list 'setq place (list 'cdr place))))
145 (cl-do-pop place)))
147 (defmacro push (x place)
148 "Insert X at the head of the list stored in PLACE.
149 Analogous to (setf PLACE (cons X PLACE)), though more careful about
150 evaluating each argument only once and in the right order. PLACE may
151 be a symbol, or any generalized variable allowed by `setf'."
152 (if (symbolp place) (list 'setq place (list 'cons x place))
153 (list 'callf2 'cons x place)))
155 (defmacro pushnew (x place &rest keys)
156 "(pushnew X PLACE): insert X at the head of the list if not already there.
157 Like (push X PLACE), except that the list is unmodified if X is `eql' to
158 an element already on the list.
159 \nKeywords supported: :test :test-not :key
160 \n(fn X PLACE [KEYWORD VALUE]...)"
161 (if (symbolp place)
162 (if (null keys)
163 `(let ((x ,x))
164 (if (memql x ,place)
165 ;; This symbol may later on expand to actual code which then
166 ;; trigger warnings like "value unused" since pushnew's return
167 ;; value is rarely used. It should not matter that other
168 ;; warnings may be silenced, since `place' is used earlier and
169 ;; should have triggered them already.
170 (with-no-warnings ,place)
171 (setq ,place (cons x ,place))))
172 (list 'setq place (list* 'adjoin x place keys)))
173 (list* 'callf2 'adjoin x place keys)))
175 (defun cl-set-elt (seq n val)
176 (if (listp seq) (setcar (nthcdr n seq) val) (aset seq n val)))
178 (defsubst cl-set-nthcdr (n list x)
179 (if (<= n 0) x (setcdr (nthcdr (1- n) list) x) list))
181 (defun cl-set-buffer-substring (start end val)
182 (save-excursion (delete-region start end)
183 (goto-char start)
184 (insert val)
185 val))
187 (defun cl-set-substring (str start end val)
188 (if end (if (< end 0) (incf end (length str)))
189 (setq end (length str)))
190 (if (< start 0) (incf start (length str)))
191 (concat (and (> start 0) (substring str 0 start))
193 (and (< end (length str)) (substring str end))))
196 ;;; Control structures.
198 ;; These macros are so simple and so often-used that it's better to have
199 ;; them all the time than to load them from cl-macs.el.
201 (defun cl-map-extents (&rest cl-args)
202 (apply 'cl-map-overlays cl-args))
205 ;;; Blocks and exits.
207 (defalias 'cl-block-wrapper 'identity)
208 (defalias 'cl-block-throw 'throw)
211 ;;; Multiple values.
212 ;; True multiple values are not supported, or even
213 ;; simulated. Instead, multiple-value-bind and friends simply expect
214 ;; the target form to return the values as a list.
216 (defsubst values (&rest values)
217 "Return multiple values, Common Lisp style.
218 The arguments of `values' are the values
219 that the containing function should return."
220 values)
222 (defsubst values-list (list)
223 "Return multiple values, Common Lisp style, taken from a list.
224 LIST specifies the list of values
225 that the containing function should return."
226 list)
228 (defsubst multiple-value-list (expression)
229 "Return a list of the multiple values produced by EXPRESSION.
230 This handles multiple values in Common Lisp style, but it does not
231 work right when EXPRESSION calls an ordinary Emacs Lisp function
232 that returns just one value."
233 expression)
235 (defsubst multiple-value-apply (function expression)
236 "Evaluate EXPRESSION to get multiple values and apply FUNCTION to them.
237 This handles multiple values in Common Lisp style, but it does not work
238 right when EXPRESSION calls an ordinary Emacs Lisp function that returns just
239 one value."
240 (apply function expression))
242 (defalias 'multiple-value-call 'apply
243 "Apply FUNCTION to ARGUMENTS, taking multiple values into account.
244 This implementation only handles the case where there is only one argument.")
246 (defsubst nth-value (n expression)
247 "Evaluate EXPRESSION to get multiple values and return the Nth one.
248 This handles multiple values in Common Lisp style, but it does not work
249 right when EXPRESSION calls an ordinary Emacs Lisp function that returns just
250 one value."
251 (nth n expression))
253 ;;; Macros.
255 (defvar cl-macro-environment)
256 (defvar cl-old-macroexpand (prog1 (symbol-function 'macroexpand)
257 (defalias 'macroexpand 'cl-macroexpand)))
259 (defun cl-macroexpand (cl-macro &optional cl-env)
260 "Return result of expanding macros at top level of FORM.
261 If FORM is not a macro call, it is returned unchanged.
262 Otherwise, the macro is expanded and the expansion is considered
263 in place of FORM. When a non-macro-call results, it is returned.
265 The second optional arg ENVIRONMENT specifies an environment of macro
266 definitions to shadow the loaded ones for use in file byte-compilation.
267 \n(fn FORM &optional ENVIRONMENT)"
268 (let ((cl-macro-environment cl-env))
269 (while (progn (setq cl-macro (funcall cl-old-macroexpand cl-macro cl-env))
270 (and (symbolp cl-macro)
271 (cdr (assq (symbol-name cl-macro) cl-env))))
272 (setq cl-macro (cadr (assq (symbol-name cl-macro) cl-env))))
273 cl-macro))
276 ;;; Declarations.
278 (defvar cl-compiling-file nil)
279 (defun cl-compiling-file ()
280 (or cl-compiling-file
281 (and (boundp 'byte-compile--outbuffer)
282 (bufferp (symbol-value 'byte-compile--outbuffer))
283 (equal (buffer-name (symbol-value 'byte-compile--outbuffer))
284 " *Compiler Output*"))))
286 (defvar cl-proclaims-deferred nil)
288 (defun proclaim (spec)
289 (if (fboundp 'cl-do-proclaim) (cl-do-proclaim spec t)
290 (push spec cl-proclaims-deferred))
291 nil)
293 (defmacro declaim (&rest specs)
294 (let ((body (mapcar (function (lambda (x) (list 'proclaim (list 'quote x))))
295 specs)))
296 (if (cl-compiling-file) (list* 'eval-when '(compile load eval) body)
297 (cons 'progn body)))) ; avoid loading cl-macs.el for eval-when
300 ;;; Symbols.
302 (defun cl-random-time ()
303 (let* ((time (copy-sequence (current-time-string))) (i (length time)) (v 0))
304 (while (>= (decf i) 0) (setq v (+ (* v 3) (aref time i))))
307 (defvar *gensym-counter* (* (logand (cl-random-time) 1023) 100))
310 ;;; Numbers.
312 (defun floatp-safe (object)
313 "Return t if OBJECT is a floating point number.
314 On Emacs versions that lack floating-point support, this function
315 always returns nil."
316 (and (numberp object) (not (integerp object))))
318 (defun plusp (number)
319 "Return t if NUMBER is positive."
320 (> number 0))
322 (defun minusp (number)
323 "Return t if NUMBER is negative."
324 (< number 0))
326 (defun oddp (integer)
327 "Return t if INTEGER is odd."
328 (eq (logand integer 1) 1))
330 (defun evenp (integer)
331 "Return t if INTEGER is even."
332 (eq (logand integer 1) 0))
334 (defvar *random-state* (vector 'cl-random-state-tag -1 30 (cl-random-time)))
336 ;; The following are actually set by cl-float-limits.
337 (defconst most-positive-float nil)
338 (defconst most-negative-float nil)
339 (defconst least-positive-float nil)
340 (defconst least-negative-float nil)
341 (defconst least-positive-normalized-float nil)
342 (defconst least-negative-normalized-float nil)
343 (defconst float-epsilon nil)
344 (defconst float-negative-epsilon nil)
347 ;;; Sequence functions.
349 (defalias 'copy-seq 'copy-sequence)
351 (declare-function cl-mapcar-many "cl-extra" (cl-func cl-seqs))
353 (defun mapcar* (cl-func cl-x &rest cl-rest)
354 "Apply FUNCTION to each element of SEQ, and make a list of the results.
355 If there are several SEQs, FUNCTION is called with that many arguments,
356 and mapping stops as soon as the shortest list runs out. With just one
357 SEQ, this is like `mapcar'. With several, it is like the Common Lisp
358 `mapcar' function extended to arbitrary sequence types.
359 \n(fn FUNCTION SEQ...)"
360 (if cl-rest
361 (if (or (cdr cl-rest) (nlistp cl-x) (nlistp (car cl-rest)))
362 (cl-mapcar-many cl-func (cons cl-x cl-rest))
363 (let ((cl-res nil) (cl-y (car cl-rest)))
364 (while (and cl-x cl-y)
365 (push (funcall cl-func (pop cl-x) (pop cl-y)) cl-res))
366 (nreverse cl-res)))
367 (mapcar cl-func cl-x)))
369 (defalias 'svref 'aref)
371 ;;; List functions.
373 (defalias 'first 'car)
374 (defalias 'second 'cadr)
375 (defalias 'rest 'cdr)
376 (defalias 'endp 'null)
378 (defun third (x)
379 "Return the third element of the list X."
380 (car (cdr (cdr x))))
382 (defun fourth (x)
383 "Return the fourth element of the list X."
384 (nth 3 x))
386 (defun fifth (x)
387 "Return the fifth element of the list X."
388 (nth 4 x))
390 (defun sixth (x)
391 "Return the sixth element of the list X."
392 (nth 5 x))
394 (defun seventh (x)
395 "Return the seventh element of the list X."
396 (nth 6 x))
398 (defun eighth (x)
399 "Return the eighth element of the list X."
400 (nth 7 x))
402 (defun ninth (x)
403 "Return the ninth element of the list X."
404 (nth 8 x))
406 (defun tenth (x)
407 "Return the tenth element of the list X."
408 (nth 9 x))
410 (defun caaar (x)
411 "Return the `car' of the `car' of the `car' of X."
412 (car (car (car x))))
414 (defun caadr (x)
415 "Return the `car' of the `car' of the `cdr' of X."
416 (car (car (cdr x))))
418 (defun cadar (x)
419 "Return the `car' of the `cdr' of the `car' of X."
420 (car (cdr (car x))))
422 (defun caddr (x)
423 "Return the `car' of the `cdr' of the `cdr' of X."
424 (car (cdr (cdr x))))
426 (defun cdaar (x)
427 "Return the `cdr' of the `car' of the `car' of X."
428 (cdr (car (car x))))
430 (defun cdadr (x)
431 "Return the `cdr' of the `car' of the `cdr' of X."
432 (cdr (car (cdr x))))
434 (defun cddar (x)
435 "Return the `cdr' of the `cdr' of the `car' of X."
436 (cdr (cdr (car x))))
438 (defun cdddr (x)
439 "Return the `cdr' of the `cdr' of the `cdr' of X."
440 (cdr (cdr (cdr x))))
442 (defun caaaar (x)
443 "Return the `car' of the `car' of the `car' of the `car' of X."
444 (car (car (car (car x)))))
446 (defun caaadr (x)
447 "Return the `car' of the `car' of the `car' of the `cdr' of X."
448 (car (car (car (cdr x)))))
450 (defun caadar (x)
451 "Return the `car' of the `car' of the `cdr' of the `car' of X."
452 (car (car (cdr (car x)))))
454 (defun caaddr (x)
455 "Return the `car' of the `car' of the `cdr' of the `cdr' of X."
456 (car (car (cdr (cdr x)))))
458 (defun cadaar (x)
459 "Return the `car' of the `cdr' of the `car' of the `car' of X."
460 (car (cdr (car (car x)))))
462 (defun cadadr (x)
463 "Return the `car' of the `cdr' of the `car' of the `cdr' of X."
464 (car (cdr (car (cdr x)))))
466 (defun caddar (x)
467 "Return the `car' of the `cdr' of the `cdr' of the `car' of X."
468 (car (cdr (cdr (car x)))))
470 (defun cadddr (x)
471 "Return the `car' of the `cdr' of the `cdr' of the `cdr' of X."
472 (car (cdr (cdr (cdr x)))))
474 (defun cdaaar (x)
475 "Return the `cdr' of the `car' of the `car' of the `car' of X."
476 (cdr (car (car (car x)))))
478 (defun cdaadr (x)
479 "Return the `cdr' of the `car' of the `car' of the `cdr' of X."
480 (cdr (car (car (cdr x)))))
482 (defun cdadar (x)
483 "Return the `cdr' of the `car' of the `cdr' of the `car' of X."
484 (cdr (car (cdr (car x)))))
486 (defun cdaddr (x)
487 "Return the `cdr' of the `car' of the `cdr' of the `cdr' of X."
488 (cdr (car (cdr (cdr x)))))
490 (defun cddaar (x)
491 "Return the `cdr' of the `cdr' of the `car' of the `car' of X."
492 (cdr (cdr (car (car x)))))
494 (defun cddadr (x)
495 "Return the `cdr' of the `cdr' of the `car' of the `cdr' of X."
496 (cdr (cdr (car (cdr x)))))
498 (defun cdddar (x)
499 "Return the `cdr' of the `cdr' of the `cdr' of the `car' of X."
500 (cdr (cdr (cdr (car x)))))
502 (defun cddddr (x)
503 "Return the `cdr' of the `cdr' of the `cdr' of the `cdr' of X."
504 (cdr (cdr (cdr (cdr x)))))
506 ;;(defun last* (x &optional n)
507 ;; "Returns the last link in the list LIST.
508 ;;With optional argument N, returns Nth-to-last link (default 1)."
509 ;; (if n
510 ;; (let ((m 0) (p x))
511 ;; (while (consp p) (incf m) (pop p))
512 ;; (if (<= n 0) p
513 ;; (if (< n m) (nthcdr (- m n) x) x)))
514 ;; (while (consp (cdr x)) (pop x))
515 ;; x))
517 (defun list* (arg &rest rest) ; See compiler macro in cl-macs.el
518 "Return a new list with specified ARGs as elements, consed to last ARG.
519 Thus, `(list* A B C D)' is equivalent to `(nconc (list A B C) D)', or to
520 `(cons A (cons B (cons C D)))'.
521 \n(fn ARG...)"
522 (cond ((not rest) arg)
523 ((not (cdr rest)) (cons arg (car rest)))
524 (t (let* ((n (length rest))
525 (copy (copy-sequence rest))
526 (last (nthcdr (- n 2) copy)))
527 (setcdr last (car (cdr last)))
528 (cons arg copy)))))
530 (defun ldiff (list sublist)
531 "Return a copy of LIST with the tail SUBLIST removed."
532 (let ((res nil))
533 (while (and (consp list) (not (eq list sublist)))
534 (push (pop list) res))
535 (nreverse res)))
537 (defun copy-list (list)
538 "Return a copy of LIST, which may be a dotted list.
539 The elements of LIST are not copied, just the list structure itself."
540 (if (consp list)
541 (let ((res nil))
542 (while (consp list) (push (pop list) res))
543 (prog1 (nreverse res) (setcdr res list)))
544 (car list)))
546 (defun cl-maclisp-member (item list)
547 (while (and list (not (equal item (car list)))) (setq list (cdr list)))
548 list)
550 (defalias 'cl-member 'memq) ; for compatibility with old CL package
552 ;; Autoloaded, but we have not loaded cl-loaddefs yet.
553 (declare-function floor* "cl-extra" (x &optional y))
554 (declare-function ceiling* "cl-extra" (x &optional y))
555 (declare-function truncate* "cl-extra" (x &optional y))
556 (declare-function round* "cl-extra" (x &optional y))
557 (declare-function mod* "cl-extra" (x y))
559 (defalias 'cl-floor 'floor*)
560 (defalias 'cl-ceiling 'ceiling*)
561 (defalias 'cl-truncate 'truncate*)
562 (defalias 'cl-round 'round*)
563 (defalias 'cl-mod 'mod*)
565 (defun adjoin (cl-item cl-list &rest cl-keys) ; See compiler macro in cl-macs
566 "Return ITEM consed onto the front of LIST only if it's not already there.
567 Otherwise, return LIST unmodified.
568 \nKeywords supported: :test :test-not :key
569 \n(fn ITEM LIST [KEYWORD VALUE]...)"
570 (cond ((or (equal cl-keys '(:test eq))
571 (and (null cl-keys) (not (numberp cl-item))))
572 (if (memq cl-item cl-list) cl-list (cons cl-item cl-list)))
573 ((or (equal cl-keys '(:test equal)) (null cl-keys))
574 (if (member cl-item cl-list) cl-list (cons cl-item cl-list)))
575 (t (apply 'cl-adjoin cl-item cl-list cl-keys))))
577 (defun subst (cl-new cl-old cl-tree &rest cl-keys)
578 "Substitute NEW for OLD everywhere in TREE (non-destructively).
579 Return a copy of TREE with all elements `eql' to OLD replaced by NEW.
580 \nKeywords supported: :test :test-not :key
581 \n(fn NEW OLD TREE [KEYWORD VALUE]...)"
582 (if (or cl-keys (and (numberp cl-old) (not (integerp cl-old))))
583 (apply 'sublis (list (cons cl-old cl-new)) cl-tree cl-keys)
584 (cl-do-subst cl-new cl-old cl-tree)))
586 (defun cl-do-subst (cl-new cl-old cl-tree)
587 (cond ((eq cl-tree cl-old) cl-new)
588 ((consp cl-tree)
589 (let ((a (cl-do-subst cl-new cl-old (car cl-tree)))
590 (d (cl-do-subst cl-new cl-old (cdr cl-tree))))
591 (if (and (eq a (car cl-tree)) (eq d (cdr cl-tree)))
592 cl-tree (cons a d))))
593 (t cl-tree)))
595 (defun acons (key value alist)
596 "Add KEY and VALUE to ALIST.
597 Return a new list with (cons KEY VALUE) as car and ALIST as cdr."
598 (cons (cons key value) alist))
600 (defun pairlis (keys values &optional alist)
601 "Make an alist from KEYS and VALUES.
602 Return a new alist composed by associating KEYS to corresponding VALUES;
603 the process stops as soon as KEYS or VALUES run out.
604 If ALIST is non-nil, the new pairs are prepended to it."
605 (nconc (mapcar* 'cons keys values) alist))
608 ;;; Miscellaneous.
610 ;; Define data for indentation and edebug.
611 (dolist (entry
612 '(((defun* defmacro*) 2)
613 ((function*) nil
614 (&or symbolp ([&optional 'macro] 'lambda (&rest sexp) &rest form)))
615 ((eval-when) 1 (sexp &rest form))
616 ((declare) nil (&rest sexp))
617 ((the) 1 (sexp &rest form))
618 ((case ecase typecase etypecase) 1 (form &rest (sexp &rest form)))
619 ((block return-from) 1 (sexp &rest form))
620 ((return) nil (&optional form))
621 ((do do*) 2 ((&rest &or symbolp (symbolp &optional form form))
622 (form &rest form)
623 &rest form))
624 ((do-symbols) 1 ((symbolp form &optional form form) &rest form))
625 ((do-all-symbols) 1 ((symbolp form &optional form) &rest form))
626 ((psetq setf psetf) nil edebug-setq-form)
627 ((progv) 2 (&rest form))
628 ((flet labels macrolet) 1
629 ((&rest (sexp sexp &rest form)) &rest form))
630 ((symbol-macrolet lexical-let lexical-let*) 1
631 ((&rest &or symbolp (symbolp form)) &rest form))
632 ((multiple-value-bind) 2 ((&rest symbolp) &rest form))
633 ((multiple-value-setq) 1 ((&rest symbolp) &rest form))
634 ((incf decf remf pushnew shiftf rotatef) nil (&rest form))
635 ((letf letf*) 1 ((&rest (&rest form)) &rest form))
636 ((callf destructuring-bind) 2 (sexp form &rest form))
637 ((callf2) 3 (sexp form form &rest form))
638 ((loop) nil (&rest &or symbolp form))
639 ((ignore-errors) 0 (&rest form))))
640 (dolist (func (car entry))
641 (put func 'lisp-indent-function (nth 1 entry))
642 (put func 'lisp-indent-hook (nth 1 entry))
643 (or (get func 'edebug-form-spec)
644 (put func 'edebug-form-spec (nth 2 entry)))))
646 ;; Autoload the other portions of the package.
647 ;; We want to replace the basic versions of dolist, dotimes, declare below.
648 (fmakunbound 'dolist)
649 (fmakunbound 'dotimes)
650 (fmakunbound 'declare)
651 (load "cl-loaddefs" nil 'quiet)
653 ;; This goes here so that cl-macs can find it if it loads right now.
654 (provide 'cl)
656 ;; Things to do after byte-compiler is loaded.
658 (defvar cl-hacked-flag nil)
659 (defun cl-hack-byte-compiler ()
660 (and (not cl-hacked-flag) (fboundp 'byte-compile-file-form)
661 (progn
662 (setq cl-hacked-flag t) ; Do it first, to prevent recursion.
663 (load "cl-macs" nil t)
664 (run-hooks 'cl-hack-bytecomp-hook))))
666 ;; Try it now in case the compiler has already been loaded.
667 (cl-hack-byte-compiler)
669 ;; Also make a hook in case compiler is loaded after this file.
670 (add-hook 'bytecomp-load-hook 'cl-hack-byte-compiler)
673 ;; The following ensures that packages which expect the old-style cl.el
674 ;; will be happy with this one.
676 (provide 'cl)
678 (run-hooks 'cl-load-hook)
680 ;; Local variables:
681 ;; byte-compile-dynamic: t
682 ;; byte-compile-warnings: (not cl-functions)
683 ;; End:
685 ;;; cl.el ends here