1 ;;; cl.el --- Common Lisp extensions for GNU Emacs Lisp
3 ;; Copyright (C) 1993, 1997 Free Software Foundation, Inc.
5 ;; Author: Dave Gillespie <daveg@synaptics.com>
6 ;; Maintainer: SXEmacs Development Team
8 ;; Keywords: extensions, dumped, lisp
10 ;; This file is part of SXEmacs.
12 ;; SXEmacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
17 ;; SXEmacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
25 ;;; Synched up with: FSF 19.34.
29 ;; This file is dumped with SXEmacs.
31 ;; These are extensions to Emacs Lisp that provide a degree of
32 ;; Common Lisp compatibility, beyond what is already built-in
35 ;; This package was written by Dave Gillespie; it is a complete
36 ;; rewrite of Cesar Quiroz's original cl.el package of December 1986.
38 ;; This package works with Emacs 18, Emacs 19, and XEmacs/Lucid Emacs 19.
40 ;; Bug reports, comments, and suggestions are welcome!
42 ;; This file contains the portions of the Common Lisp extensions
43 ;; package which should always be present.
48 ;; Once Emacs 19 becomes standard, many things in this package which are
49 ;; messy for reasons of compatibility can be greatly simplified. For now,
50 ;; I prefer to maintain one unified version.
55 ;; Version 2.02 (30 Jul 93):
56 ;; * Added "cl-compat.el" file, extra compatibility with old package.
57 ;; * Added `lexical-let' and `lexical-let*'.
58 ;; * Added `define-modify-macro', `callf', and `callf2'.
59 ;; * Added `ignore-errors'.
60 ;; * Changed `(setf (nthcdr N PLACE) X)' to work when N is zero.
61 ;; * Merged `*gentemp-counter*' into `*gensym-counter*'.
62 ;; * Extended `subseq' to allow negative START and END like `substring'.
63 ;; * Added `in-ref', `across-ref', `elements of-ref' loop clauses.
64 ;; * Added `concat', `vconcat' loop clauses.
65 ;; * Cleaned up a number of compiler warnings.
67 ;; Version 2.01 (7 Jul 93):
68 ;; * Added support for FSF version of Emacs 19.
69 ;; * Added `add-hook' for Emacs 18 users.
70 ;; * Added `defsubst*' and `symbol-macrolet'.
71 ;; * Added `maplist', `mapc', `mapl', `mapcan', `mapcon'.
72 ;; * Added `map', `concatenate', `reduce', `merge'.
73 ;; * Added `revappend', `nreconc', `tailp', `tree-equal'.
74 ;; * Added `assert', `check-type', `typecase', `typep', and `deftype'.
75 ;; * Added destructuring and `&environment' support to `defmacro*'.
76 ;; * Added destructuring to `loop', and added the following clauses:
77 ;; `elements', `frames', `overlays', `intervals', `buffers', `key-seqs'.
78 ;; * Renamed `delete' to `delete*' and `remove' to `remove*'.
79 ;; * Completed support for all keywords in `remove*', `substitute', etc.
80 ;; * Added `most-positive-float' and company.
81 ;; * Fixed hash tables to work with latest Lucid Emacs.
82 ;; * `proclaim' forms are no longer compile-time-evaluating; use `declaim'.
83 ;; * Syntax for `warn' declarations has changed.
84 ;; * Improved implementation of `random*'.
85 ;; * Moved most sequence functions to a new file, cl-seq.el.
86 ;; * Moved `eval-when' into cl-macs.el.
87 ;; * Moved `pushnew' and `adjoin' to cl.el for most common cases.
88 ;; * Moved `provide' forms down to ends of files.
89 ;; * Changed expansion of `pop' to something that compiles to better code.
90 ;; * Changed so that no patch is required for Emacs 19 byte compiler.
91 ;; * Made more things dependent on `optimize' declarations.
92 ;; * Added a partial implementation of struct print functions.
93 ;; * Miscellaneous minor changes.
96 ;; * First public release of this package.
101 (defvar cl-emacs-type (cond ((or (and (fboundp 'epoch::version)
102 (symbol-value 'epoch::version))
103 (string-lessp emacs-version "19")) 18)
104 ((string-match "XEmacs" emacs-version)
108 (or (fboundp 'defalias) (fset 'defalias 'fset))
110 (defvar cl-optimize-speed 1)
111 (defvar cl-optimize-safety 1)
114 ;;; Keywords used in this package.
116 ;;; XEmacs - keywords are done in Fintern().
118 ;;; (defconst :test ':test)
119 ;;; (defconst :test-not ':test-not)
120 ;;; (defconst :key ':key)
121 ;;; (defconst :start ':start)
122 ;;; (defconst :start1 ':start1)
123 ;;; (defconst :start2 ':start2)
124 ;;; (defconst :end ':end)
125 ;;; (defconst :end1 ':end1)
126 ;;; (defconst :end2 ':end2)
127 ;;; (defconst :count ':count)
128 ;;; (defconst :initial-value ':initial-value)
129 ;;; (defconst :size ':size)
130 ;;; (defconst :from-end ':from-end)
131 ;;; (defconst :rehash-size ':rehash-size)
132 ;;; (defconst :rehash-threshold ':rehash-threshold)
133 ;;; (defconst :allow-other-keys ':allow-other-keys)
136 (defvar custom-print-functions nil
137 "This is a list of functions that format user objects for printing.
138 Each function is called in turn with three arguments: the object, the
139 stream, and the print level (currently ignored). If it is able to
140 print the object it returns true; otherwise it returns nil and the
141 printer proceeds to the next function on the list.")
143 (defun print-custom-object (obj &optional stream pl)
144 "Print custom object OBJ into STREAM using print level PL."
145 (let ((cpfs custom-print-functions)
148 (when (funcall (car cpfs) obj stream pl)
151 (setq cpfs (cdr cpfs)))
154 (defun print-object-ignoring-custom-print-functions (obj &optional stream pl)
155 "Print object OBJ not using custom printers."
156 (let ((custom-object-printer nil))
159 ;; Install custom printer
160 (setq custom-object-printer 'print-custom-object)
164 (defun eql (a b) ; See compiler macro in cl-macs.el
165 "Return t if the two args are the same Lisp object.
166 Floating-point numbers of equal value are `eql', but they may not be `eq'."
172 ;;; Generalized variables. These macros are defined here so that they
173 ;;; can safely be used in .emacs files.
175 (defmacro incf (place &optional x)
176 "(incf PLACE [X]): increment PLACE by X (1 by default).
177 PLACE may be a symbol, or any generalized variable allowed by `setf'.
178 The return value is the incremented value of PLACE."
180 (list 'setq place (if x (list '+ place x) (list '1+ place)))
181 ;; XEmacs byte-compiler optimizes (+ FOO 1) to (1+ FOO), so this
183 (list 'callf '+ place (or x 1))))
185 (defmacro decf (place &optional x)
186 "(decf PLACE [X]): decrement PLACE by X (1 by default).
187 PLACE may be a symbol, or any generalized variable allowed by `setf'.
188 The return value is the decremented value of PLACE."
190 (list 'setq place (if x (list '- place x) (list '1- place)))
191 (list 'callf '- place (or x 1))))
193 (defmacro pop (place)
194 "(pop PLACE): remove and return the head of the list stored in PLACE.
195 Analogous to (prog1 (car PLACE) (setf PLACE (cdr PLACE))), though more
196 careful about evaluating each argument only once and in the right order.
197 PLACE may be a symbol, or any generalized variable allowed by `setf'."
199 `(car (prog1 ,place (setq ,place (cdr ,place))))
202 (defmacro push (x place)
203 "(push X PLACE): insert X at the head of the list stored in PLACE.
204 Analogous to (setf PLACE (cons X PLACE)), though more careful about
205 evaluating each argument only once and in the right order. PLACE may
206 be a symbol, or any generalized variable allowed by `setf'; that is,
207 it does not necessarily have to be a list, though `push' is most often
209 (if (symbolp place) `(setq ,place (cons ,x ,place))
210 (list 'callf2 'cons x place)))
212 (defmacro pushnew (x place &rest keys)
213 "(pushnew X PLACE): insert X at the head of the list stored in PLACE.
214 Like (push X PLACE), except that the list is unmodified if X is `eql'
215 to an element already on the list.
216 Keywords supported: :test :test-not :key"
217 (if (symbolp place) (list 'setq place (list* 'adjoin x place keys))
218 (list* 'callf2 'adjoin x place keys)))
220 (defun cl-set-elt (seq n val)
221 (if (listp seq) (setcar (nthcdr n seq) val) (aset seq n val)))
223 (defun cl-set-nthcdr (n list x)
224 (if (<= n 0) x (setcdr (nthcdr (1- n) list) x) list))
226 (defun cl-set-buffer-substring (start end val)
227 (save-excursion (delete-region start end)
232 (defun cl-set-substring (str start end val)
233 (if end (if (< end 0) (incf end (length str)))
234 (setq end (length str)))
235 (if (< start 0) (incf start (length str)))
236 (concat (and (> start 0) (substring str 0 start))
238 (and (< end (length str)) (substring str end))))
241 ;;; Control structures.
243 ;; The macros `when' and `unless' are so useful that we want them to
244 ;; ALWAYS be available. So they've been moved from cl.el to eval.c.
245 ;; Note: FSF Emacs moved them to subr.el in FSF 20.
247 (defun cl-map-extents (&rest cl-args)
248 ;; XEmacs: This used to check for overlays first, but that's wrong
249 ;; because of the new compatibility library. *duh*
250 (cond ((fboundp 'map-extents)
251 (apply 'map-extents cl-args))
252 ((fboundp 'next-overlay-at)
253 (apply 'cl-map-overlays cl-args))))
256 ;;; Blocks and exits.
258 (defalias 'cl-block-wrapper 'identity)
259 (defalias 'cl-block-throw 'throw)
262 ;;; Multiple values. True multiple values are not supported, or even
263 ;;; simulated. Instead, multiple-value-bind and friends simply expect
264 ;;; the target form to return the values as a list.
266 (defalias 'values 'list)
267 (defalias 'values-list 'identity)
268 (defalias 'multiple-value-list 'identity)
269 (defalias 'multiple-value-call 'apply) ; only works for one arg
270 (defalias 'nth-value 'nth)
275 (defvar cl-macro-environment nil)
276 ;; XEmacs: we renamed the internal function to macroexpand-internal
277 ;; to avoid doc-file problems.
278 (defvar cl-old-macroexpand (prog1 (symbol-function 'macroexpand-internal)
279 (defalias 'macroexpand 'cl-macroexpand)))
281 (defun cl-macroexpand (cl-macro &optional cl-env)
282 "Return result of expanding macros at top level of FORM.
283 If FORM is not a macro call, it is returned unchanged.
284 Otherwise, the macro is expanded and the expansion is considered
285 in place of FORM. When a non-macro-call results, it is returned.
287 The second optional arg ENVIRONMENT specifies an environment of macro
288 definitions to shadow the loaded ones for use in file byte-compilation."
289 (let ((cl-macro-environment cl-env))
290 (while (progn (setq cl-macro (funcall cl-old-macroexpand cl-macro cl-env))
291 (and (symbolp cl-macro)
292 (cdr (assq (symbol-name cl-macro) cl-env))))
293 (setq cl-macro (cadr (assq (symbol-name cl-macro) cl-env))))
299 (defvar cl-compiling-file nil)
300 (defun cl-compiling-file ()
301 (or cl-compiling-file
303 ; (and (boundp 'outbuffer) (bufferp (symbol-value 'outbuffer))
304 ; (equal (buffer-name (symbol-value 'outbuffer))
305 ; " *Compiler Output*"))
306 (and (boundp 'byte-compile-outbuffer)
307 (bufferp (symbol-value 'byte-compile-outbuffer))
308 (equal (buffer-name (symbol-value 'byte-compile-outbuffer))
309 " *Compiler Output*"))
312 (defvar cl-proclaims-deferred nil)
314 (defun proclaim (spec)
315 (if (fboundp 'cl-do-proclaim) (cl-do-proclaim spec t)
316 (push spec cl-proclaims-deferred))
319 (defmacro declaim (&rest specs)
320 (let ((body (mapcar (function (lambda (x) (list 'proclaim (list 'quote x))))
322 (if (cl-compiling-file) (list* 'eval-when '(compile load eval) body)
323 (cons 'progn body)))) ; avoid loading cl-macs.el for eval-when
328 (defun cl-random-time ()
329 (let* ((time (copy-sequence (current-time-string))) (i (length time)) (v 0))
330 (while (>= (decf i) 0) (setq v (+ (* v 3) (aref time i))))
333 (defvar *gensym-counter* (* (logand (cl-random-time) 1023) 100))
335 (defun gensym (&optional arg)
336 "Generate a new uninterned symbol.
337 The name is made by appending a number to a prefix. If ARG is a string, it
338 is the prefix, otherwise the prefix defaults to \"G\". If ARG is an integer,
339 the internal counter is reset to that number before creating the name.
340 There is no way to specify both using this function."
341 (let ((prefix (if (stringp arg) arg "G"))
342 (num (if (integerp arg) arg
343 (prog1 *gensym-counter*
344 (setq *gensym-counter* (1+ *gensym-counter*))))))
345 (make-symbol (format "%s%d" prefix num))))
347 (defun gentemp (&optional arg)
348 "Generate a new interned symbol with a unique name.
349 The name is made by appending a number to ARG, default \"G\".
350 If ARG is not a string, it is ignored."
351 (let ((prefix (if (stringp arg) arg "G"))
353 (while (intern-soft (setq name (format "%s%d" prefix *gensym-counter*)))
354 (setq *gensym-counter* (1+ *gensym-counter*)))
359 (defun floatp-safe (object)
360 "Return t if OBJECT is a floating point number."
363 (defun plusp (number)
364 "Return t if NUMBER is positive."
367 (defun minusp (number)
368 "Return t if NUMBER is negative."
371 (unless (featurep 'ent)
372 (defun oddp (integer)
373 "Return t if INTEGER is odd."
374 (eq (logand integer 1) 1))
376 (defun evenp (integer)
377 "Return t if INTEGER is even."
378 (eq (logand integer 1) 0)))
380 (defun cl-abs (number)
381 "Return the absolute value of NUMBER."
382 (if (>= number 0) number (- number)))
383 (or (fboundp 'abs) (defalias 'abs 'cl-abs)) ; This is built-in to Emacs 19
385 (defvar *random-state* (vector 'cl-random-state-tag -1 30 (cl-random-time)))
387 ;; Threse constants are defined in C when 'number-types is provided
388 (unless (featurep 'ent)
389 ;;; We use `eval' in case VALBITS differs from compile-time to load-time.
390 (defconst most-positive-fixnum (eval '(lsh -1 -1))
391 "The integer closest in value to positive infinity.")
392 (defconst most-negative-fixnum (eval '(- -1 (lsh -1 -1)))
393 "The integer closest in value to negative infinity."))
395 ;;; Sequence functions.
397 (defalias 'copy-seq 'copy-sequence)
399 (defun mapcar* (cl-func cl-x &rest cl-rest)
400 "Apply FUNCTION to each element of SEQ, and make a list of the results.
401 If there are several SEQs, FUNCTION is called with that many arguments,
402 and mapping stops as soon as the shortest list runs out. With just one
403 SEQ, this is like `mapcar'. With several, it is like the Common Lisp
404 `mapcar' function extended to arbitrary sequence types."
406 (if (or (cdr cl-rest) (nlistp cl-x) (nlistp (car cl-rest)))
407 (cl-mapcar-many cl-func (cons cl-x cl-rest))
408 (let ((cl-res nil) (cl-y (car cl-rest)))
409 (while (and cl-x cl-y)
410 (push (funcall cl-func (pop cl-x) (pop cl-y)) cl-res))
412 (mapcar cl-func cl-x)))
417 ;; These functions are made known to the byte-compiler by cl-macs.el
418 ;; and turned into efficient car and cdr bytecodes.
420 (defalias 'first 'car)
421 (defalias 'rest 'cdr)
422 (defalias 'endp 'null)
425 "Return the second element of the list LIST."
429 "Return the third element of the list LIST."
433 "Return the fourth element of the list LIST."
437 "Return the fifth element of the list LIST."
441 "Return the sixth element of the list LIST."
445 "Return the seventh element of the list LIST."
449 "Return the eighth element of the list LIST."
453 "Return the ninth element of the list LIST."
457 "Return the tenth element of the list LIST."
461 "Return the `car' of the `car' of X."
465 "Return the `car' of the `cdr' of X."
469 "Return the `cdr' of the `car' of X."
473 "Return the `cdr' of the `cdr' of X."
477 "Return the `car' of the `car' of the `car' of X."
481 "Return the `car' of the `car' of the `cdr' of X."
485 "Return the `car' of the `cdr' of the `car' of X."
489 "Return the `car' of the `cdr' of the `cdr' of X."
493 "Return the `cdr' of the `car' of the `car' of X."
497 "Return the `cdr' of the `car' of the `cdr' of X."
501 "Return the `cdr' of the `cdr' of the `car' of X."
505 "Return the `cdr' of the `cdr' of the `cdr' of X."
509 "Return the `car' of the `car' of the `car' of the `car' of X."
510 (car (car (car (car x)))))
513 "Return the `car' of the `car' of the `car' of the `cdr' of X."
514 (car (car (car (cdr x)))))
517 "Return the `car' of the `car' of the `cdr' of the `car' of X."
518 (car (car (cdr (car x)))))
521 "Return the `car' of the `car' of the `cdr' of the `cdr' of X."
522 (car (car (cdr (cdr x)))))
525 "Return the `car' of the `cdr' of the `car' of the `car' of X."
526 (car (cdr (car (car x)))))
529 "Return the `car' of the `cdr' of the `car' of the `cdr' of X."
530 (car (cdr (car (cdr x)))))
533 "Return the `car' of the `cdr' of the `cdr' of the `car' of X."
534 (car (cdr (cdr (car x)))))
537 "Return the `car' of the `cdr' of the `cdr' of the `cdr' of X."
538 (car (cdr (cdr (cdr x)))))
541 "Return the `cdr' of the `car' of the `car' of the `car' of X."
542 (cdr (car (car (car x)))))
545 "Return the `cdr' of the `car' of the `car' of the `cdr' of X."
546 (cdr (car (car (cdr x)))))
549 "Return the `cdr' of the `car' of the `cdr' of the `car' of X."
550 (cdr (car (cdr (car x)))))
553 "Return the `cdr' of the `car' of the `cdr' of the `cdr' of X."
554 (cdr (car (cdr (cdr x)))))
557 "Return the `cdr' of the `cdr' of the `car' of the `car' of X."
558 (cdr (cdr (car (car x)))))
561 "Return the `cdr' of the `cdr' of the `car' of the `cdr' of X."
562 (cdr (cdr (car (cdr x)))))
565 "Return the `cdr' of the `cdr' of the `cdr' of the `car' of X."
566 (cdr (cdr (cdr (car x)))))
569 "Return the `cdr' of the `cdr' of the `cdr' of the `cdr' of X."
570 (cdr (cdr (cdr (cdr x)))))
572 ;;; `last' is implemented as a C primitive, as of 1998-11
574 ;(defun last (x &optional n)
575 ; "Return the last link in the list LIST.
576 ;With optional argument N, return Nth-to-last link (default 1)."
579 ; (while (consp p) (incf m) (pop p))
581 ; (if (< n m) (nthcdr (- m n) x) x)))
582 ; (while (consp (cdr x)) (pop x))
585 ;;; `butlast' is implemented as a C primitive, as of 1998-11
586 ;;; `nbutlast' is implemented as a C primitive, as of 1998-11
588 ;(defun butlast (x &optional n)
589 ; "Return a copy of LIST with the last N elements removed."
590 ; (if (and n (<= n 0)) x
591 ; (nbutlast (copy-sequence x) n)))
593 ;(defun nbutlast (x &optional n)
594 ; "Modify LIST to remove the last N elements."
595 ; (let ((m (length x)))
599 ; (if (> n 0) (setcdr (nthcdr (- (1- m) n) x) nil))
602 (defun list* (arg &rest rest) ; See compiler macro in cl-macs.el
603 "Return a new list with specified args as elements, cons'd to last arg.
604 Thus, `(list* A B C D)' is equivalent to `(nconc (list A B C) D)', or to
605 `(cons A (cons B (cons C D)))'."
606 (cond ((not rest) arg)
607 ((not (cdr rest)) (cons arg (car rest)))
608 (t (let* ((n (length rest))
609 (copy (copy-sequence rest))
610 (last (nthcdr (- n 2) copy)))
611 (setcdr last (car (cdr last)))
614 (defun ldiff (list sublist)
615 "Return a copy of LIST with the tail SUBLIST removed."
617 (while (and (consp list) (not (eq list sublist)))
618 (push (pop list) res))
621 ;;; `copy-list' is implemented as a C primitive, as of 1998-11
623 ;(defun copy-list (list)
624 ; "Return a copy of a list, which may be a dotted list.
625 ;The elements of the list are not copied, just the list structure itself."
628 ; (while (consp list) (push (pop list) res))
629 ; (prog1 (nreverse res) (setcdr res list)))
632 (defun cl-maclisp-member (item list)
633 (while (and list (not (equal item (car list)))) (setq list (cdr list)))
636 ;;; Define an Emacs 19-compatible `member' for the benefit of Emacs 18 users.
637 (or (and (fboundp 'member) (subrp (symbol-function 'member)))
638 (defalias 'member 'cl-maclisp-member))
640 (defalias 'cl-member 'memq) ; for compatibility with old CL package
641 (defalias 'cl-floor 'floor*)
642 (defalias 'cl-ceiling 'ceiling*)
643 (defalias 'cl-truncate 'truncate*)
644 (defalias 'cl-round 'round*)
645 (defalias 'cl-mod 'mod*)
647 (defun adjoin (cl-item cl-list &rest cl-keys) ; See compiler macro in cl-macs
648 "Return ITEM consed onto the front of LIST only if it's not already there.
649 Otherwise, return LIST unmodified.
650 Keywords supported: :test :test-not :key"
651 (cond ((or (equal cl-keys '(:test eq))
652 (and (null cl-keys) (not (numberp cl-item))))
653 (if (memq cl-item cl-list) cl-list (cons cl-item cl-list)))
654 ((or (equal cl-keys '(:test equal)) (null cl-keys))
655 (if (member cl-item cl-list) cl-list (cons cl-item cl-list)))
656 (t (apply 'cl-adjoin cl-item cl-list cl-keys))))
658 (defun subst (cl-new cl-old cl-tree &rest cl-keys)
659 "Substitute NEW for OLD everywhere in TREE (non-destructively).
660 Return a copy of TREE with all elements `eql' to OLD replaced by NEW.
661 Keywords supported: :test :test-not :key"
662 (if (or cl-keys (and (numberp cl-old) (not (integerp cl-old))))
663 (apply 'sublis (list (cons cl-old cl-new)) cl-tree cl-keys)
664 (cl-do-subst cl-new cl-old cl-tree)))
666 (defun cl-do-subst (cl-new cl-old cl-tree)
667 (cond ((eq cl-tree cl-old) cl-new)
669 (let ((a (cl-do-subst cl-new cl-old (car cl-tree)))
670 (d (cl-do-subst cl-new cl-old (cdr cl-tree))))
671 (if (and (eq a (car cl-tree)) (eq d (cdr cl-tree)))
672 cl-tree (cons a d))))
676 "Return a new alist created by adding (KEY . VALUE) to ALIST."
679 (defun pairlis (a b &optional c) (nconc (mapcar* 'cons a b) c))
685 (define-error 'cl-assertion-failed "Assertion failed")
687 ;;; This is defined in Emacs 19; define it here for Emacs 18 users.
688 (defun cl-add-hook (hook func &optional append)
689 "Add to hook variable HOOK the function FUNC.
690 FUNC is not added if it already appears on the list stored in HOOK."
691 (let ((old (and (boundp hook) (symbol-value hook))))
692 (and (listp old) (not (eq (car old) 'lambda))
693 (setq old (list old)))
694 (and (not (member func old))
695 (set hook (if append (nconc old (list func)) (cons func old))))))
696 (or (fboundp 'add-hook) (defalias 'add-hook 'cl-add-hook))
701 ;;; Define data for indentation and edebug.
706 (put func 'lisp-indent-function (nth 1 entry))
707 (put func 'lisp-indent-hook (nth 1 entry))
708 (or (get func 'edebug-form-spec)
709 (put func 'edebug-form-spec (nth 2 entry))))
711 '(((defun* defmacro*) defun)
713 (&or symbolp ([&optional 'macro] 'lambda (&rest sexp) &rest form)))
714 ((eval-when) 1 (sexp &rest form))
715 ((when unless) 1 (&rest form))
716 ((declare) nil (&rest sexp))
717 ((the) 1 (sexp &rest form))
718 ((case ecase typecase etypecase) 1 (form &rest (sexp &rest form)))
719 ((block return-from) 1 (sexp &rest form))
720 ((return) nil (&optional form))
721 ((do do*) 2 ((&rest &or symbolp (symbolp &optional form form))
724 ((dolist dotimes) 1 ((symbolp form &rest form) &rest form))
725 ((do-symbols) 1 ((symbolp form &optional form form) &rest form))
726 ((do-all-symbols) 1 ((symbolp form &optional form) &rest form))
727 ((psetq setf psetf) nil edebug-setq-form)
728 ((progv) 2 (&rest form))
729 ((flet labels macrolet) 1
730 ((&rest (sexp sexp &rest form)) &rest form))
731 ((symbol-macrolet lexical-let lexical-let*) 1
732 ((&rest &or symbolp (symbolp form)) &rest form))
733 ((multiple-value-bind) 2 ((&rest symbolp) &rest form))
734 ((multiple-value-setq) 1 ((&rest symbolp) &rest form))
735 ((incf decf remf pop push pushnew shiftf rotatef) nil (&rest form))
736 ((letf letf*) 1 ((&rest (&rest form)) &rest form))
737 ((callf destructuring-bind) 2 (sexp form &rest form))
738 ((callf2) 3 (sexp form form &rest form))
739 ((loop) defun (&rest &or symbolp form))
740 ((ignore-errors) 0 (&rest form))))
743 ;;; This goes here so that cl-macs can find it if it loads right now.
744 (provide 'cl-19) ; usage: (require 'cl-19 "cl")
747 ;;; Things to do after byte-compiler is loaded.
748 ;;; As a side effect, we cause cl-macs to be loaded when compiling, so
749 ;;; that the compiler-macros defined there will be present.
751 (defvar cl-hacked-flag nil)
752 (defun cl-hack-byte-compiler ()
753 (if (and (not cl-hacked-flag) (fboundp 'byte-compile-file-form))
755 (when (not (fboundp 'cl-compile-time-init))
756 (load "cl-macs" nil t))
757 (cl-compile-time-init) ; in cl-macs.el
758 (setq cl-hacked-flag t))))
760 ;;; Try it now in case the compiler has already been loaded.
761 (cl-hack-byte-compiler)
763 ;;; Also make a hook in case compiler is loaded after this file.
764 ;;; The compiler doesn't call any hooks when it loads or runs, but
765 ;;; we can take advantage of the fact that emacs-lisp-mode will be
766 ;;; called when the compiler reads in the file to be compiled.
767 ;;; BUG: If the first compilation is `byte-compile' rather than
768 ;;; `byte-compile-file', we lose. Oh, well.
769 (add-hook 'emacs-lisp-mode-hook 'cl-hack-byte-compiler)
772 ;;; The following ensures that packages which expect the old-style cl.el
773 ;;; will be happy with this one.
777 (provide 'mini-cl) ; for Epoch
779 (run-hooks 'cl-load-hook)