aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Love2000-04-13 19:03:34 +0000
committerDave Love2000-04-13 19:03:34 +0000
commitcf6bc7c3a5b147e2885ada538f1244ad7d7b58a4 (patch)
treef6161b37ba82a74d4aa6b68b87b1a5e901c3d470
parent8eba343c5bff98e27b12822f8fba16c4204e8f4d (diff)
downloademacs-cf6bc7c3a5b147e2885ada538f1244ad7d7b58a4.tar.gz
emacs-cf6bc7c3a5b147e2885ada538f1244ad7d7b58a4.zip
Don't quote keywords.
(cl-old-mapc): New variable. (mapc): Use it. (cl-map-intervals): Use with-current-buffer. Don't check for next-property-change. (cl-map-overlays): Use with-current-buffer. (cl-expt): Remove. (copy-tree, remprop): Define unconditionally.
-rw-r--r--lisp/emacs-lisp/cl-extra.el59
1 files changed, 24 insertions, 35 deletions
diff --git a/lisp/emacs-lisp/cl-extra.el b/lisp/emacs-lisp/cl-extra.el
index 9c6e17e9fec..505fa2cc3d0 100644
--- a/lisp/emacs-lisp/cl-extra.el
+++ b/lisp/emacs-lisp/cl-extra.el
@@ -152,12 +152,14 @@ the elements themselves."
152 (setq cl-list (cdr cl-list))) 152 (setq cl-list (cdr cl-list)))
153 (nreverse cl-res)))) 153 (nreverse cl-res))))
154 154
155(defvar cl-old-mapc (symbol-function 'mapc))
156
155(defun mapc (cl-func cl-seq &rest cl-rest) 157(defun mapc (cl-func cl-seq &rest cl-rest)
156 "Like `mapcar', but does not accumulate values returned by the function." 158 "Like `mapcar', but does not accumulate values returned by the function."
157 (if cl-rest 159 (if cl-rest
158 (apply 'map nil cl-func cl-seq cl-rest) 160 (progn (apply 'map nil cl-func cl-seq cl-rest)
159 (mapcar cl-func cl-seq)) 161 cl-seq)
160 cl-seq) 162 (funcall #'cl-old-mapc cl-func cl-seq)))
161 163
162(defun mapl (cl-func cl-list &rest cl-rest) 164(defun mapl (cl-func cl-list &rest cl-rest)
163 "Like `maplist', but does not accumulate values returned by the function." 165 "Like `maplist', but does not accumulate values returned by the function."
@@ -244,17 +246,15 @@ If so, return the true (non-nil) value returned by PREDICATE."
244 (or cl-what (setq cl-what (current-buffer))) 246 (or cl-what (setq cl-what (current-buffer)))
245 (if (bufferp cl-what) 247 (if (bufferp cl-what)
246 (let (cl-mark cl-mark2 (cl-next t) cl-next2) 248 (let (cl-mark cl-mark2 (cl-next t) cl-next2)
247 (save-excursion 249 (with-current-buffer cl-what
248 (set-buffer cl-what)
249 (setq cl-mark (copy-marker (or cl-start (point-min)))) 250 (setq cl-mark (copy-marker (or cl-start (point-min))))
250 (setq cl-mark2 (and cl-end (copy-marker cl-end)))) 251 (setq cl-mark2 (and cl-end (copy-marker cl-end))))
251 (while (and cl-next (or (not cl-mark2) (< cl-mark cl-mark2))) 252 (while (and cl-next (or (not cl-mark2) (< cl-mark cl-mark2)))
252 (setq cl-next (and (fboundp 'next-property-change) 253 (setq cl-next (if cl-prop (next-single-property-change
253 (if cl-prop (next-single-property-change 254 cl-mark cl-prop cl-what)
254 cl-mark cl-prop cl-what) 255 (next-property-change cl-mark cl-what))
255 (next-property-change cl-mark cl-what))) 256 cl-next2 (or cl-next (with-current-buffer cl-what
256 cl-next2 (or cl-next (save-excursion 257 (point-max))))
257 (set-buffer cl-what) (point-max))))
258 (funcall cl-func (prog1 (marker-position cl-mark) 258 (funcall cl-func (prog1 (marker-position cl-mark)
259 (set-marker cl-mark cl-next2)) 259 (set-marker cl-mark cl-next2))
260 (if cl-mark2 (min cl-next2 cl-mark2) cl-next2))) 260 (if cl-mark2 (min cl-next2 cl-mark2) cl-next2)))
@@ -262,10 +262,9 @@ If so, return the true (non-nil) value returned by PREDICATE."
262 (or cl-start (setq cl-start 0)) 262 (or cl-start (setq cl-start 0))
263 (or cl-end (setq cl-end (length cl-what))) 263 (or cl-end (setq cl-end (length cl-what)))
264 (while (< cl-start cl-end) 264 (while (< cl-start cl-end)
265 (let ((cl-next (or (and (fboundp 'next-property-change) 265 (let ((cl-next (or (if cl-prop (next-single-property-change
266 (if cl-prop (next-single-property-change 266 cl-start cl-prop cl-what)
267 cl-start cl-prop cl-what) 267 (next-property-change cl-start cl-what))
268 (next-property-change cl-start cl-what)))
269 cl-end))) 268 cl-end)))
270 (funcall cl-func cl-start (min cl-next cl-end)) 269 (funcall cl-func cl-start (min cl-next cl-end))
271 (setq cl-start cl-next))))) 270 (setq cl-start cl-next)))))
@@ -276,8 +275,7 @@ If so, return the true (non-nil) value returned by PREDICATE."
276 275
277 ;; This is the preferred algorithm, though overlay-lists is undocumented. 276 ;; This is the preferred algorithm, though overlay-lists is undocumented.
278 (let (cl-ovl) 277 (let (cl-ovl)
279 (save-excursion 278 (with-current-buffer cl-buffer
280 (set-buffer cl-buffer)
281 (setq cl-ovl (overlay-lists)) 279 (setq cl-ovl (overlay-lists))
282 (if cl-start (setq cl-start (copy-marker cl-start))) 280 (if cl-start (setq cl-start (copy-marker cl-start)))
283 (if cl-end (setq cl-end (copy-marker cl-end)))) 281 (if cl-end (setq cl-end (copy-marker cl-end))))
@@ -292,10 +290,10 @@ If so, return the true (non-nil) value returned by PREDICATE."
292 (if cl-end (set-marker cl-end nil))) 290 (if cl-end (set-marker cl-end nil)))
293 291
294 ;; This alternate algorithm fails to find zero-length overlays. 292 ;; This alternate algorithm fails to find zero-length overlays.
295 (let ((cl-mark (save-excursion (set-buffer cl-buffer) 293 (let ((cl-mark (with-current-buffer cl-buffer
296 (copy-marker (or cl-start (point-min))))) 294 (copy-marker (or cl-start (point-min)))))
297 (cl-mark2 (and cl-end (save-excursion (set-buffer cl-buffer) 295 (cl-mark2 (and cl-end (with-current-buffer cl-buffer
298 (copy-marker cl-end)))) 296 (copy-marker cl-end))))
299 cl-pos cl-ovl) 297 cl-pos cl-ovl)
300 (while (save-excursion 298 (while (save-excursion
301 (and (setq cl-pos (marker-position cl-mark)) 299 (and (setq cl-pos (marker-position cl-mark))
@@ -368,13 +366,6 @@ If so, return the true (non-nil) value returned by PREDICATE."
368 g) 366 g)
369 (if (eq a 0) 0 (signal 'arith-error nil)))) 367 (if (eq a 0) 0 (signal 'arith-error nil))))
370 368
371(defun cl-expt (x y)
372 "Return X raised to the power of Y. Works only for integer arguments."
373 (if (<= y 0) (if (= y 0) 1 (if (memq x '(-1 1)) (cl-expt x (- y)) 0))
374 (* (if (= (% y 2) 0) 1 x) (cl-expt (* x x) (/ y 2)))))
375(or (and (fboundp 'expt) (subrp (symbol-function 'expt)))
376 (defalias 'expt 'cl-expt))
377
378(defun floor* (x &optional y) 369(defun floor* (x &optional y)
379 "Return a list of the floor of X and the fractional part of X. 370 "Return a list of the floor of X and the fractional part of X.
380With two arguments, return floor and remainder of their quotient." 371With two arguments, return floor and remainder of their quotient."
@@ -593,8 +584,7 @@ argument VECP, this copies vectors as well as conses."
593 (while (>= (setq i (1- i)) 0) 584 (while (>= (setq i (1- i)) 0)
594 (aset tree i (cl-copy-tree (aref tree i) vecp)))))) 585 (aset tree i (cl-copy-tree (aref tree i) vecp))))))
595 tree) 586 tree)
596(or (and (fboundp 'copy-tree) (subrp (symbol-function 'copy-tree))) 587(defalias 'copy-tree 'cl-copy-tree)
597 (defalias 'copy-tree 'cl-copy-tree))
598 588
599 589
600;;; Property lists. 590;;; Property lists.
@@ -637,8 +627,7 @@ PROPLIST is a list of the sort returned by `symbol-plist'."
637 (if (and plist (eq tag (car plist))) 627 (if (and plist (eq tag (car plist)))
638 (progn (setplist sym (cdr (cdr plist))) t) 628 (progn (setplist sym (cdr (cdr plist))) t)
639 (cl-do-remf plist tag)))) 629 (cl-do-remf plist tag))))
640(or (and (fboundp 'remprop) (subrp (symbol-function 'remprop))) 630(defalias 'remprop 'cl-remprop)
641 (defalias 'remprop 'cl-remprop))
642 631
643 632
644 633
@@ -648,8 +637,8 @@ PROPLIST is a list of the sort returned by `symbol-plist'."
648 "Make an empty Common Lisp-style hash-table. 637 "Make an empty Common Lisp-style hash-table.
649Keywords supported: :test :size 638Keywords supported: :test :size
650The Common Lisp keywords :rehash-size and :rehash-threshold are ignored." 639The Common Lisp keywords :rehash-size and :rehash-threshold are ignored."
651 (let ((cl-test (or (car (cdr (memq ':test cl-keys))) 'eql)) 640 (let ((cl-test (or (car (cdr (memq :test cl-keys))) 'eql))
652 (cl-size (or (car (cdr (memq ':size cl-keys))) 20))) 641 (cl-size (or (car (cdr (memq :size cl-keys))) 20)))
653 (make-hash-table :size cl-size :test cl-size))) 642 (make-hash-table :size cl-size :test cl-size)))
654 643
655(defun cl-hash-table-p (x) 644(defun cl-hash-table-p (x)
@@ -678,7 +667,7 @@ The Common Lisp keywords :rehash-size and :rehash-threshold are ignored."
678 (and (eq test 'eql) (not (numberp key)))) 667 (and (eq test 'eql) (not (numberp key))))
679 (assq key sym)) 668 (assq key sym))
680 ((memq test '(eql equal)) (assoc key sym)) 669 ((memq test '(eql equal)) (assoc key sym))
681 (t (assoc* key sym ':test test)))) 670 (t (assoc* key sym :test test))))
682 sym str))) 671 sym str)))
683 672
684(defun cl-gethash (key table &optional def) 673(defun cl-gethash (key table &optional def)