annotate lisp/emacs-lisp/cl-extra.el @ 72863:526dc1f36b09

(produce_image_glyph): Automatically crop wide images at right window edge so we can draw the cursor on the same row to avoid confusing redisplay by placing the cursor outside the visible window area.
author Kim F. Storm <storm@cua.dk>
date Thu, 14 Sep 2006 09:37:44 +0000
parents 067115a6e738
children 1d4b1a32fd66 c5406394f567
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16057
a74507d555ba Turn on byte-compile-dynamic.
Richard M. Stallman <rms@gnu.org>
parents: 15029
diff changeset
1 ;;; cl-extra.el --- Common Lisp features, part 2 -*-byte-compile-dynamic: t;-*-
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
64751
5b1a238fcbb4 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64684
diff changeset
3 ;; Copyright (C) 1993, 2000, 2002, 2003, 2004,
68648
067115a6e738 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 67650
diff changeset
4 ;; 2005, 2006 Free Software Foundation, Inc.
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Author: Dave Gillespie <daveg@synaptics.com>
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; Keywords: extensions
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
12244
ac7375e60931 Update GPL to version 2.
Karl Heuer <kwzh@gnu.org>
parents: 7942
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; any later version.
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13970
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64085
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62627
diff changeset
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62627
diff changeset
24 ;; Boston, MA 02110-1301, USA.
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
7942
bc5dccc5375f Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 4517
diff changeset
26 ;;; Commentary:
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;; These are extensions to Emacs Lisp that provide a degree of
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; Common Lisp compatibility, beyond what is already built-in
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; in Emacs Lisp.
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;;
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;; This package was written by Dave Gillespie; it is a complete
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;; rewrite of Cesar Quiroz's original cl.el package of December 1986.
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;;
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;; Bug reports, comments, and suggestions are welcome!
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;; This file contains portions of the Common Lisp extensions
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;; package which are autoloaded since they are relatively obscure.
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39
7942
bc5dccc5375f Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 4517
diff changeset
40 ;;; Code:
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41
64684
eb2cbda455c6 Require CL also when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64085
diff changeset
42 (require 'cl)
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 ;;; Type coercion.
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 (defun coerce (x type)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 "Coerce OBJECT to type TYPE.
62627
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
48 TYPE is a Common Lisp type specifier.
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
49 \n(fn OBJECT TYPE)"
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 (cond ((eq type 'list) (if (listp x) x (append x nil)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 ((eq type 'vector) (if (vectorp x) x (vconcat x)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 ((eq type 'string) (if (stringp x) x (concat x)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 ((eq type 'array) (if (arrayp x) x (vconcat x)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 ((and (eq type 'character) (stringp x) (= (length x) 1)) (aref x 0))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 ((and (eq type 'character) (symbolp x)) (coerce (symbol-name x) type))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 ((eq type 'float) (float x))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 ((typep x type) x)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 (t (error "Can't coerce %s to type %s" x type))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 ;;; Predicates.
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 (defun equalp (x y)
62409
45f10c2912d3 (equalp): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 52401
diff changeset
64 "Return t if two Lisp objects have similar structures and contents.
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 This is like `equal', except that it accepts numerically equal
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 numbers of different types (float vs. integer), and also compares
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 strings case-insensitively."
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 (cond ((eq x y) t)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 ((stringp x)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 (and (stringp y) (= (length x) (length y))
14794
c3a2cabb73ef (equalp): Use string-equal on strings.
Erik Naggum <erik@naggum.no>
parents: 14762
diff changeset
71 (or (string-equal x y)
c3a2cabb73ef (equalp): Use string-equal on strings.
Erik Naggum <erik@naggum.no>
parents: 14762
diff changeset
72 (string-equal (downcase x) (downcase y))))) ; lazy but simple!
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 ((numberp x)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 (and (numberp y) (= x y)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 ((consp x)
14762
624d5547a6d6 (equalp): Correctly compare last elt of two lists.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
76 (while (and (consp x) (consp y) (equalp (car x) (car y)))
624d5547a6d6 (equalp): Correctly compare last elt of two lists.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
77 (setq x (cdr x) y (cdr y)))
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 (and (not (consp x)) (equalp x y)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 ((vectorp x)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 (and (vectorp y) (= (length x) (length y))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 (let ((i (length x)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 (while (and (>= (setq i (1- i)) 0)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 (equalp (aref x i) (aref y i))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 (< i 0))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 (t (equal x y))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 ;;; Control structures.
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 (defun cl-mapcar-many (cl-func cl-seqs)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 (if (cdr (cdr cl-seqs))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 (let* ((cl-res nil)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 (cl-n (apply 'min (mapcar 'length cl-seqs)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 (cl-i 0)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 (cl-args (copy-sequence cl-seqs))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 cl-p1 cl-p2)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 (setq cl-seqs (copy-sequence cl-seqs))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 (while (< cl-i cl-n)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 (setq cl-p1 cl-seqs cl-p2 cl-args)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 (while cl-p1
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 (setcar cl-p2
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 (if (consp (car cl-p1))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 (prog1 (car (car cl-p1))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 (setcar cl-p1 (cdr (car cl-p1))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 (aref (car cl-p1) cl-i)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 (setq cl-p1 (cdr cl-p1) cl-p2 (cdr cl-p2)))
47662
a6d932b28650 (cl-push, cl-pop): Remove. Use pop and push throughout the file instead.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45699
diff changeset
107 (push (apply cl-func cl-args) cl-res)
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 (setq cl-i (1+ cl-i)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 (nreverse cl-res))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 (let ((cl-res nil)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 (cl-x (car cl-seqs))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 (cl-y (nth 1 cl-seqs)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 (let ((cl-n (min (length cl-x) (length cl-y)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 (cl-i -1))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 (while (< (setq cl-i (1+ cl-i)) cl-n)
47662
a6d932b28650 (cl-push, cl-pop): Remove. Use pop and push throughout the file instead.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45699
diff changeset
116 (push (funcall cl-func
a6d932b28650 (cl-push, cl-pop): Remove. Use pop and push throughout the file instead.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45699
diff changeset
117 (if (consp cl-x) (pop cl-x) (aref cl-x cl-i))
a6d932b28650 (cl-push, cl-pop): Remove. Use pop and push throughout the file instead.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45699
diff changeset
118 (if (consp cl-y) (pop cl-y) (aref cl-y cl-i)))
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 cl-res)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 (nreverse cl-res))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 (defun map (cl-type cl-func cl-seq &rest cl-rest)
62627
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
123 "Map a FUNCTION across one or more SEQUENCEs, returning a sequence.
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
124 TYPE is the sequence type to return.
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
125 \n(fn TYPE FUNCTION SEQUENCE...)"
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 (let ((cl-res (apply 'mapcar* cl-func cl-seq cl-rest)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 (and cl-type (coerce cl-res cl-type))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 (defun maplist (cl-func cl-list &rest cl-rest)
62627
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
130 "Map FUNCTION to each sublist of LIST or LISTs.
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 Like `mapcar', except applies to lists and their cdr's rather than to
62627
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
132 the elements themselves.
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
133 \n(fn FUNCTION LIST...)"
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 (if cl-rest
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 (let ((cl-res nil)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 (cl-args (cons cl-list (copy-sequence cl-rest)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 cl-p)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 (while (not (memq nil cl-args))
47662
a6d932b28650 (cl-push, cl-pop): Remove. Use pop and push throughout the file instead.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45699
diff changeset
139 (push (apply cl-func cl-args) cl-res)
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 (setq cl-p cl-args)
47662
a6d932b28650 (cl-push, cl-pop): Remove. Use pop and push throughout the file instead.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45699
diff changeset
141 (while cl-p (setcar cl-p (cdr (pop cl-p)) )))
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 (nreverse cl-res))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 (let ((cl-res nil))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 (while cl-list
47662
a6d932b28650 (cl-push, cl-pop): Remove. Use pop and push throughout the file instead.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45699
diff changeset
145 (push (funcall cl-func cl-list) cl-res)
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 (setq cl-list (cdr cl-list)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 (nreverse cl-res))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148
28667
0569ba69aa2b (cl-old-mapc): Fix definition.
Dave Love <fx@gnu.org>
parents: 28565
diff changeset
149 (defun cl-mapc (cl-func cl-seq &rest cl-rest)
62627
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
150 "Like `mapcar', but does not accumulate values returned by the function.
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
151 \n(fn FUNCTION SEQUENCE...)"
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 (if cl-rest
28565
69dea80bbb87 Don't quote keywords.
Dave Love <fx@gnu.org>
parents: 27588
diff changeset
153 (progn (apply 'map nil cl-func cl-seq cl-rest)
69dea80bbb87 Don't quote keywords.
Dave Love <fx@gnu.org>
parents: 27588
diff changeset
154 cl-seq)
30074
e06697d4135f (cl-old-mapc): Removed; don't defalias mapc.
Gerd Moellmann <gerd@gnu.org>
parents: 28667
diff changeset
155 (mapc cl-func cl-seq)))
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 (defun mapl (cl-func cl-list &rest cl-rest)
62627
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
158 "Like `maplist', but does not accumulate values returned by the function.
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
159 \n(fn FUNCTION LIST...)"
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 (if cl-rest
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 (apply 'maplist cl-func cl-list cl-rest)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 (let ((cl-p cl-list))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 (while cl-p (funcall cl-func cl-p) (setq cl-p (cdr cl-p)))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 cl-list)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 (defun mapcan (cl-func cl-seq &rest cl-rest)
62627
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
167 "Like `mapcar', but nconc's together the values returned by the function.
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
168 \n(fn FUNCTION SEQUENCE...)"
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 (apply 'nconc (apply 'mapcar* cl-func cl-seq cl-rest)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 (defun mapcon (cl-func cl-list &rest cl-rest)
62627
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
172 "Like `maplist', but nconc's together the values returned by the function.
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
173 \n(fn FUNCTION LIST...)"
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 (apply 'nconc (apply 'maplist cl-func cl-list cl-rest)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 (defun some (cl-pred cl-seq &rest cl-rest)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 "Return true if PREDICATE is true of any element of SEQ or SEQs.
62627
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
178 If so, return the true (non-nil) value returned by PREDICATE.
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
179 \n(fn PREDICATE SEQ...)"
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 (if (or cl-rest (nlistp cl-seq))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 (catch 'cl-some
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 (apply 'map nil
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 (function (lambda (&rest cl-x)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 (let ((cl-res (apply cl-pred cl-x)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 (if cl-res (throw 'cl-some cl-res)))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 cl-seq cl-rest) nil)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 (let ((cl-x nil))
47662
a6d932b28650 (cl-push, cl-pop): Remove. Use pop and push throughout the file instead.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45699
diff changeset
188 (while (and cl-seq (not (setq cl-x (funcall cl-pred (pop cl-seq))))))
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 cl-x)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 (defun every (cl-pred cl-seq &rest cl-rest)
62627
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
192 "Return true if PREDICATE is true of every element of SEQ or SEQs.
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
193 \n(fn PREDICATE SEQ...)"
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 (if (or cl-rest (nlistp cl-seq))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 (catch 'cl-every
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 (apply 'map nil
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 (function (lambda (&rest cl-x)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 (or (apply cl-pred cl-x) (throw 'cl-every nil))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 cl-seq cl-rest) t)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 (while (and cl-seq (funcall cl-pred (car cl-seq)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 (setq cl-seq (cdr cl-seq)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 (null cl-seq)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 (defun notany (cl-pred cl-seq &rest cl-rest)
62627
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
205 "Return true if PREDICATE is false of every element of SEQ or SEQs.
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
206 \n(fn PREDICATE SEQ...)"
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 (not (apply 'some cl-pred cl-seq cl-rest)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 (defun notevery (cl-pred cl-seq &rest cl-rest)
62627
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
210 "Return true if PREDICATE is false of some element of SEQ or SEQs.
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
211 \n(fn PREDICATE SEQ...)"
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 (not (apply 'every cl-pred cl-seq cl-rest)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 ;;; Support for `loop'.
50802
fe838fc4d9a9 (cl-map-keymap): Redefine as alias.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47662
diff changeset
215 (defalias 'cl-map-keymap 'map-keymap)
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 (defun cl-map-keymap-recursively (cl-func-rec cl-map &optional cl-base)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 (or cl-base
27123
b153112d5bd0 (cl-emacs-type): Remove defvar.
Dave Love <fx@gnu.org>
parents: 24988
diff changeset
219 (setq cl-base (copy-sequence [0])))
50802
fe838fc4d9a9 (cl-map-keymap): Redefine as alias.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47662
diff changeset
220 (map-keymap
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 (function
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 (lambda (cl-key cl-bind)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 (aset cl-base (1- (length cl-base)) cl-key)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 (if (keymapp cl-bind)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 (cl-map-keymap-recursively
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 cl-func-rec cl-bind
27123
b153112d5bd0 (cl-emacs-type): Remove defvar.
Dave Love <fx@gnu.org>
parents: 24988
diff changeset
227 (vconcat cl-base (list 0)))
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 (funcall cl-func-rec cl-base cl-bind))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 cl-map))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 (defun cl-map-intervals (cl-func &optional cl-what cl-prop cl-start cl-end)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 (or cl-what (setq cl-what (current-buffer)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 (if (bufferp cl-what)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 (let (cl-mark cl-mark2 (cl-next t) cl-next2)
28565
69dea80bbb87 Don't quote keywords.
Dave Love <fx@gnu.org>
parents: 27588
diff changeset
235 (with-current-buffer cl-what
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 (setq cl-mark (copy-marker (or cl-start (point-min))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 (setq cl-mark2 (and cl-end (copy-marker cl-end))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 (while (and cl-next (or (not cl-mark2) (< cl-mark cl-mark2)))
28565
69dea80bbb87 Don't quote keywords.
Dave Love <fx@gnu.org>
parents: 27588
diff changeset
239 (setq cl-next (if cl-prop (next-single-property-change
69dea80bbb87 Don't quote keywords.
Dave Love <fx@gnu.org>
parents: 27588
diff changeset
240 cl-mark cl-prop cl-what)
69dea80bbb87 Don't quote keywords.
Dave Love <fx@gnu.org>
parents: 27588
diff changeset
241 (next-property-change cl-mark cl-what))
69dea80bbb87 Don't quote keywords.
Dave Love <fx@gnu.org>
parents: 27588
diff changeset
242 cl-next2 (or cl-next (with-current-buffer cl-what
69dea80bbb87 Don't quote keywords.
Dave Love <fx@gnu.org>
parents: 27588
diff changeset
243 (point-max))))
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 (funcall cl-func (prog1 (marker-position cl-mark)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 (set-marker cl-mark cl-next2))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 (if cl-mark2 (min cl-next2 cl-mark2) cl-next2)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 (set-marker cl-mark nil) (if cl-mark2 (set-marker cl-mark2 nil)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248 (or cl-start (setq cl-start 0))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 (or cl-end (setq cl-end (length cl-what)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 (while (< cl-start cl-end)
28565
69dea80bbb87 Don't quote keywords.
Dave Love <fx@gnu.org>
parents: 27588
diff changeset
251 (let ((cl-next (or (if cl-prop (next-single-property-change
69dea80bbb87 Don't quote keywords.
Dave Love <fx@gnu.org>
parents: 27588
diff changeset
252 cl-start cl-prop cl-what)
69dea80bbb87 Don't quote keywords.
Dave Love <fx@gnu.org>
parents: 27588
diff changeset
253 (next-property-change cl-start cl-what))
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 cl-end)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 (funcall cl-func cl-start (min cl-next cl-end))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 (setq cl-start cl-next)))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 (defun cl-map-overlays (cl-func &optional cl-buffer cl-start cl-end cl-arg)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 (or cl-buffer (setq cl-buffer (current-buffer)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 (if (fboundp 'overlay-lists)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 ;; This is the preferred algorithm, though overlay-lists is undocumented.
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 (let (cl-ovl)
28565
69dea80bbb87 Don't quote keywords.
Dave Love <fx@gnu.org>
parents: 27588
diff changeset
264 (with-current-buffer cl-buffer
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 (setq cl-ovl (overlay-lists))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 (if cl-start (setq cl-start (copy-marker cl-start)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 (if cl-end (setq cl-end (copy-marker cl-end))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 (setq cl-ovl (nconc (car cl-ovl) (cdr cl-ovl)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 (while (and cl-ovl
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 (or (not (overlay-start (car cl-ovl)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 (and cl-end (>= (overlay-start (car cl-ovl)) cl-end))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 (and cl-start (<= (overlay-end (car cl-ovl)) cl-start))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 (not (funcall cl-func (car cl-ovl) cl-arg))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 (setq cl-ovl (cdr cl-ovl)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 (if cl-start (set-marker cl-start nil))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 (if cl-end (set-marker cl-end nil)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 ;; This alternate algorithm fails to find zero-length overlays.
28565
69dea80bbb87 Don't quote keywords.
Dave Love <fx@gnu.org>
parents: 27588
diff changeset
279 (let ((cl-mark (with-current-buffer cl-buffer
69dea80bbb87 Don't quote keywords.
Dave Love <fx@gnu.org>
parents: 27588
diff changeset
280 (copy-marker (or cl-start (point-min)))))
69dea80bbb87 Don't quote keywords.
Dave Love <fx@gnu.org>
parents: 27588
diff changeset
281 (cl-mark2 (and cl-end (with-current-buffer cl-buffer
69dea80bbb87 Don't quote keywords.
Dave Love <fx@gnu.org>
parents: 27588
diff changeset
282 (copy-marker cl-end))))
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 cl-pos cl-ovl)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 (while (save-excursion
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 (and (setq cl-pos (marker-position cl-mark))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 (< cl-pos (or cl-mark2 (point-max)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 (progn
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 (set-buffer cl-buffer)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 (setq cl-ovl (overlays-at cl-pos))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 (set-marker cl-mark (next-overlay-change cl-pos)))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 (while (and cl-ovl
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 (or (/= (overlay-start (car cl-ovl)) cl-pos)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 (not (and (funcall cl-func (car cl-ovl) cl-arg)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 (set-marker cl-mark nil)))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 (setq cl-ovl (cdr cl-ovl))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 (set-marker cl-mark nil) (if cl-mark2 (set-marker cl-mark2 nil)))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 ;;; Support for `setf'.
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 (defun cl-set-frame-visible-p (frame val)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 (cond ((null val) (make-frame-invisible frame))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 ((eq val 'icon) (iconify-frame frame))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 (t (make-frame-visible frame)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 val)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 ;;; Support for `progv'.
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 (defvar cl-progv-save)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 (defun cl-progv-before (syms values)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 (while syms
47662
a6d932b28650 (cl-push, cl-pop): Remove. Use pop and push throughout the file instead.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45699
diff changeset
309 (push (if (boundp (car syms))
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 (cons (car syms) (symbol-value (car syms)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 (car syms)) cl-progv-save)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 (if values
47662
a6d932b28650 (cl-push, cl-pop): Remove. Use pop and push throughout the file instead.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45699
diff changeset
313 (set (pop syms) (pop values))
a6d932b28650 (cl-push, cl-pop): Remove. Use pop and push throughout the file instead.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45699
diff changeset
314 (makunbound (pop syms)))))
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 (defun cl-progv-after ()
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 (while cl-progv-save
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 (if (consp (car cl-progv-save))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 (set (car (car cl-progv-save)) (cdr (car cl-progv-save)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 (makunbound (car cl-progv-save)))
47662
a6d932b28650 (cl-push, cl-pop): Remove. Use pop and push throughout the file instead.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45699
diff changeset
321 (pop cl-progv-save)))
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 ;;; Numbers.
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 (defun gcd (&rest args)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 "Return the greatest common divisor of the arguments."
47662
a6d932b28650 (cl-push, cl-pop): Remove. Use pop and push throughout the file instead.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45699
diff changeset
328 (let ((a (abs (or (pop args) 0))))
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 (while args
47662
a6d932b28650 (cl-push, cl-pop): Remove. Use pop and push throughout the file instead.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45699
diff changeset
330 (let ((b (abs (pop args))))
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 (while (> b 0) (setq b (% a (setq a b))))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 a))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 (defun lcm (&rest args)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 "Return the least common multiple of the arguments."
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 (if (memq 0 args)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 0
47662
a6d932b28650 (cl-push, cl-pop): Remove. Use pop and push throughout the file instead.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45699
diff changeset
338 (let ((a (abs (or (pop args) 1))))
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 (while args
47662
a6d932b28650 (cl-push, cl-pop): Remove. Use pop and push throughout the file instead.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45699
diff changeset
340 (let ((b (abs (pop args))))
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341 (setq a (* (/ a (gcd a b)) b))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 a)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343
62627
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
344 (defun isqrt (x)
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345 "Return the integer square root of the argument."
62627
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
346 (if (and (integerp x) (> x 0))
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
347 (let ((g (cond ((<= x 100) 10) ((<= x 10000) 100)
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
348 ((<= x 1000000) 1000) (t x)))
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 g2)
62627
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
350 (while (< (setq g2 (/ (+ g (/ x g)) 2)) g)
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 (setq g g2))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 g)
62627
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
353 (if (eq x 0) 0 (signal 'arith-error nil))))
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355 (defun floor* (x &optional y)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356 "Return a list of the floor of X and the fractional part of X.
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357 With two arguments, return floor and remainder of their quotient."
4517
45e3868140f1 (floor*): Use `floor' instead of doing most the work ourselves.
Paul Eggert <eggert@twinsun.com>
parents: 4355
diff changeset
358 (let ((q (floor x y)))
45e3868140f1 (floor*): Use `floor' instead of doing most the work ourselves.
Paul Eggert <eggert@twinsun.com>
parents: 4355
diff changeset
359 (list q (- x (if y (* y q) q)))))
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 (defun ceiling* (x &optional y)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362 "Return a list of the ceiling of X and the fractional part of X.
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363 With two arguments, return ceiling and remainder of their quotient."
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364 (let ((res (floor* x y)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365 (if (= (car (cdr res)) 0) res
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366 (list (1+ (car res)) (- (car (cdr res)) (or y 1))))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368 (defun truncate* (x &optional y)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 "Return a list of the integer part of X and the fractional part of X.
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370 With two arguments, return truncation and remainder of their quotient."
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371 (if (eq (>= x 0) (or (null y) (>= y 0)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372 (floor* x y) (ceiling* x y)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 (defun round* (x &optional y)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 "Return a list of X rounded to the nearest integer and the remainder.
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 With two arguments, return rounding and remainder of their quotient."
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 (if y
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378 (if (and (integerp x) (integerp y))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 (let* ((hy (/ y 2))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 (res (floor* (+ x hy) y)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381 (if (and (= (car (cdr res)) 0)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382 (= (+ hy hy) y)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 (/= (% (car res) 2) 0))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 (list (1- (car res)) hy)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 (list (car res) (- (car (cdr res)) hy))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386 (let ((q (round (/ x y))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 (list q (- x (* q y)))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388 (if (integerp x) (list x 0)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389 (let ((q (round x)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390 (list q (- x q))))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 (defun mod* (x y)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393 "The remainder of X divided by Y, with the same sign as Y."
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 (nth 1 (floor* x y)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396 (defun rem* (x y)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397 "The remainder of X divided by Y, with the same sign as X."
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 (nth 1 (truncate* x y)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399
62627
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
400 (defun signum (x)
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
401 "Return 1 if X is positive, -1 if negative, 0 if zero."
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
402 (cond ((> x 0) 1) ((< x 0) -1) (t 0)))
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 ;; Random numbers.
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 (defvar *random-state*)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
408 (defun random* (lim &optional state)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409 "Return a random nonnegative number less than LIM, an integer or float.
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 Optional second arg STATE is a random-state object."
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 (or state (setq state *random-state*))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 ;; Inspired by "ran3" from Numerical Recipes. Additive congruential method.
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 (let ((vec (aref state 3)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414 (if (integerp vec)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 (let ((i 0) (j (- 1357335 (% (abs vec) 1357333))) (k 1) ii)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 (aset state 3 (setq vec (make-vector 55 nil)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 (aset vec 0 j)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 (while (> (setq i (% (+ i 21) 55)) 0)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 (aset vec i (setq j (prog1 k (setq k (- j k))))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 (while (< (setq i (1+ i)) 200) (random* 2 state))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 (let* ((i (aset state 1 (% (1+ (aref state 1)) 55)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 (j (aset state 2 (% (1+ (aref state 2)) 55)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 (n (logand 8388607 (aset vec i (- (aref vec i) (aref vec j))))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 (if (integerp lim)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 (if (<= lim 512) (% n lim)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 (if (> lim 8388607) (setq n (+ (lsh n 9) (random* 512 state))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 (let ((mask 1023))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 (while (< mask (1- lim)) (setq mask (1+ (+ mask mask))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429 (if (< (setq n (logand n mask)) lim) n (random* lim state))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 (* (/ n '8388608e0) lim)))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 (defun make-random-state (&optional state)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 "Return a copy of random-state STATE, or of `*random-state*' if omitted.
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 If STATE is t, return a new state object seeded from the time of day."
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 (cond ((null state) (make-random-state *random-state*))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 ((vectorp state) (cl-copy-tree state t))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437 ((integerp state) (vector 'cl-random-state-tag -1 30 state))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 (t (make-random-state (cl-random-time)))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440 (defun random-state-p (object)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441 "Return t if OBJECT is a random-state object."
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442 (and (vectorp object) (= (length object) 4)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 (eq (aref object 0) 'cl-random-state-tag)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 ;; Implementation limits.
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
447
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
448 (defun cl-finite-do (func a b)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
449 (condition-case err
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
450 (let ((res (funcall func a b))) ; check for IEEE infinity
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
451 (and (numberp res) (/= res (/ res 2)) res))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452 (arith-error nil)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
453
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454 (defvar most-positive-float)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455 (defvar most-negative-float)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456 (defvar least-positive-float)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457 (defvar least-negative-float)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458 (defvar least-positive-normalized-float)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
459 (defvar least-negative-normalized-float)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
460 (defvar float-epsilon)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
461 (defvar float-negative-epsilon)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
462
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
463 (defun cl-float-limits ()
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
464 (or most-positive-float (not (numberp '2e1))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
465 (let ((x '2e0) y z)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
466 ;; Find maximum exponent (first two loops are optimizations)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467 (while (cl-finite-do '* x x) (setq x (* x x)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468 (while (cl-finite-do '* x (/ x 2)) (setq x (* x (/ x 2))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
469 (while (cl-finite-do '+ x x) (setq x (+ x x)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470 (setq z x y (/ x 2))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471 ;; Now fill in 1's in the mantissa.
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
472 (while (and (cl-finite-do '+ x y) (/= (+ x y) x))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
473 (setq x (+ x y) y (/ y 2)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
474 (setq most-positive-float x
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
475 most-negative-float (- x))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476 ;; Divide down until mantissa starts rounding.
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477 (setq x (/ x z) y (/ 16 z) x (* x y))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 (while (condition-case err (and (= x (* (/ x 2) 2)) (> (/ y 2) 0))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479 (arith-error nil))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 (setq x (/ x 2) y (/ y 2)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 (setq least-positive-normalized-float y
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482 least-negative-normalized-float (- y))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483 ;; Divide down until value underflows to zero.
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484 (setq x (/ 1 z) y x)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485 (while (condition-case err (> (/ x 2) 0) (arith-error nil))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486 (setq x (/ x 2)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487 (setq least-positive-float x
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488 least-negative-float (- x))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489 (setq x '1e0)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490 (while (/= (+ '1e0 x) '1e0) (setq x (/ x 2)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491 (setq float-epsilon (* x 2))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492 (setq x '1e0)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493 (while (/= (- '1e0 x) '1e0) (setq x (/ x 2)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494 (setq float-negative-epsilon (* x 2))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
495 nil)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
496
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498 ;;; Sequence functions.
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500 (defun subseq (seq start &optional end)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
501 "Return the subsequence of SEQ from START to END.
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502 If END is omitted, it defaults to the length of the sequence.
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503 If START or END is negative, it counts from the end."
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504 (if (stringp seq) (substring seq start end)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505 (let (len)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506 (and end (< end 0) (setq end (+ end (setq len (length seq)))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
507 (if (< start 0) (setq start (+ start (or len (setq len (length seq))))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508 (cond ((listp seq)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509 (if (> start 0) (setq seq (nthcdr start seq)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510 (if end
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511 (let ((res nil))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 (while (>= (setq end (1- end)) start)
47662
a6d932b28650 (cl-push, cl-pop): Remove. Use pop and push throughout the file instead.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45699
diff changeset
513 (push (pop seq) res))
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514 (nreverse res))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 (copy-sequence seq)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516 (t
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517 (or end (setq end (or len (length seq))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
518 (let ((res (make-vector (max (- end start) 0) nil))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519 (i 0))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520 (while (< start end)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521 (aset res i (aref seq start))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
522 (setq i (1+ i) start (1+ start)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
523 res))))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
524
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
525 (defun concatenate (type &rest seqs)
62627
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
526 "Concatenate, into a sequence of type TYPE, the argument SEQUENCEs.
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
527 \n(fn TYPE SEQUENCE...)"
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
528 (cond ((eq type 'vector) (apply 'vconcat seqs))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529 ((eq type 'string) (apply 'concat seqs))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
530 ((eq type 'list) (apply 'append (append seqs '(nil))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531 (t (error "Not a sequence type name: %s" type))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534 ;;; List functions.
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536 (defun revappend (x y)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
537 "Equivalent to (append (reverse X) Y)."
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
538 (nconc (reverse x) y))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
539
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
540 (defun nreconc (x y)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
541 "Equivalent to (nconc (nreverse X) Y)."
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
542 (nconc (nreverse x) y))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
543
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
544 (defun list-length (x)
62627
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
545 "Return the length of list X. Return nil if list is circular."
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
546 (let ((n 0) (fast x) (slow x))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
547 (while (and (cdr fast) (not (and (eq fast slow) (> n 0))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
548 (setq n (+ n 2) fast (cdr (cdr fast)) slow (cdr slow)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549 (if fast (if (cdr fast) nil (1+ n)) n)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
550
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
551 (defun tailp (sublist list)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
552 "Return true if SUBLIST is a tail of LIST."
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
553 (while (and (consp list) (not (eq sublist list)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
554 (setq list (cdr list)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
555 (if (numberp sublist) (equal sublist list) (eq sublist list)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
556
45699
5204b7681bdc (cl-copy-tree): Moved to `copy-tree' in subr.el. Add a defalias with
Colin Walters <walters@gnu.org>
parents: 32481
diff changeset
557 (defalias 'cl-copy-tree 'copy-tree)
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
558
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
559
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
560 ;;; Property lists.
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
561
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
562 (defun get* (sym tag &optional def) ; See compiler macro in cl-macs.el
62627
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
563 "Return the value of SYMBOL's PROPNAME property, or DEFAULT if none.
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
564 \n(fn SYMBOL PROPNAME &optional DEFAULT)"
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565 (or (get sym tag)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
566 (and def
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
567 (let ((plist (symbol-plist sym)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
568 (while (and plist (not (eq (car plist) tag)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
569 (setq plist (cdr (cdr plist))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
570 (if plist (car (cdr plist)) def)))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
571
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
572 (defun getf (plist tag &optional def)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
573 "Search PROPLIST for property PROPNAME; return its value or DEFAULT.
62627
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
574 PROPLIST is a list of the sort returned by `symbol-plist'.
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
575 \n(fn PROPLIST PROPNAME &optional DEFAULT)"
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
576 (setplist '--cl-getf-symbol-- plist)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
577 (or (get '--cl-getf-symbol-- tag)
24826
a134726a4a15 (getf): Don't call get*.
Karl Heuer <kwzh@gnu.org>
parents: 16057
diff changeset
578 ;; Originally we called get* here,
a134726a4a15 (getf): Don't call get*.
Karl Heuer <kwzh@gnu.org>
parents: 16057
diff changeset
579 ;; but that fails, because get* has a compiler macro
a134726a4a15 (getf): Don't call get*.
Karl Heuer <kwzh@gnu.org>
parents: 16057
diff changeset
580 ;; definition that uses getf!
a134726a4a15 (getf): Don't call get*.
Karl Heuer <kwzh@gnu.org>
parents: 16057
diff changeset
581 (when def
a134726a4a15 (getf): Don't call get*.
Karl Heuer <kwzh@gnu.org>
parents: 16057
diff changeset
582 (while (and plist (not (eq (car plist) tag)))
a134726a4a15 (getf): Don't call get*.
Karl Heuer <kwzh@gnu.org>
parents: 16057
diff changeset
583 (setq plist (cdr (cdr plist))))
a134726a4a15 (getf): Don't call get*.
Karl Heuer <kwzh@gnu.org>
parents: 16057
diff changeset
584 (if plist (car (cdr plist)) def))))
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
585
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
586 (defun cl-set-getf (plist tag val)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587 (let ((p plist))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
588 (while (and p (not (eq (car p) tag))) (setq p (cdr (cdr p))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
589 (if p (progn (setcar (cdr p) val) plist) (list* tag val plist))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
590
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
591 (defun cl-do-remf (plist tag)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
592 (let ((p (cdr plist)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
593 (while (and (cdr p) (not (eq (car (cdr p)) tag))) (setq p (cdr (cdr p))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
594 (and (cdr p) (progn (setcdr p (cdr (cdr (cdr p)))) t))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
595
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
596 (defun cl-remprop (sym tag)
62627
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
597 "Remove from SYMBOL's plist the property PROPNAME and its value.
30ac735c84d8 (coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
Juanma Barranquero <lekktu@gmail.com>
parents: 62409
diff changeset
598 \n(fn SYMBOL PROPNAME)"
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
599 (let ((plist (symbol-plist sym)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
600 (if (and plist (eq tag (car plist)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
601 (progn (setplist sym (cdr (cdr plist))) t)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
602 (cl-do-remf plist tag))))
28565
69dea80bbb87 Don't quote keywords.
Dave Love <fx@gnu.org>
parents: 27588
diff changeset
603 (defalias 'remprop 'cl-remprop)
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
604
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
605
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
606
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
607 ;;; Hash tables.
47662
a6d932b28650 (cl-push, cl-pop): Remove. Use pop and push throughout the file instead.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45699
diff changeset
608 ;; This is just kept for compatibility with code byte-compiled by Emacs-20.
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
609
47662
a6d932b28650 (cl-push, cl-pop): Remove. Use pop and push throughout the file instead.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45699
diff changeset
610 ;; No idea if this might still be needed.
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
611 (defun cl-not-hash-table (x &optional y &rest z)
27123
b153112d5bd0 (cl-emacs-type): Remove defvar.
Dave Love <fx@gnu.org>
parents: 24988
diff changeset
612 (signal 'wrong-type-argument (list 'cl-hash-table-p (or y x))))
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
613
32481
4372fcfffc7f (cl-builtin-gethash, cl-builtin-remhash)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30086
diff changeset
614 (defvar cl-builtin-gethash (symbol-function 'gethash))
4372fcfffc7f (cl-builtin-gethash, cl-builtin-remhash)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30086
diff changeset
615 (defvar cl-builtin-remhash (symbol-function 'remhash))
4372fcfffc7f (cl-builtin-gethash, cl-builtin-remhash)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30086
diff changeset
616 (defvar cl-builtin-clrhash (symbol-function 'clrhash))
4372fcfffc7f (cl-builtin-gethash, cl-builtin-remhash)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30086
diff changeset
617 (defvar cl-builtin-maphash (symbol-function 'maphash))
4372fcfffc7f (cl-builtin-gethash, cl-builtin-remhash)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30086
diff changeset
618
47662
a6d932b28650 (cl-push, cl-pop): Remove. Use pop and push throughout the file instead.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45699
diff changeset
619 (defalias 'cl-gethash 'gethash)
a6d932b28650 (cl-push, cl-pop): Remove. Use pop and push throughout the file instead.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45699
diff changeset
620 (defalias 'cl-puthash 'puthash)
a6d932b28650 (cl-push, cl-pop): Remove. Use pop and push throughout the file instead.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45699
diff changeset
621 (defalias 'cl-remhash 'remhash)
a6d932b28650 (cl-push, cl-pop): Remove. Use pop and push throughout the file instead.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45699
diff changeset
622 (defalias 'cl-clrhash 'clrhash)
a6d932b28650 (cl-push, cl-pop): Remove. Use pop and push throughout the file instead.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45699
diff changeset
623 (defalias 'cl-maphash 'maphash)
a6d932b28650 (cl-push, cl-pop): Remove. Use pop and push throughout the file instead.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45699
diff changeset
624 ;; These three actually didn't exist in Emacs-20.
a6d932b28650 (cl-push, cl-pop): Remove. Use pop and push throughout the file instead.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45699
diff changeset
625 (defalias 'cl-make-hash-table 'make-hash-table)
a6d932b28650 (cl-push, cl-pop): Remove. Use pop and push throughout the file instead.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45699
diff changeset
626 (defalias 'cl-hash-table-p 'hash-table-p)
a6d932b28650 (cl-push, cl-pop): Remove. Use pop and push throughout the file instead.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45699
diff changeset
627 (defalias 'cl-hash-table-count 'hash-table-count)
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
628
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
629 ;;; Some debugging aids.
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
630
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
631 (defun cl-prettyprint (form)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
632 "Insert a pretty-printed rendition of a Lisp FORM in current buffer."
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
633 (let ((pt (point)) last)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
634 (insert "\n" (prin1-to-string form) "\n")
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
635 (setq last (point))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
636 (goto-char (1+ pt))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
637 (while (search-forward "(quote " last t)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
638 (delete-backward-char 7)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
639 (insert "'")
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
640 (forward-sexp)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
641 (delete-char 1))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
642 (goto-char (1+ pt))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
643 (cl-do-prettyprint)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
644
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
645 (defun cl-do-prettyprint ()
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
646 (skip-chars-forward " ")
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
647 (if (looking-at "(")
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
648 (let ((skip (or (looking-at "((") (looking-at "(prog")
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
649 (looking-at "(unwind-protect ")
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
650 (looking-at "(function (")
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
651 (looking-at "(cl-block-wrapper ")))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
652 (two (or (looking-at "(defun ") (looking-at "(defmacro ")))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
653 (let (or (looking-at "(let\\*? ") (looking-at "(while ")))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
654 (set (looking-at "(p?set[qf] ")))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
655 (if (or skip let
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
656 (progn
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
657 (forward-sexp)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
658 (and (>= (current-column) 78) (progn (backward-sexp) t))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
659 (let ((nl t))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
660 (forward-char 1)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
661 (cl-do-prettyprint)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
662 (or skip (looking-at ")") (cl-do-prettyprint))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
663 (or (not two) (looking-at ")") (cl-do-prettyprint))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
664 (while (not (looking-at ")"))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
665 (if set (setq nl (not nl)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
666 (if nl (insert "\n"))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
667 (lisp-indent-line)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
668 (cl-do-prettyprint))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
669 (forward-char 1))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
670 (forward-sexp)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
671
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
672 (defvar cl-macroexpand-cmacs nil)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
673 (defvar cl-closure-vars nil)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
674
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
675 (defun cl-macroexpand-all (form &optional env)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
676 "Expand all macro calls through a Lisp FORM.
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
677 This also does some trivial optimizations to make the form prettier."
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
678 (while (or (not (eq form (setq form (macroexpand form env))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
679 (and cl-macroexpand-cmacs
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
680 (not (eq form (setq form (compiler-macroexpand form)))))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
681 (cond ((not (consp form)) form)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
682 ((memq (car form) '(let let*))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
683 (if (null (nth 1 form))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
684 (cl-macroexpand-all (cons 'progn (cddr form)) env)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
685 (let ((letf nil) (res nil) (lets (cadr form)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
686 (while lets
47662
a6d932b28650 (cl-push, cl-pop): Remove. Use pop and push throughout the file instead.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45699
diff changeset
687 (push (if (consp (car lets))
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
688 (let ((exp (cl-macroexpand-all (caar lets) env)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
689 (or (symbolp exp) (setq letf t))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
690 (cons exp (cl-macroexpand-body (cdar lets) env)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
691 (let ((exp (cl-macroexpand-all (car lets) env)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
692 (if (symbolp exp) exp
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
693 (setq letf t) (list exp nil)))) res)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
694 (setq lets (cdr lets)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
695 (list* (if letf (if (eq (car form) 'let) 'letf 'letf*) (car form))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
696 (nreverse res) (cl-macroexpand-body (cddr form) env)))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
697 ((eq (car form) 'cond)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
698 (cons (car form)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
699 (mapcar (function (lambda (x) (cl-macroexpand-body x env)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
700 (cdr form))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
701 ((eq (car form) 'condition-case)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
702 (list* (car form) (nth 1 form) (cl-macroexpand-all (nth 2 form) env)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
703 (mapcar (function
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
704 (lambda (x)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
705 (cons (car x) (cl-macroexpand-body (cdr x) env))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
706 (cdddr form))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
707 ((memq (car form) '(quote function))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
708 (if (eq (car-safe (nth 1 form)) 'lambda)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
709 (let ((body (cl-macroexpand-body (cddadr form) env)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
710 (if (and cl-closure-vars (eq (car form) 'function)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
711 (cl-expr-contains-any body cl-closure-vars))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
712 (let* ((new (mapcar 'gensym cl-closure-vars))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
713 (sub (pairlis cl-closure-vars new)) (decls nil))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
714 (while (or (stringp (car body))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
715 (eq (car-safe (car body)) 'interactive))
47662
a6d932b28650 (cl-push, cl-pop): Remove. Use pop and push throughout the file instead.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45699
diff changeset
716 (push (list 'quote (pop body)) decls))
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
717 (put (car (last cl-closure-vars)) 'used t)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
718 (append
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
719 (list 'list '(quote lambda) '(quote (&rest --cl-rest--)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
720 (sublis sub (nreverse decls))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
721 (list
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
722 (list* 'list '(quote apply)
50802
fe838fc4d9a9 (cl-map-keymap): Redefine as alias.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47662
diff changeset
723 (list 'function
fe838fc4d9a9 (cl-map-keymap): Redefine as alias.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47662
diff changeset
724 (list* 'lambda
fe838fc4d9a9 (cl-map-keymap): Redefine as alias.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47662
diff changeset
725 (append new (cadadr form))
fe838fc4d9a9 (cl-map-keymap): Redefine as alias.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47662
diff changeset
726 (sublis sub body)))
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
727 (nconc (mapcar (function
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
728 (lambda (x)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
729 (list 'list '(quote quote) x)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
730 cl-closure-vars)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
731 '((quote --cl-rest--)))))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
732 (list (car form) (list* 'lambda (cadadr form) body))))
15029
ba44a899c055 (isqrt): Support expanded range of Lisp integers.
Richard M. Stallman <rms@gnu.org>
parents: 14794
diff changeset
733 (let ((found (assq (cadr form) env)))
51584
0fdf268507e5 (cl-macroexpand-all):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50802
diff changeset
734 (if (and found (ignore-errors
0fdf268507e5 (cl-macroexpand-all):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50802
diff changeset
735 (eq (cadr (caddr found)) 'cl-labels-args)))
15029
ba44a899c055 (isqrt): Support expanded range of Lisp integers.
Richard M. Stallman <rms@gnu.org>
parents: 14794
diff changeset
736 (cl-macroexpand-all (cadr (caddr (cadddr found))) env)
ba44a899c055 (isqrt): Support expanded range of Lisp integers.
Richard M. Stallman <rms@gnu.org>
parents: 14794
diff changeset
737 form))))
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
738 ((memq (car form) '(defun defmacro))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
739 (list* (car form) (nth 1 form) (cl-macroexpand-body (cddr form) env)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
740 ((and (eq (car form) 'progn) (not (cddr form)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
741 (cl-macroexpand-all (nth 1 form) env))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
742 ((eq (car form) 'setq)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
743 (let* ((args (cl-macroexpand-body (cdr form) env)) (p args))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
744 (while (and p (symbolp (car p))) (setq p (cddr p)))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
745 (if p (cl-macroexpand-all (cons 'setf args)) (cons 'setq args))))
67650
bb585f2cd98c (cl-macroexpand-all): Fix code-walk for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64751
diff changeset
746 ((consp (car form))
bb585f2cd98c (cl-macroexpand-all): Fix code-walk for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64751
diff changeset
747 (cl-macroexpand-all (list* 'funcall
bb585f2cd98c (cl-macroexpand-all): Fix code-walk for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64751
diff changeset
748 (list 'function (car form))
bb585f2cd98c (cl-macroexpand-all): Fix code-walk for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64751
diff changeset
749 (cdr form))
bb585f2cd98c (cl-macroexpand-all): Fix code-walk for
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64751
diff changeset
750 env))
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
751 (t (cons (car form) (cl-macroexpand-body (cdr form) env)))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
752
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
753 (defun cl-macroexpand-body (body &optional env)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
754 (mapcar (function (lambda (x) (cl-macroexpand-all x env))) body))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
755
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
756 (defun cl-prettyexpand (form &optional full)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
757 (message "Expanding...")
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
758 (let ((cl-macroexpand-cmacs full) (cl-compiling-file full)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
759 (byte-compile-macro-environment nil))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
760 (setq form (cl-macroexpand-all form
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
761 (and (not full) '((block) (eval-when)))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
762 (message "Formatting...")
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
763 (prog1 (cl-prettyprint form)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
764 (message ""))))
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
765
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
766
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
767
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
768 (run-hooks 'cl-extra-load-hook)
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
769
64684
eb2cbda455c6 Require CL also when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64085
diff changeset
770 ;; arch-tag: bcd03437-0871-43fb-a8f1-ad0e0b5427ed
4355
691a28818487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
771 ;;; cl-extra.el ends here