Use lexical-binding for all of CL, and clean up its namespace.
* lisp/emacs-lisp/cl-lib.el: Use lexical-binding.
(cl-map-extents, cl-maclisp-member): Remove.
(cl--set-elt, cl--set-nthcdr, cl--set-buffer-substring)
(cl--set-substring, cl--block-wrapper, cl--block-throw)
(cl--compiling-file, cl--mapcar-many, cl--do-subst): Use "cl--" prefix.
* lisp/emacs-lisp/cl-extra.el: Use lexical-binding.
(cl--mapcar-many, cl--map-keymap-recursively, cl--map-intervals)
(cl--map-overlays, cl--set-frame-visible-p, cl--progv-save)
(cl--progv-before, cl--progv-after, cl--finite-do, cl--set-getf)
(cl--do-remf, cl--do-prettyprint): Use "cl--" prefix.
* lisp/emacs-lisp/cl-seq.el: Use lexical-binding.
(cl--parsing-keywords, cl--check-key, cl--check-test-nokey)
(cl--check-test, cl--check-match): Use "cl--" prefix and backquotes.
(cl--alist, cl--sublis-rec, cl--nsublis-rec, cl--tree-equal-rec):
* lisp/emacs-lisp/cl-macs.el (cl--lambda-list-keywords): Use "cl--" prefix.
* lisp/edmacro.el (edmacro-mismatch): Simplify to remove dependence on
CL's internals.
2012-06-11 15:52:50 +00:00
|
|
|
;;; cl-extra.el --- Common Lisp features, part 2 -*- lexical-binding: t -*-
|
1993-07-30 20:15:09 +00:00
|
|
|
|
2014-01-01 07:43:34 +00:00
|
|
|
;; Copyright (C) 1993, 2000-2014 Free Software Foundation, Inc.
|
1993-07-30 20:15:09 +00:00
|
|
|
|
|
|
|
;; Author: Dave Gillespie <daveg@synaptics.com>
|
|
|
|
;; Keywords: extensions
|
2010-08-29 16:17:13 +00:00
|
|
|
;; Package: emacs
|
1993-07-30 20:15:09 +00:00
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
2008-05-06 03:21:21 +00:00
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
1993-07-30 20:15:09 +00:00
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 03:21:21 +00:00
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
1993-07-30 20:15:09 +00:00
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2008-05-06 03:21:21 +00:00
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
1993-07-30 20:15:09 +00:00
|
|
|
|
1994-06-17 20:04:22 +00:00
|
|
|
;;; Commentary:
|
1993-07-30 20:15:09 +00:00
|
|
|
|
|
|
|
;; These are extensions to Emacs Lisp that provide a degree of
|
|
|
|
;; Common Lisp compatibility, beyond what is already built-in
|
|
|
|
;; in Emacs Lisp.
|
|
|
|
;;
|
|
|
|
;; This package was written by Dave Gillespie; it is a complete
|
|
|
|
;; rewrite of Cesar Quiroz's original cl.el package of December 1986.
|
|
|
|
;;
|
|
|
|
;; Bug reports, comments, and suggestions are welcome!
|
|
|
|
|
|
|
|
;; This file contains portions of the Common Lisp extensions
|
|
|
|
;; package which are autoloaded since they are relatively obscure.
|
|
|
|
|
1994-06-17 20:04:22 +00:00
|
|
|
;;; Code:
|
1993-07-30 20:15:09 +00:00
|
|
|
|
2012-06-04 01:05:17 +00:00
|
|
|
(require 'cl-lib)
|
1993-07-30 20:15:09 +00:00
|
|
|
|
|
|
|
;;; Type coercion.
|
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
2012-06-04 01:05:17 +00:00
|
|
|
(defun cl-coerce (x type)
|
1993-07-30 20:15:09 +00:00
|
|
|
"Coerce OBJECT to type TYPE.
|
(coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
notevery, signum, isqrt, concatenate, list-length, get*, getf, cl-remprop):
Improve argument/docstring consistency.
2005-05-22 17:48:02 +00:00
|
|
|
TYPE is a Common Lisp type specifier.
|
|
|
|
\n(fn OBJECT TYPE)"
|
1993-07-30 20:15:09 +00:00
|
|
|
(cond ((eq type 'list) (if (listp x) x (append x nil)))
|
|
|
|
((eq type 'vector) (if (vectorp x) x (vconcat x)))
|
|
|
|
((eq type 'string) (if (stringp x) x (concat x)))
|
|
|
|
((eq type 'array) (if (arrayp x) x (vconcat x)))
|
|
|
|
((and (eq type 'character) (stringp x) (= (length x) 1)) (aref x 0))
|
2012-12-06 21:29:29 +00:00
|
|
|
((and (eq type 'character) (symbolp x))
|
|
|
|
(cl-coerce (symbol-name x) type))
|
1993-07-30 20:15:09 +00:00
|
|
|
((eq type 'float) (float x))
|
2012-06-04 01:05:17 +00:00
|
|
|
((cl-typep x type) x)
|
1993-07-30 20:15:09 +00:00
|
|
|
(t (error "Can't coerce %s to type %s" x type))))
|
|
|
|
|
|
|
|
|
|
|
|
;;; Predicates.
|
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
2012-06-04 01:05:17 +00:00
|
|
|
(defun cl-equalp (x y)
|
2005-05-16 15:32:09 +00:00
|
|
|
"Return t if two Lisp objects have similar structures and contents.
|
1993-07-30 20:15:09 +00:00
|
|
|
This is like `equal', except that it accepts numerically equal
|
|
|
|
numbers of different types (float vs. integer), and also compares
|
|
|
|
strings case-insensitively."
|
|
|
|
(cond ((eq x y) t)
|
|
|
|
((stringp x)
|
|
|
|
(and (stringp y) (= (length x) (length y))
|
1996-03-08 18:30:12 +00:00
|
|
|
(or (string-equal x y)
|
2012-12-06 21:29:29 +00:00
|
|
|
(string-equal (downcase x) (downcase y))))) ;Lazy but simple!
|
1993-07-30 20:15:09 +00:00
|
|
|
((numberp x)
|
|
|
|
(and (numberp y) (= x y)))
|
|
|
|
((consp x)
|
2012-06-04 01:05:17 +00:00
|
|
|
(while (and (consp x) (consp y) (cl-equalp (car x) (car y)))
|
1996-03-05 22:53:55 +00:00
|
|
|
(setq x (cdr x) y (cdr y)))
|
2012-06-04 01:05:17 +00:00
|
|
|
(and (not (consp x)) (cl-equalp x y)))
|
1993-07-30 20:15:09 +00:00
|
|
|
((vectorp x)
|
|
|
|
(and (vectorp y) (= (length x) (length y))
|
|
|
|
(let ((i (length x)))
|
|
|
|
(while (and (>= (setq i (1- i)) 0)
|
2012-06-04 01:05:17 +00:00
|
|
|
(cl-equalp (aref x i) (aref y i))))
|
1993-07-30 20:15:09 +00:00
|
|
|
(< i 0))))
|
|
|
|
(t (equal x y))))
|
|
|
|
|
|
|
|
|
|
|
|
;;; Control structures.
|
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
Use lexical-binding for all of CL, and clean up its namespace.
* lisp/emacs-lisp/cl-lib.el: Use lexical-binding.
(cl-map-extents, cl-maclisp-member): Remove.
(cl--set-elt, cl--set-nthcdr, cl--set-buffer-substring)
(cl--set-substring, cl--block-wrapper, cl--block-throw)
(cl--compiling-file, cl--mapcar-many, cl--do-subst): Use "cl--" prefix.
* lisp/emacs-lisp/cl-extra.el: Use lexical-binding.
(cl--mapcar-many, cl--map-keymap-recursively, cl--map-intervals)
(cl--map-overlays, cl--set-frame-visible-p, cl--progv-save)
(cl--progv-before, cl--progv-after, cl--finite-do, cl--set-getf)
(cl--do-remf, cl--do-prettyprint): Use "cl--" prefix.
* lisp/emacs-lisp/cl-seq.el: Use lexical-binding.
(cl--parsing-keywords, cl--check-key, cl--check-test-nokey)
(cl--check-test, cl--check-match): Use "cl--" prefix and backquotes.
(cl--alist, cl--sublis-rec, cl--nsublis-rec, cl--tree-equal-rec):
* lisp/emacs-lisp/cl-macs.el (cl--lambda-list-keywords): Use "cl--" prefix.
* lisp/edmacro.el (edmacro-mismatch): Simplify to remove dependence on
CL's internals.
2012-06-11 15:52:50 +00:00
|
|
|
(defun cl--mapcar-many (cl-func cl-seqs)
|
1993-07-30 20:15:09 +00:00
|
|
|
(if (cdr (cdr cl-seqs))
|
|
|
|
(let* ((cl-res nil)
|
|
|
|
(cl-n (apply 'min (mapcar 'length cl-seqs)))
|
|
|
|
(cl-i 0)
|
|
|
|
(cl-args (copy-sequence cl-seqs))
|
|
|
|
cl-p1 cl-p2)
|
|
|
|
(setq cl-seqs (copy-sequence cl-seqs))
|
|
|
|
(while (< cl-i cl-n)
|
|
|
|
(setq cl-p1 cl-seqs cl-p2 cl-args)
|
|
|
|
(while cl-p1
|
|
|
|
(setcar cl-p2
|
|
|
|
(if (consp (car cl-p1))
|
|
|
|
(prog1 (car (car cl-p1))
|
|
|
|
(setcar cl-p1 (cdr (car cl-p1))))
|
|
|
|
(aref (car cl-p1) cl-i)))
|
|
|
|
(setq cl-p1 (cdr cl-p1) cl-p2 (cdr cl-p2)))
|
2002-09-27 22:32:48 +00:00
|
|
|
(push (apply cl-func cl-args) cl-res)
|
1993-07-30 20:15:09 +00:00
|
|
|
(setq cl-i (1+ cl-i)))
|
|
|
|
(nreverse cl-res))
|
|
|
|
(let ((cl-res nil)
|
|
|
|
(cl-x (car cl-seqs))
|
|
|
|
(cl-y (nth 1 cl-seqs)))
|
|
|
|
(let ((cl-n (min (length cl-x) (length cl-y)))
|
|
|
|
(cl-i -1))
|
|
|
|
(while (< (setq cl-i (1+ cl-i)) cl-n)
|
2002-09-27 22:32:48 +00:00
|
|
|
(push (funcall cl-func
|
2012-06-04 01:05:17 +00:00
|
|
|
(if (consp cl-x) (pop cl-x) (aref cl-x cl-i))
|
|
|
|
(if (consp cl-y) (pop cl-y) (aref cl-y cl-i)))
|
|
|
|
cl-res)))
|
1993-07-30 20:15:09 +00:00
|
|
|
(nreverse cl-res))))
|
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
2012-06-04 01:05:17 +00:00
|
|
|
(defun cl-map (cl-type cl-func cl-seq &rest cl-rest)
|
(coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
notevery, signum, isqrt, concatenate, list-length, get*, getf, cl-remprop):
Improve argument/docstring consistency.
2005-05-22 17:48:02 +00:00
|
|
|
"Map a FUNCTION across one or more SEQUENCEs, returning a sequence.
|
|
|
|
TYPE is the sequence type to return.
|
|
|
|
\n(fn TYPE FUNCTION SEQUENCE...)"
|
2012-06-04 01:05:17 +00:00
|
|
|
(let ((cl-res (apply 'cl-mapcar cl-func cl-seq cl-rest)))
|
|
|
|
(and cl-type (cl-coerce cl-res cl-type))))
|
1993-07-30 20:15:09 +00:00
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
2012-06-04 01:05:17 +00:00
|
|
|
(defun cl-maplist (cl-func cl-list &rest cl-rest)
|
(coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
notevery, signum, isqrt, concatenate, list-length, get*, getf, cl-remprop):
Improve argument/docstring consistency.
2005-05-22 17:48:02 +00:00
|
|
|
"Map FUNCTION to each sublist of LIST or LISTs.
|
2012-11-05 08:29:12 +00:00
|
|
|
Like `cl-mapcar', except applies to lists and their cdr's rather than to
|
(coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
notevery, signum, isqrt, concatenate, list-length, get*, getf, cl-remprop):
Improve argument/docstring consistency.
2005-05-22 17:48:02 +00:00
|
|
|
the elements themselves.
|
|
|
|
\n(fn FUNCTION LIST...)"
|
1993-07-30 20:15:09 +00:00
|
|
|
(if cl-rest
|
|
|
|
(let ((cl-res nil)
|
|
|
|
(cl-args (cons cl-list (copy-sequence cl-rest)))
|
|
|
|
cl-p)
|
|
|
|
(while (not (memq nil cl-args))
|
2002-09-27 22:32:48 +00:00
|
|
|
(push (apply cl-func cl-args) cl-res)
|
1993-07-30 20:15:09 +00:00
|
|
|
(setq cl-p cl-args)
|
2002-09-27 22:32:48 +00:00
|
|
|
(while cl-p (setcar cl-p (cdr (pop cl-p)) )))
|
1993-07-30 20:15:09 +00:00
|
|
|
(nreverse cl-res))
|
|
|
|
(let ((cl-res nil))
|
|
|
|
(while cl-list
|
2002-09-27 22:32:48 +00:00
|
|
|
(push (funcall cl-func cl-list) cl-res)
|
1993-07-30 20:15:09 +00:00
|
|
|
(setq cl-list (cdr cl-list)))
|
|
|
|
(nreverse cl-res))))
|
|
|
|
|
2012-10-30 08:03:22 +00:00
|
|
|
;;;###autoload
|
2000-04-19 22:31:21 +00:00
|
|
|
(defun cl-mapc (cl-func cl-seq &rest cl-rest)
|
2012-10-30 08:03:22 +00:00
|
|
|
"Like `cl-mapcar', but does not accumulate values returned by the function.
|
(coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
notevery, signum, isqrt, concatenate, list-length, get*, getf, cl-remprop):
Improve argument/docstring consistency.
2005-05-22 17:48:02 +00:00
|
|
|
\n(fn FUNCTION SEQUENCE...)"
|
1993-07-30 20:15:09 +00:00
|
|
|
(if cl-rest
|
2012-06-04 01:05:17 +00:00
|
|
|
(progn (apply 'cl-map nil cl-func cl-seq cl-rest)
|
2000-04-13 19:03:34 +00:00
|
|
|
cl-seq)
|
2000-07-05 17:29:40 +00:00
|
|
|
(mapc cl-func cl-seq)))
|
1993-07-30 20:15:09 +00:00
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
2012-06-04 01:05:17 +00:00
|
|
|
(defun cl-mapl (cl-func cl-list &rest cl-rest)
|
|
|
|
"Like `cl-maplist', but does not accumulate values returned by the function.
|
(coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
notevery, signum, isqrt, concatenate, list-length, get*, getf, cl-remprop):
Improve argument/docstring consistency.
2005-05-22 17:48:02 +00:00
|
|
|
\n(fn FUNCTION LIST...)"
|
1993-07-30 20:15:09 +00:00
|
|
|
(if cl-rest
|
2012-06-04 01:05:17 +00:00
|
|
|
(apply 'cl-maplist cl-func cl-list cl-rest)
|
1993-07-30 20:15:09 +00:00
|
|
|
(let ((cl-p cl-list))
|
|
|
|
(while cl-p (funcall cl-func cl-p) (setq cl-p (cdr cl-p)))))
|
|
|
|
cl-list)
|
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
2012-06-04 01:05:17 +00:00
|
|
|
(defun cl-mapcan (cl-func cl-seq &rest cl-rest)
|
2012-11-05 08:29:12 +00:00
|
|
|
"Like `cl-mapcar', but nconc's together the values returned by the function.
|
(coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
notevery, signum, isqrt, concatenate, list-length, get*, getf, cl-remprop):
Improve argument/docstring consistency.
2005-05-22 17:48:02 +00:00
|
|
|
\n(fn FUNCTION SEQUENCE...)"
|
2012-06-04 01:05:17 +00:00
|
|
|
(apply 'nconc (apply 'cl-mapcar cl-func cl-seq cl-rest)))
|
1993-07-30 20:15:09 +00:00
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
2012-06-04 01:05:17 +00:00
|
|
|
(defun cl-mapcon (cl-func cl-list &rest cl-rest)
|
|
|
|
"Like `cl-maplist', but nconc's together the values returned by the function.
|
(coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
notevery, signum, isqrt, concatenate, list-length, get*, getf, cl-remprop):
Improve argument/docstring consistency.
2005-05-22 17:48:02 +00:00
|
|
|
\n(fn FUNCTION LIST...)"
|
2012-06-04 01:05:17 +00:00
|
|
|
(apply 'nconc (apply 'cl-maplist cl-func cl-list cl-rest)))
|
1993-07-30 20:15:09 +00:00
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
2012-06-04 01:05:17 +00:00
|
|
|
(defun cl-some (cl-pred cl-seq &rest cl-rest)
|
1993-07-30 20:15:09 +00:00
|
|
|
"Return true if PREDICATE is true of any element of SEQ or SEQs.
|
(coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
notevery, signum, isqrt, concatenate, list-length, get*, getf, cl-remprop):
Improve argument/docstring consistency.
2005-05-22 17:48:02 +00:00
|
|
|
If so, return the true (non-nil) value returned by PREDICATE.
|
|
|
|
\n(fn PREDICATE SEQ...)"
|
1993-07-30 20:15:09 +00:00
|
|
|
(if (or cl-rest (nlistp cl-seq))
|
|
|
|
(catch 'cl-some
|
2012-06-04 01:05:17 +00:00
|
|
|
(apply 'cl-map nil
|
1993-07-30 20:15:09 +00:00
|
|
|
(function (lambda (&rest cl-x)
|
|
|
|
(let ((cl-res (apply cl-pred cl-x)))
|
|
|
|
(if cl-res (throw 'cl-some cl-res)))))
|
|
|
|
cl-seq cl-rest) nil)
|
|
|
|
(let ((cl-x nil))
|
2002-09-27 22:32:48 +00:00
|
|
|
(while (and cl-seq (not (setq cl-x (funcall cl-pred (pop cl-seq))))))
|
1993-07-30 20:15:09 +00:00
|
|
|
cl-x)))
|
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
2012-06-04 01:05:17 +00:00
|
|
|
(defun cl-every (cl-pred cl-seq &rest cl-rest)
|
(coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
notevery, signum, isqrt, concatenate, list-length, get*, getf, cl-remprop):
Improve argument/docstring consistency.
2005-05-22 17:48:02 +00:00
|
|
|
"Return true if PREDICATE is true of every element of SEQ or SEQs.
|
|
|
|
\n(fn PREDICATE SEQ...)"
|
1993-07-30 20:15:09 +00:00
|
|
|
(if (or cl-rest (nlistp cl-seq))
|
|
|
|
(catch 'cl-every
|
2012-06-04 01:05:17 +00:00
|
|
|
(apply 'cl-map nil
|
1993-07-30 20:15:09 +00:00
|
|
|
(function (lambda (&rest cl-x)
|
|
|
|
(or (apply cl-pred cl-x) (throw 'cl-every nil))))
|
|
|
|
cl-seq cl-rest) t)
|
|
|
|
(while (and cl-seq (funcall cl-pred (car cl-seq)))
|
|
|
|
(setq cl-seq (cdr cl-seq)))
|
|
|
|
(null cl-seq)))
|
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
2012-06-04 01:05:17 +00:00
|
|
|
(defun cl-notany (cl-pred cl-seq &rest cl-rest)
|
(coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
notevery, signum, isqrt, concatenate, list-length, get*, getf, cl-remprop):
Improve argument/docstring consistency.
2005-05-22 17:48:02 +00:00
|
|
|
"Return true if PREDICATE is false of every element of SEQ or SEQs.
|
|
|
|
\n(fn PREDICATE SEQ...)"
|
2012-06-04 01:05:17 +00:00
|
|
|
(not (apply 'cl-some cl-pred cl-seq cl-rest)))
|
1993-07-30 20:15:09 +00:00
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
2012-06-04 01:05:17 +00:00
|
|
|
(defun cl-notevery (cl-pred cl-seq &rest cl-rest)
|
(coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
notevery, signum, isqrt, concatenate, list-length, get*, getf, cl-remprop):
Improve argument/docstring consistency.
2005-05-22 17:48:02 +00:00
|
|
|
"Return true if PREDICATE is false of some element of SEQ or SEQs.
|
|
|
|
\n(fn PREDICATE SEQ...)"
|
2012-06-04 01:05:17 +00:00
|
|
|
(not (apply 'cl-every cl-pred cl-seq cl-rest)))
|
1993-07-30 20:15:09 +00:00
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
Use lexical-binding for all of CL, and clean up its namespace.
* lisp/emacs-lisp/cl-lib.el: Use lexical-binding.
(cl-map-extents, cl-maclisp-member): Remove.
(cl--set-elt, cl--set-nthcdr, cl--set-buffer-substring)
(cl--set-substring, cl--block-wrapper, cl--block-throw)
(cl--compiling-file, cl--mapcar-many, cl--do-subst): Use "cl--" prefix.
* lisp/emacs-lisp/cl-extra.el: Use lexical-binding.
(cl--mapcar-many, cl--map-keymap-recursively, cl--map-intervals)
(cl--map-overlays, cl--set-frame-visible-p, cl--progv-save)
(cl--progv-before, cl--progv-after, cl--finite-do, cl--set-getf)
(cl--do-remf, cl--do-prettyprint): Use "cl--" prefix.
* lisp/emacs-lisp/cl-seq.el: Use lexical-binding.
(cl--parsing-keywords, cl--check-key, cl--check-test-nokey)
(cl--check-test, cl--check-match): Use "cl--" prefix and backquotes.
(cl--alist, cl--sublis-rec, cl--nsublis-rec, cl--tree-equal-rec):
* lisp/emacs-lisp/cl-macs.el (cl--lambda-list-keywords): Use "cl--" prefix.
* lisp/edmacro.el (edmacro-mismatch): Simplify to remove dependence on
CL's internals.
2012-06-11 15:52:50 +00:00
|
|
|
(defun cl--map-keymap-recursively (cl-func-rec cl-map &optional cl-base)
|
1993-07-30 20:15:09 +00:00
|
|
|
(or cl-base
|
2000-01-03 23:12:38 +00:00
|
|
|
(setq cl-base (copy-sequence [0])))
|
2003-05-04 00:44:25 +00:00
|
|
|
(map-keymap
|
1993-07-30 20:15:09 +00:00
|
|
|
(function
|
|
|
|
(lambda (cl-key cl-bind)
|
|
|
|
(aset cl-base (1- (length cl-base)) cl-key)
|
|
|
|
(if (keymapp cl-bind)
|
Use lexical-binding for all of CL, and clean up its namespace.
* lisp/emacs-lisp/cl-lib.el: Use lexical-binding.
(cl-map-extents, cl-maclisp-member): Remove.
(cl--set-elt, cl--set-nthcdr, cl--set-buffer-substring)
(cl--set-substring, cl--block-wrapper, cl--block-throw)
(cl--compiling-file, cl--mapcar-many, cl--do-subst): Use "cl--" prefix.
* lisp/emacs-lisp/cl-extra.el: Use lexical-binding.
(cl--mapcar-many, cl--map-keymap-recursively, cl--map-intervals)
(cl--map-overlays, cl--set-frame-visible-p, cl--progv-save)
(cl--progv-before, cl--progv-after, cl--finite-do, cl--set-getf)
(cl--do-remf, cl--do-prettyprint): Use "cl--" prefix.
* lisp/emacs-lisp/cl-seq.el: Use lexical-binding.
(cl--parsing-keywords, cl--check-key, cl--check-test-nokey)
(cl--check-test, cl--check-match): Use "cl--" prefix and backquotes.
(cl--alist, cl--sublis-rec, cl--nsublis-rec, cl--tree-equal-rec):
* lisp/emacs-lisp/cl-macs.el (cl--lambda-list-keywords): Use "cl--" prefix.
* lisp/edmacro.el (edmacro-mismatch): Simplify to remove dependence on
CL's internals.
2012-06-11 15:52:50 +00:00
|
|
|
(cl--map-keymap-recursively
|
1993-07-30 20:15:09 +00:00
|
|
|
cl-func-rec cl-bind
|
2000-01-03 23:12:38 +00:00
|
|
|
(vconcat cl-base (list 0)))
|
1993-07-30 20:15:09 +00:00
|
|
|
(funcall cl-func-rec cl-base cl-bind))))
|
|
|
|
cl-map))
|
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
Use lexical-binding for all of CL, and clean up its namespace.
* lisp/emacs-lisp/cl-lib.el: Use lexical-binding.
(cl-map-extents, cl-maclisp-member): Remove.
(cl--set-elt, cl--set-nthcdr, cl--set-buffer-substring)
(cl--set-substring, cl--block-wrapper, cl--block-throw)
(cl--compiling-file, cl--mapcar-many, cl--do-subst): Use "cl--" prefix.
* lisp/emacs-lisp/cl-extra.el: Use lexical-binding.
(cl--mapcar-many, cl--map-keymap-recursively, cl--map-intervals)
(cl--map-overlays, cl--set-frame-visible-p, cl--progv-save)
(cl--progv-before, cl--progv-after, cl--finite-do, cl--set-getf)
(cl--do-remf, cl--do-prettyprint): Use "cl--" prefix.
* lisp/emacs-lisp/cl-seq.el: Use lexical-binding.
(cl--parsing-keywords, cl--check-key, cl--check-test-nokey)
(cl--check-test, cl--check-match): Use "cl--" prefix and backquotes.
(cl--alist, cl--sublis-rec, cl--nsublis-rec, cl--tree-equal-rec):
* lisp/emacs-lisp/cl-macs.el (cl--lambda-list-keywords): Use "cl--" prefix.
* lisp/edmacro.el (edmacro-mismatch): Simplify to remove dependence on
CL's internals.
2012-06-11 15:52:50 +00:00
|
|
|
(defun cl--map-intervals (cl-func &optional cl-what cl-prop cl-start cl-end)
|
1993-07-30 20:15:09 +00:00
|
|
|
(or cl-what (setq cl-what (current-buffer)))
|
|
|
|
(if (bufferp cl-what)
|
|
|
|
(let (cl-mark cl-mark2 (cl-next t) cl-next2)
|
2000-04-13 19:03:34 +00:00
|
|
|
(with-current-buffer cl-what
|
1993-07-30 20:15:09 +00:00
|
|
|
(setq cl-mark (copy-marker (or cl-start (point-min))))
|
|
|
|
(setq cl-mark2 (and cl-end (copy-marker cl-end))))
|
|
|
|
(while (and cl-next (or (not cl-mark2) (< cl-mark cl-mark2)))
|
2000-04-13 19:03:34 +00:00
|
|
|
(setq cl-next (if cl-prop (next-single-property-change
|
|
|
|
cl-mark cl-prop cl-what)
|
|
|
|
(next-property-change cl-mark cl-what))
|
|
|
|
cl-next2 (or cl-next (with-current-buffer cl-what
|
|
|
|
(point-max))))
|
1993-07-30 20:15:09 +00:00
|
|
|
(funcall cl-func (prog1 (marker-position cl-mark)
|
|
|
|
(set-marker cl-mark cl-next2))
|
|
|
|
(if cl-mark2 (min cl-next2 cl-mark2) cl-next2)))
|
|
|
|
(set-marker cl-mark nil) (if cl-mark2 (set-marker cl-mark2 nil)))
|
|
|
|
(or cl-start (setq cl-start 0))
|
|
|
|
(or cl-end (setq cl-end (length cl-what)))
|
|
|
|
(while (< cl-start cl-end)
|
2000-04-13 19:03:34 +00:00
|
|
|
(let ((cl-next (or (if cl-prop (next-single-property-change
|
|
|
|
cl-start cl-prop cl-what)
|
|
|
|
(next-property-change cl-start cl-what))
|
1993-07-30 20:15:09 +00:00
|
|
|
cl-end)))
|
|
|
|
(funcall cl-func cl-start (min cl-next cl-end))
|
|
|
|
(setq cl-start cl-next)))))
|
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
Use lexical-binding for all of CL, and clean up its namespace.
* lisp/emacs-lisp/cl-lib.el: Use lexical-binding.
(cl-map-extents, cl-maclisp-member): Remove.
(cl--set-elt, cl--set-nthcdr, cl--set-buffer-substring)
(cl--set-substring, cl--block-wrapper, cl--block-throw)
(cl--compiling-file, cl--mapcar-many, cl--do-subst): Use "cl--" prefix.
* lisp/emacs-lisp/cl-extra.el: Use lexical-binding.
(cl--mapcar-many, cl--map-keymap-recursively, cl--map-intervals)
(cl--map-overlays, cl--set-frame-visible-p, cl--progv-save)
(cl--progv-before, cl--progv-after, cl--finite-do, cl--set-getf)
(cl--do-remf, cl--do-prettyprint): Use "cl--" prefix.
* lisp/emacs-lisp/cl-seq.el: Use lexical-binding.
(cl--parsing-keywords, cl--check-key, cl--check-test-nokey)
(cl--check-test, cl--check-match): Use "cl--" prefix and backquotes.
(cl--alist, cl--sublis-rec, cl--nsublis-rec, cl--tree-equal-rec):
* lisp/emacs-lisp/cl-macs.el (cl--lambda-list-keywords): Use "cl--" prefix.
* lisp/edmacro.el (edmacro-mismatch): Simplify to remove dependence on
CL's internals.
2012-06-11 15:52:50 +00:00
|
|
|
(defun cl--map-overlays (cl-func &optional cl-buffer cl-start cl-end cl-arg)
|
1993-07-30 20:15:09 +00:00
|
|
|
(or cl-buffer (setq cl-buffer (current-buffer)))
|
2014-03-20 18:16:47 +00:00
|
|
|
(let (cl-ovl)
|
|
|
|
(with-current-buffer cl-buffer
|
|
|
|
(setq cl-ovl (overlay-lists))
|
|
|
|
(if cl-start (setq cl-start (copy-marker cl-start)))
|
|
|
|
(if cl-end (setq cl-end (copy-marker cl-end))))
|
|
|
|
(setq cl-ovl (nconc (car cl-ovl) (cdr cl-ovl)))
|
|
|
|
(while (and cl-ovl
|
|
|
|
(or (not (overlay-start (car cl-ovl)))
|
|
|
|
(and cl-end (>= (overlay-start (car cl-ovl)) cl-end))
|
|
|
|
(and cl-start (<= (overlay-end (car cl-ovl)) cl-start))
|
|
|
|
(not (funcall cl-func (car cl-ovl) cl-arg))))
|
|
|
|
(setq cl-ovl (cdr cl-ovl)))
|
|
|
|
(if cl-start (set-marker cl-start nil))
|
|
|
|
(if cl-end (set-marker cl-end nil))))
|
1993-07-30 20:15:09 +00:00
|
|
|
|
Provide generalized variables in core Elisp.
* lisp/emacs-lisp/gv.el: New file.
* lisp/subr.el (push, pop): Extend to generalized variables.
* lisp/loadup.el (macroexp): Unload if preloaded and uncompiled.
* lisp/emacs-lisp/cl-lib.el (cl-pop, cl-push, cl--set-nthcdr): Remove.
* lisp/emacs-lisp/cl-macs.el: Require gv. Use gv-define-setter,
gv-define-simple-setter, and gv-define-expander.
Remove setf-methods defined in gv. Rename cl-setf -> setf.
(cl-setf, cl-do-pop, cl-get-setf-method): Remove.
(cl-letf, cl-letf*, cl-define-modify-macro, cl-defsetf)
(cl-define-setf-expander, cl-struct-setf-expander): Move to cl.el.
(cl-remf, cl-shiftf, cl-rotatef, cl-callf, cl-callf2): Rewrite with
gv-letplace.
(cl-defstruct): Don't define setf-method any more.
* lisp/emacs-lisp/cl.el (flet): Don't autoload.
(cl--letf, letf, cl--letf*, letf*, cl--gv-adapt)
(define-setf-expander, defsetf, define-modify-macro)
(cl-struct-setf-expander): Move from cl-lib.el.
* lisp/emacs-lisp/syntax.el:
* lisp/emacs-lisp/ewoc.el:
* lisp/emacs-lisp/smie.el:
* lisp/emacs-lisp/cconv.el:
* lisp/emacs-lisp/timer.el: Rename cl-setf -> setf, cl-push -> push.
(timer--time): Use gv-define-simple-setter.
* lisp/emacs-lisp/macroexp.el (macroexp-let2): Rename from macroexp-let²
to avoid coding-system problems in subr.el. Adjust all users.
(macroexp--maxsize, macroexp-small-p): New functions.
* lisp/emacs-lisp/bytecomp.el (byte-compile-file): Don't use cl-letf.
* lisp/scroll-bar.el (scroll-bar-mode):
* lisp/simple.el (auto-fill-mode, overwrite-mode, binary-overwrite-mode)
(normal-erase-is-backspace-mode): Don't use the `eq' place.
* lisp/winner.el (winner-configuration, winner-make-point-alist)
(winner-set-conf, winner-get-point, winner-set): Don't abuse letf.
* lisp/files.el (locate-file-completion-table): Avoid list*.
Fixes: debbugs:11657
2012-06-22 13:42:38 +00:00
|
|
|
;;; Support for `setf'.
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
Use lexical-binding for all of CL, and clean up its namespace.
* lisp/emacs-lisp/cl-lib.el: Use lexical-binding.
(cl-map-extents, cl-maclisp-member): Remove.
(cl--set-elt, cl--set-nthcdr, cl--set-buffer-substring)
(cl--set-substring, cl--block-wrapper, cl--block-throw)
(cl--compiling-file, cl--mapcar-many, cl--do-subst): Use "cl--" prefix.
* lisp/emacs-lisp/cl-extra.el: Use lexical-binding.
(cl--mapcar-many, cl--map-keymap-recursively, cl--map-intervals)
(cl--map-overlays, cl--set-frame-visible-p, cl--progv-save)
(cl--progv-before, cl--progv-after, cl--finite-do, cl--set-getf)
(cl--do-remf, cl--do-prettyprint): Use "cl--" prefix.
* lisp/emacs-lisp/cl-seq.el: Use lexical-binding.
(cl--parsing-keywords, cl--check-key, cl--check-test-nokey)
(cl--check-test, cl--check-match): Use "cl--" prefix and backquotes.
(cl--alist, cl--sublis-rec, cl--nsublis-rec, cl--tree-equal-rec):
* lisp/emacs-lisp/cl-macs.el (cl--lambda-list-keywords): Use "cl--" prefix.
* lisp/edmacro.el (edmacro-mismatch): Simplify to remove dependence on
CL's internals.
2012-06-11 15:52:50 +00:00
|
|
|
(defun cl--set-frame-visible-p (frame val)
|
1993-07-30 20:15:09 +00:00
|
|
|
(cond ((null val) (make-frame-invisible frame))
|
|
|
|
((eq val 'icon) (iconify-frame frame))
|
|
|
|
(t (make-frame-visible frame)))
|
|
|
|
val)
|
|
|
|
|
|
|
|
|
|
|
|
;;; Numbers.
|
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
2012-06-04 01:05:17 +00:00
|
|
|
(defun cl-gcd (&rest args)
|
1993-07-30 20:15:09 +00:00
|
|
|
"Return the greatest common divisor of the arguments."
|
2002-09-27 22:32:48 +00:00
|
|
|
(let ((a (abs (or (pop args) 0))))
|
1993-07-30 20:15:09 +00:00
|
|
|
(while args
|
2002-09-27 22:32:48 +00:00
|
|
|
(let ((b (abs (pop args))))
|
1993-07-30 20:15:09 +00:00
|
|
|
(while (> b 0) (setq b (% a (setq a b))))))
|
|
|
|
a))
|
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
2012-06-04 01:05:17 +00:00
|
|
|
(defun cl-lcm (&rest args)
|
1993-07-30 20:15:09 +00:00
|
|
|
"Return the least common multiple of the arguments."
|
|
|
|
(if (memq 0 args)
|
|
|
|
0
|
2002-09-27 22:32:48 +00:00
|
|
|
(let ((a (abs (or (pop args) 1))))
|
1993-07-30 20:15:09 +00:00
|
|
|
(while args
|
2002-09-27 22:32:48 +00:00
|
|
|
(let ((b (abs (pop args))))
|
2012-06-04 01:05:17 +00:00
|
|
|
(setq a (* (/ a (cl-gcd a b)) b))))
|
1993-07-30 20:15:09 +00:00
|
|
|
a)))
|
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
2012-06-04 01:05:17 +00:00
|
|
|
(defun cl-isqrt (x)
|
1993-07-30 20:15:09 +00:00
|
|
|
"Return the integer square root of the argument."
|
(coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
notevery, signum, isqrt, concatenate, list-length, get*, getf, cl-remprop):
Improve argument/docstring consistency.
2005-05-22 17:48:02 +00:00
|
|
|
(if (and (integerp x) (> x 0))
|
|
|
|
(let ((g (cond ((<= x 100) 10) ((<= x 10000) 100)
|
|
|
|
((<= x 1000000) 1000) (t x)))
|
1993-07-30 20:15:09 +00:00
|
|
|
g2)
|
(coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
notevery, signum, isqrt, concatenate, list-length, get*, getf, cl-remprop):
Improve argument/docstring consistency.
2005-05-22 17:48:02 +00:00
|
|
|
(while (< (setq g2 (/ (+ g (/ x g)) 2)) g)
|
1993-07-30 20:15:09 +00:00
|
|
|
(setq g g2))
|
|
|
|
g)
|
(coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
notevery, signum, isqrt, concatenate, list-length, get*, getf, cl-remprop):
Improve argument/docstring consistency.
2005-05-22 17:48:02 +00:00
|
|
|
(if (eq x 0) 0 (signal 'arith-error nil))))
|
1993-07-30 20:15:09 +00:00
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
2012-06-04 01:05:17 +00:00
|
|
|
(defun cl-floor (x &optional y)
|
1993-07-30 20:15:09 +00:00
|
|
|
"Return a list of the floor of X and the fractional part of X.
|
|
|
|
With two arguments, return floor and remainder of their quotient."
|
1993-08-10 04:14:17 +00:00
|
|
|
(let ((q (floor x y)))
|
|
|
|
(list q (- x (if y (* y q) q)))))
|
1993-07-30 20:15:09 +00:00
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
2012-06-04 01:05:17 +00:00
|
|
|
(defun cl-ceiling (x &optional y)
|
1993-07-30 20:15:09 +00:00
|
|
|
"Return a list of the ceiling of X and the fractional part of X.
|
|
|
|
With two arguments, return ceiling and remainder of their quotient."
|
2012-06-04 01:05:17 +00:00
|
|
|
(let ((res (cl-floor x y)))
|
1993-07-30 20:15:09 +00:00
|
|
|
(if (= (car (cdr res)) 0) res
|
|
|
|
(list (1+ (car res)) (- (car (cdr res)) (or y 1))))))
|
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
2012-06-04 01:05:17 +00:00
|
|
|
(defun cl-truncate (x &optional y)
|
1993-07-30 20:15:09 +00:00
|
|
|
"Return a list of the integer part of X and the fractional part of X.
|
|
|
|
With two arguments, return truncation and remainder of their quotient."
|
|
|
|
(if (eq (>= x 0) (or (null y) (>= y 0)))
|
2012-06-04 01:05:17 +00:00
|
|
|
(cl-floor x y) (cl-ceiling x y)))
|
1993-07-30 20:15:09 +00:00
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
2012-06-04 01:05:17 +00:00
|
|
|
(defun cl-round (x &optional y)
|
1993-07-30 20:15:09 +00:00
|
|
|
"Return a list of X rounded to the nearest integer and the remainder.
|
|
|
|
With two arguments, return rounding and remainder of their quotient."
|
|
|
|
(if y
|
|
|
|
(if (and (integerp x) (integerp y))
|
|
|
|
(let* ((hy (/ y 2))
|
2012-06-04 01:05:17 +00:00
|
|
|
(res (cl-floor (+ x hy) y)))
|
1993-07-30 20:15:09 +00:00
|
|
|
(if (and (= (car (cdr res)) 0)
|
|
|
|
(= (+ hy hy) y)
|
|
|
|
(/= (% (car res) 2) 0))
|
|
|
|
(list (1- (car res)) hy)
|
|
|
|
(list (car res) (- (car (cdr res)) hy))))
|
|
|
|
(let ((q (round (/ x y))))
|
|
|
|
(list q (- x (* q y)))))
|
|
|
|
(if (integerp x) (list x 0)
|
|
|
|
(let ((q (round x)))
|
|
|
|
(list q (- x q))))))
|
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
2012-06-04 01:05:17 +00:00
|
|
|
(defun cl-mod (x y)
|
1993-07-30 20:15:09 +00:00
|
|
|
"The remainder of X divided by Y, with the same sign as Y."
|
2012-06-04 01:05:17 +00:00
|
|
|
(nth 1 (cl-floor x y)))
|
1993-07-30 20:15:09 +00:00
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
2012-06-04 01:05:17 +00:00
|
|
|
(defun cl-rem (x y)
|
1993-07-30 20:15:09 +00:00
|
|
|
"The remainder of X divided by Y, with the same sign as X."
|
2012-06-04 01:05:17 +00:00
|
|
|
(nth 1 (cl-truncate x y)))
|
1993-07-30 20:15:09 +00:00
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
2012-06-04 01:05:17 +00:00
|
|
|
(defun cl-signum (x)
|
(coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
notevery, signum, isqrt, concatenate, list-length, get*, getf, cl-remprop):
Improve argument/docstring consistency.
2005-05-22 17:48:02 +00:00
|
|
|
"Return 1 if X is positive, -1 if negative, 0 if zero."
|
|
|
|
(cond ((> x 0) 1) ((< x 0) -1) (t 0)))
|
1993-07-30 20:15:09 +00:00
|
|
|
|
2014-09-26 00:15:21 +00:00
|
|
|
;;;###autoload
|
|
|
|
(cl-defun cl-parse-integer (string &key start end radix junk-allowed)
|
|
|
|
"Parse integer from the substring of STRING from START to END.
|
|
|
|
STRING may be surrounded by whitespace chars (chars with syntax ` ').
|
|
|
|
Other non-digit chars are considered junk.
|
|
|
|
RADIX is an integer between 2 and 36, the default is 10. Signal
|
|
|
|
an error if the substring between START and END cannot be parsed
|
|
|
|
as an integer unless JUNK-ALLOWED is non-nil."
|
|
|
|
(cl-check-type string string)
|
|
|
|
(let* ((start (or start 0))
|
|
|
|
(len (length string))
|
|
|
|
(end (or end len))
|
|
|
|
(radix (or radix 10)))
|
|
|
|
(or (<= start end len)
|
|
|
|
(error "Bad interval: [%d, %d)" start end))
|
|
|
|
(cl-flet ((skip-whitespace ()
|
|
|
|
(while (and (< start end)
|
|
|
|
(= 32 (char-syntax (aref string start))))
|
|
|
|
(setq start (1+ start)))))
|
|
|
|
(skip-whitespace)
|
|
|
|
(let ((sign (cl-case (and (< start end) (aref string start))
|
|
|
|
(?+ (cl-incf start) +1)
|
|
|
|
(?- (cl-incf start) -1)
|
|
|
|
(t +1)))
|
|
|
|
digit sum)
|
|
|
|
(while (and (< start end)
|
|
|
|
(setq digit (cl-digit-char-p (aref string start) radix)))
|
|
|
|
(setq sum (+ (* (or sum 0) radix) digit)
|
|
|
|
start (1+ start)))
|
|
|
|
(skip-whitespace)
|
|
|
|
(cond ((and junk-allowed (null sum)) sum)
|
|
|
|
(junk-allowed (* sign sum))
|
2014-09-26 02:01:17 +00:00
|
|
|
((or (/= start end) (null sum))
|
|
|
|
(error "Not an integer string: `%s'" string))
|
2014-09-26 00:15:21 +00:00
|
|
|
(t (* sign sum)))))))
|
|
|
|
|
1993-07-30 20:15:09 +00:00
|
|
|
|
|
|
|
;; Random numbers.
|
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
2012-06-04 01:05:17 +00:00
|
|
|
(defun cl-random (lim &optional state)
|
1993-07-30 20:15:09 +00:00
|
|
|
"Return a random nonnegative number less than LIM, an integer or float.
|
|
|
|
Optional second arg STATE is a random-state object."
|
2012-05-17 20:04:56 +00:00
|
|
|
(or state (setq state cl--random-state))
|
1993-07-30 20:15:09 +00:00
|
|
|
;; Inspired by "ran3" from Numerical Recipes. Additive congruential method.
|
|
|
|
(let ((vec (aref state 3)))
|
|
|
|
(if (integerp vec)
|
2007-06-27 19:13:46 +00:00
|
|
|
(let ((i 0) (j (- 1357335 (% (abs vec) 1357333))) (k 1))
|
1993-07-30 20:15:09 +00:00
|
|
|
(aset state 3 (setq vec (make-vector 55 nil)))
|
|
|
|
(aset vec 0 j)
|
|
|
|
(while (> (setq i (% (+ i 21) 55)) 0)
|
|
|
|
(aset vec i (setq j (prog1 k (setq k (- j k))))))
|
2012-06-04 01:05:17 +00:00
|
|
|
(while (< (setq i (1+ i)) 200) (cl-random 2 state))))
|
1993-07-30 20:15:09 +00:00
|
|
|
(let* ((i (aset state 1 (% (1+ (aref state 1)) 55)))
|
|
|
|
(j (aset state 2 (% (1+ (aref state 2)) 55)))
|
|
|
|
(n (logand 8388607 (aset vec i (- (aref vec i) (aref vec j))))))
|
|
|
|
(if (integerp lim)
|
|
|
|
(if (<= lim 512) (% n lim)
|
2012-06-04 01:05:17 +00:00
|
|
|
(if (> lim 8388607) (setq n (+ (lsh n 9) (cl-random 512 state))))
|
1993-07-30 20:15:09 +00:00
|
|
|
(let ((mask 1023))
|
|
|
|
(while (< mask (1- lim)) (setq mask (1+ (+ mask mask))))
|
2012-06-04 01:05:17 +00:00
|
|
|
(if (< (setq n (logand n mask)) lim) n (cl-random lim state))))
|
1993-07-30 20:15:09 +00:00
|
|
|
(* (/ n '8388608e0) lim)))))
|
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
2012-06-04 01:05:17 +00:00
|
|
|
(defun cl-make-random-state (&optional state)
|
2012-05-17 20:04:56 +00:00
|
|
|
"Return a copy of random-state STATE, or of the internal state if omitted.
|
1993-07-30 20:15:09 +00:00
|
|
|
If STATE is t, return a new state object seeded from the time of day."
|
2012-06-04 01:05:17 +00:00
|
|
|
(cond ((null state) (cl-make-random-state cl--random-state))
|
Move old compatiblity to cl.el. Remove cl-macroexpand-all.
* emacs-lisp/cl-extra.el (cl-map-keymap, cl-copy-tree)
(cl-not-hash-table, cl-builtin-gethash, cl-builtin-remhash)
(cl-builtin-clrhash, cl-builtin-maphash, cl-gethash, cl-puthash)
(cl-remhash, cl-clrhash, cl-maphash, cl-make-hash-table)
(cl-hash-table-p, cl-hash-table-count): Move to cl.el.
(cl-macroexpand-cmacs): Remove var.
(cl-macroexpand-all, cl-macroexpand-body): Remove funs.
Use macroexpand-all instead.
* emacs-lisp/cl-lib.el (cl-macro-environment): Remove decl.
(cl-macroexpand): Move to cl-macs.el and rename to cl--sm-macroexpand.
(cl-member): Remove old alias.
* emacs-lisp/cl-macs.el (cl-macro-environment): Remove var.
Use macroexpand-all-environment instead.
(cl--old-macroexpand): New var.
(cl--sm-macroexpand): New function.
(cl-symbol-macrolet): Use it during macro expansion.
(cl--function-convert-cache): New var.
(cl--function-convert): New function, extracted from
cl-macroexpand-all.
(cl-lexical-let): Use it.
* emacs-lisp/cl.el (cl-macroexpand, cl-macro-environment)
(cl-macroexpand-all, cl-not-hash-table, cl-builtin-gethash)
(cl-builtin-remhash, cl-builtin-clrhash, cl-builtin-maphash)
(cl-map-keymap, cl-copy-tree, cl-gethash, cl-puthash, cl-remhash)
(cl-clrhash, cl-maphash, cl-make-hash-table, cl-hash-table-p)
(cl-hash-table-count): Add old compatibility aliases.
2012-06-07 19:48:22 +00:00
|
|
|
((vectorp state) (copy-tree state t))
|
2012-12-06 21:29:29 +00:00
|
|
|
((integerp state) (vector 'cl--random-state-tag -1 30 state))
|
2012-11-03 18:36:09 +00:00
|
|
|
(t (cl-make-random-state (cl--random-time)))))
|
1993-07-30 20:15:09 +00:00
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
2012-06-04 01:05:17 +00:00
|
|
|
(defun cl-random-state-p (object)
|
1993-07-30 20:15:09 +00:00
|
|
|
"Return t if OBJECT is a random-state object."
|
|
|
|
(and (vectorp object) (= (length object) 4)
|
2012-12-06 21:29:29 +00:00
|
|
|
(eq (aref object 0) 'cl--random-state-tag)))
|
1993-07-30 20:15:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
;; Implementation limits.
|
|
|
|
|
Use lexical-binding for all of CL, and clean up its namespace.
* lisp/emacs-lisp/cl-lib.el: Use lexical-binding.
(cl-map-extents, cl-maclisp-member): Remove.
(cl--set-elt, cl--set-nthcdr, cl--set-buffer-substring)
(cl--set-substring, cl--block-wrapper, cl--block-throw)
(cl--compiling-file, cl--mapcar-many, cl--do-subst): Use "cl--" prefix.
* lisp/emacs-lisp/cl-extra.el: Use lexical-binding.
(cl--mapcar-many, cl--map-keymap-recursively, cl--map-intervals)
(cl--map-overlays, cl--set-frame-visible-p, cl--progv-save)
(cl--progv-before, cl--progv-after, cl--finite-do, cl--set-getf)
(cl--do-remf, cl--do-prettyprint): Use "cl--" prefix.
* lisp/emacs-lisp/cl-seq.el: Use lexical-binding.
(cl--parsing-keywords, cl--check-key, cl--check-test-nokey)
(cl--check-test, cl--check-match): Use "cl--" prefix and backquotes.
(cl--alist, cl--sublis-rec, cl--nsublis-rec, cl--tree-equal-rec):
* lisp/emacs-lisp/cl-macs.el (cl--lambda-list-keywords): Use "cl--" prefix.
* lisp/edmacro.el (edmacro-mismatch): Simplify to remove dependence on
CL's internals.
2012-06-11 15:52:50 +00:00
|
|
|
(defun cl--finite-do (func a b)
|
|
|
|
(condition-case _
|
1993-07-30 20:15:09 +00:00
|
|
|
(let ((res (funcall func a b))) ; check for IEEE infinity
|
|
|
|
(and (numberp res) (/= res (/ res 2)) res))
|
|
|
|
(arith-error nil)))
|
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
1993-07-30 20:15:09 +00:00
|
|
|
(defun cl-float-limits ()
|
2011-10-27 07:21:00 +00:00
|
|
|
"Initialize the Common Lisp floating-point parameters.
|
2012-06-04 01:05:17 +00:00
|
|
|
This sets the values of: `cl-most-positive-float', `cl-most-negative-float',
|
|
|
|
`cl-least-positive-float', `cl-least-negative-float', `cl-float-epsilon',
|
|
|
|
`cl-float-negative-epsilon', `cl-least-positive-normalized-float', and
|
|
|
|
`cl-least-negative-normalized-float'."
|
|
|
|
(or cl-most-positive-float (not (numberp '2e1))
|
1993-07-30 20:15:09 +00:00
|
|
|
(let ((x '2e0) y z)
|
|
|
|
;; Find maximum exponent (first two loops are optimizations)
|
Use lexical-binding for all of CL, and clean up its namespace.
* lisp/emacs-lisp/cl-lib.el: Use lexical-binding.
(cl-map-extents, cl-maclisp-member): Remove.
(cl--set-elt, cl--set-nthcdr, cl--set-buffer-substring)
(cl--set-substring, cl--block-wrapper, cl--block-throw)
(cl--compiling-file, cl--mapcar-many, cl--do-subst): Use "cl--" prefix.
* lisp/emacs-lisp/cl-extra.el: Use lexical-binding.
(cl--mapcar-many, cl--map-keymap-recursively, cl--map-intervals)
(cl--map-overlays, cl--set-frame-visible-p, cl--progv-save)
(cl--progv-before, cl--progv-after, cl--finite-do, cl--set-getf)
(cl--do-remf, cl--do-prettyprint): Use "cl--" prefix.
* lisp/emacs-lisp/cl-seq.el: Use lexical-binding.
(cl--parsing-keywords, cl--check-key, cl--check-test-nokey)
(cl--check-test, cl--check-match): Use "cl--" prefix and backquotes.
(cl--alist, cl--sublis-rec, cl--nsublis-rec, cl--tree-equal-rec):
* lisp/emacs-lisp/cl-macs.el (cl--lambda-list-keywords): Use "cl--" prefix.
* lisp/edmacro.el (edmacro-mismatch): Simplify to remove dependence on
CL's internals.
2012-06-11 15:52:50 +00:00
|
|
|
(while (cl--finite-do '* x x) (setq x (* x x)))
|
|
|
|
(while (cl--finite-do '* x (/ x 2)) (setq x (* x (/ x 2))))
|
|
|
|
(while (cl--finite-do '+ x x) (setq x (+ x x)))
|
1993-07-30 20:15:09 +00:00
|
|
|
(setq z x y (/ x 2))
|
2012-06-04 01:05:17 +00:00
|
|
|
;; Now cl-fill in 1's in the mantissa.
|
Use lexical-binding for all of CL, and clean up its namespace.
* lisp/emacs-lisp/cl-lib.el: Use lexical-binding.
(cl-map-extents, cl-maclisp-member): Remove.
(cl--set-elt, cl--set-nthcdr, cl--set-buffer-substring)
(cl--set-substring, cl--block-wrapper, cl--block-throw)
(cl--compiling-file, cl--mapcar-many, cl--do-subst): Use "cl--" prefix.
* lisp/emacs-lisp/cl-extra.el: Use lexical-binding.
(cl--mapcar-many, cl--map-keymap-recursively, cl--map-intervals)
(cl--map-overlays, cl--set-frame-visible-p, cl--progv-save)
(cl--progv-before, cl--progv-after, cl--finite-do, cl--set-getf)
(cl--do-remf, cl--do-prettyprint): Use "cl--" prefix.
* lisp/emacs-lisp/cl-seq.el: Use lexical-binding.
(cl--parsing-keywords, cl--check-key, cl--check-test-nokey)
(cl--check-test, cl--check-match): Use "cl--" prefix and backquotes.
(cl--alist, cl--sublis-rec, cl--nsublis-rec, cl--tree-equal-rec):
* lisp/emacs-lisp/cl-macs.el (cl--lambda-list-keywords): Use "cl--" prefix.
* lisp/edmacro.el (edmacro-mismatch): Simplify to remove dependence on
CL's internals.
2012-06-11 15:52:50 +00:00
|
|
|
(while (and (cl--finite-do '+ x y) (/= (+ x y) x))
|
1993-07-30 20:15:09 +00:00
|
|
|
(setq x (+ x y) y (/ y 2)))
|
2012-06-04 01:05:17 +00:00
|
|
|
(setq cl-most-positive-float x
|
|
|
|
cl-most-negative-float (- x))
|
1993-07-30 20:15:09 +00:00
|
|
|
;; Divide down until mantissa starts rounding.
|
|
|
|
(setq x (/ x z) y (/ 16 z) x (* x y))
|
Use lexical-binding for all of CL, and clean up its namespace.
* lisp/emacs-lisp/cl-lib.el: Use lexical-binding.
(cl-map-extents, cl-maclisp-member): Remove.
(cl--set-elt, cl--set-nthcdr, cl--set-buffer-substring)
(cl--set-substring, cl--block-wrapper, cl--block-throw)
(cl--compiling-file, cl--mapcar-many, cl--do-subst): Use "cl--" prefix.
* lisp/emacs-lisp/cl-extra.el: Use lexical-binding.
(cl--mapcar-many, cl--map-keymap-recursively, cl--map-intervals)
(cl--map-overlays, cl--set-frame-visible-p, cl--progv-save)
(cl--progv-before, cl--progv-after, cl--finite-do, cl--set-getf)
(cl--do-remf, cl--do-prettyprint): Use "cl--" prefix.
* lisp/emacs-lisp/cl-seq.el: Use lexical-binding.
(cl--parsing-keywords, cl--check-key, cl--check-test-nokey)
(cl--check-test, cl--check-match): Use "cl--" prefix and backquotes.
(cl--alist, cl--sublis-rec, cl--nsublis-rec, cl--tree-equal-rec):
* lisp/emacs-lisp/cl-macs.el (cl--lambda-list-keywords): Use "cl--" prefix.
* lisp/edmacro.el (edmacro-mismatch): Simplify to remove dependence on
CL's internals.
2012-06-11 15:52:50 +00:00
|
|
|
(while (condition-case _ (and (= x (* (/ x 2) 2)) (> (/ y 2) 0))
|
1993-07-30 20:15:09 +00:00
|
|
|
(arith-error nil))
|
|
|
|
(setq x (/ x 2) y (/ y 2)))
|
2012-06-04 01:05:17 +00:00
|
|
|
(setq cl-least-positive-normalized-float y
|
|
|
|
cl-least-negative-normalized-float (- y))
|
1993-07-30 20:15:09 +00:00
|
|
|
;; Divide down until value underflows to zero.
|
|
|
|
(setq x (/ 1 z) y x)
|
Use lexical-binding for all of CL, and clean up its namespace.
* lisp/emacs-lisp/cl-lib.el: Use lexical-binding.
(cl-map-extents, cl-maclisp-member): Remove.
(cl--set-elt, cl--set-nthcdr, cl--set-buffer-substring)
(cl--set-substring, cl--block-wrapper, cl--block-throw)
(cl--compiling-file, cl--mapcar-many, cl--do-subst): Use "cl--" prefix.
* lisp/emacs-lisp/cl-extra.el: Use lexical-binding.
(cl--mapcar-many, cl--map-keymap-recursively, cl--map-intervals)
(cl--map-overlays, cl--set-frame-visible-p, cl--progv-save)
(cl--progv-before, cl--progv-after, cl--finite-do, cl--set-getf)
(cl--do-remf, cl--do-prettyprint): Use "cl--" prefix.
* lisp/emacs-lisp/cl-seq.el: Use lexical-binding.
(cl--parsing-keywords, cl--check-key, cl--check-test-nokey)
(cl--check-test, cl--check-match): Use "cl--" prefix and backquotes.
(cl--alist, cl--sublis-rec, cl--nsublis-rec, cl--tree-equal-rec):
* lisp/emacs-lisp/cl-macs.el (cl--lambda-list-keywords): Use "cl--" prefix.
* lisp/edmacro.el (edmacro-mismatch): Simplify to remove dependence on
CL's internals.
2012-06-11 15:52:50 +00:00
|
|
|
(while (condition-case _ (> (/ x 2) 0) (arith-error nil))
|
1993-07-30 20:15:09 +00:00
|
|
|
(setq x (/ x 2)))
|
2012-06-04 01:05:17 +00:00
|
|
|
(setq cl-least-positive-float x
|
|
|
|
cl-least-negative-float (- x))
|
1993-07-30 20:15:09 +00:00
|
|
|
(setq x '1e0)
|
|
|
|
(while (/= (+ '1e0 x) '1e0) (setq x (/ x 2)))
|
2012-06-04 01:05:17 +00:00
|
|
|
(setq cl-float-epsilon (* x 2))
|
1993-07-30 20:15:09 +00:00
|
|
|
(setq x '1e0)
|
|
|
|
(while (/= (- '1e0 x) '1e0) (setq x (/ x 2)))
|
2012-06-04 01:05:17 +00:00
|
|
|
(setq cl-float-negative-epsilon (* x 2))))
|
1993-07-30 20:15:09 +00:00
|
|
|
nil)
|
|
|
|
|
|
|
|
|
|
|
|
;;; Sequence functions.
|
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
2012-06-04 01:05:17 +00:00
|
|
|
(defun cl-subseq (seq start &optional end)
|
1993-07-30 20:15:09 +00:00
|
|
|
"Return the subsequence of SEQ from START to END.
|
|
|
|
If END is omitted, it defaults to the length of the sequence.
|
|
|
|
If START or END is negative, it counts from the end."
|
Further GV/CL cleanups.
* lisp/emacs-lisp/gv.el (gv-get): Autoload functions to find their
gv-expander.
(gv--defun-declaration): New function.
(defun-declarations-alist): Use it.
(gv-define-modify-macro, gv-pushnew!, gv-inc!, gv-dec!): Remove.
(gv-place): Autoload.
* lisp/emacs-lisp/cl.el (cl--dotimes, cl--dolist): Remember subr.el's
original definition of dotimes and dolist.
* lisp/emacs-lisp/cl-macs.el (cl-expr-access-order): Remove unused.
(cl-dolist, cl-dotimes): Use `dolist' and `dotimes'.
* lisp/emacs-lisp/cl-lib.el: Move gv handlers from cl-macs to here.
(cl-fifth, cl-sixth, cl-seventh, cl-eighth)
(cl-ninth, cl-tenth): Move gv handler to the function's definition.
* lisp/emacs-lisp/cl-extra.el (cl-subseq, cl-get, cl-getf): Move gv handler
to the function's definition.
* lisp/Makefile.in (COMPILE_FIRST): Re-order to speed it up by about 50%.
* lisp/window.el:
* lisp/files.el:
* lisp/faces.el:
* lisp/env.el: Don't use CL.
2012-06-22 21:24:54 +00:00
|
|
|
(declare (gv-setter
|
|
|
|
(lambda (new)
|
|
|
|
`(progn (cl-replace ,seq ,new :start1 ,start :end1 ,end)
|
|
|
|
,new))))
|
1993-07-30 20:15:09 +00:00
|
|
|
(if (stringp seq) (substring seq start end)
|
|
|
|
(let (len)
|
|
|
|
(and end (< end 0) (setq end (+ end (setq len (length seq)))))
|
|
|
|
(if (< start 0) (setq start (+ start (or len (setq len (length seq))))))
|
|
|
|
(cond ((listp seq)
|
|
|
|
(if (> start 0) (setq seq (nthcdr start seq)))
|
|
|
|
(if end
|
|
|
|
(let ((res nil))
|
|
|
|
(while (>= (setq end (1- end)) start)
|
2002-09-27 22:32:48 +00:00
|
|
|
(push (pop seq) res))
|
1993-07-30 20:15:09 +00:00
|
|
|
(nreverse res))
|
|
|
|
(copy-sequence seq)))
|
|
|
|
(t
|
|
|
|
(or end (setq end (or len (length seq))))
|
|
|
|
(let ((res (make-vector (max (- end start) 0) nil))
|
|
|
|
(i 0))
|
|
|
|
(while (< start end)
|
|
|
|
(aset res i (aref seq start))
|
|
|
|
(setq i (1+ i) start (1+ start)))
|
|
|
|
res))))))
|
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
2012-06-04 01:05:17 +00:00
|
|
|
(defun cl-concatenate (type &rest seqs)
|
(coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
notevery, signum, isqrt, concatenate, list-length, get*, getf, cl-remprop):
Improve argument/docstring consistency.
2005-05-22 17:48:02 +00:00
|
|
|
"Concatenate, into a sequence of type TYPE, the argument SEQUENCEs.
|
|
|
|
\n(fn TYPE SEQUENCE...)"
|
1993-07-30 20:15:09 +00:00
|
|
|
(cond ((eq type 'vector) (apply 'vconcat seqs))
|
|
|
|
((eq type 'string) (apply 'concat seqs))
|
|
|
|
((eq type 'list) (apply 'append (append seqs '(nil))))
|
|
|
|
(t (error "Not a sequence type name: %s" type))))
|
|
|
|
|
|
|
|
|
|
|
|
;;; List functions.
|
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
2012-06-04 01:05:17 +00:00
|
|
|
(defun cl-revappend (x y)
|
1993-07-30 20:15:09 +00:00
|
|
|
"Equivalent to (append (reverse X) Y)."
|
|
|
|
(nconc (reverse x) y))
|
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
2012-06-04 01:05:17 +00:00
|
|
|
(defun cl-nreconc (x y)
|
1993-07-30 20:15:09 +00:00
|
|
|
"Equivalent to (nconc (nreverse X) Y)."
|
|
|
|
(nconc (nreverse x) y))
|
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
2012-06-04 01:05:17 +00:00
|
|
|
(defun cl-list-length (x)
|
(coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
notevery, signum, isqrt, concatenate, list-length, get*, getf, cl-remprop):
Improve argument/docstring consistency.
2005-05-22 17:48:02 +00:00
|
|
|
"Return the length of list X. Return nil if list is circular."
|
1993-07-30 20:15:09 +00:00
|
|
|
(let ((n 0) (fast x) (slow x))
|
|
|
|
(while (and (cdr fast) (not (and (eq fast slow) (> n 0))))
|
|
|
|
(setq n (+ n 2) fast (cdr (cdr fast)) slow (cdr slow)))
|
|
|
|
(if fast (if (cdr fast) nil (1+ n)) n)))
|
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
2012-06-04 01:05:17 +00:00
|
|
|
(defun cl-tailp (sublist list)
|
1993-07-30 20:15:09 +00:00
|
|
|
"Return true if SUBLIST is a tail of LIST."
|
|
|
|
(while (and (consp list) (not (eq sublist list)))
|
|
|
|
(setq list (cdr list)))
|
|
|
|
(if (numberp sublist) (equal sublist list) (eq sublist list)))
|
|
|
|
|
|
|
|
;;; Property lists.
|
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
2012-06-09 02:26:47 +00:00
|
|
|
(defun cl-get (sym tag &optional def)
|
(coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
notevery, signum, isqrt, concatenate, list-length, get*, getf, cl-remprop):
Improve argument/docstring consistency.
2005-05-22 17:48:02 +00:00
|
|
|
"Return the value of SYMBOL's PROPNAME property, or DEFAULT if none.
|
|
|
|
\n(fn SYMBOL PROPNAME &optional DEFAULT)"
|
Further GV/CL cleanups.
* lisp/emacs-lisp/gv.el (gv-get): Autoload functions to find their
gv-expander.
(gv--defun-declaration): New function.
(defun-declarations-alist): Use it.
(gv-define-modify-macro, gv-pushnew!, gv-inc!, gv-dec!): Remove.
(gv-place): Autoload.
* lisp/emacs-lisp/cl.el (cl--dotimes, cl--dolist): Remember subr.el's
original definition of dotimes and dolist.
* lisp/emacs-lisp/cl-macs.el (cl-expr-access-order): Remove unused.
(cl-dolist, cl-dotimes): Use `dolist' and `dotimes'.
* lisp/emacs-lisp/cl-lib.el: Move gv handlers from cl-macs to here.
(cl-fifth, cl-sixth, cl-seventh, cl-eighth)
(cl-ninth, cl-tenth): Move gv handler to the function's definition.
* lisp/emacs-lisp/cl-extra.el (cl-subseq, cl-get, cl-getf): Move gv handler
to the function's definition.
* lisp/Makefile.in (COMPILE_FIRST): Re-order to speed it up by about 50%.
* lisp/window.el:
* lisp/files.el:
* lisp/faces.el:
* lisp/env.el: Don't use CL.
2012-06-22 21:24:54 +00:00
|
|
|
(declare (compiler-macro cl--compiler-macro-get)
|
|
|
|
(gv-setter (lambda (store) `(put ,sym ,tag ,store))))
|
1993-07-30 20:15:09 +00:00
|
|
|
(or (get sym tag)
|
|
|
|
(and def
|
Provide generalized variables in core Elisp.
* lisp/emacs-lisp/gv.el: New file.
* lisp/subr.el (push, pop): Extend to generalized variables.
* lisp/loadup.el (macroexp): Unload if preloaded and uncompiled.
* lisp/emacs-lisp/cl-lib.el (cl-pop, cl-push, cl--set-nthcdr): Remove.
* lisp/emacs-lisp/cl-macs.el: Require gv. Use gv-define-setter,
gv-define-simple-setter, and gv-define-expander.
Remove setf-methods defined in gv. Rename cl-setf -> setf.
(cl-setf, cl-do-pop, cl-get-setf-method): Remove.
(cl-letf, cl-letf*, cl-define-modify-macro, cl-defsetf)
(cl-define-setf-expander, cl-struct-setf-expander): Move to cl.el.
(cl-remf, cl-shiftf, cl-rotatef, cl-callf, cl-callf2): Rewrite with
gv-letplace.
(cl-defstruct): Don't define setf-method any more.
* lisp/emacs-lisp/cl.el (flet): Don't autoload.
(cl--letf, letf, cl--letf*, letf*, cl--gv-adapt)
(define-setf-expander, defsetf, define-modify-macro)
(cl-struct-setf-expander): Move from cl-lib.el.
* lisp/emacs-lisp/syntax.el:
* lisp/emacs-lisp/ewoc.el:
* lisp/emacs-lisp/smie.el:
* lisp/emacs-lisp/cconv.el:
* lisp/emacs-lisp/timer.el: Rename cl-setf -> setf, cl-push -> push.
(timer--time): Use gv-define-simple-setter.
* lisp/emacs-lisp/macroexp.el (macroexp-let2): Rename from macroexp-let²
to avoid coding-system problems in subr.el. Adjust all users.
(macroexp--maxsize, macroexp-small-p): New functions.
* lisp/emacs-lisp/bytecomp.el (byte-compile-file): Don't use cl-letf.
* lisp/scroll-bar.el (scroll-bar-mode):
* lisp/simple.el (auto-fill-mode, overwrite-mode, binary-overwrite-mode)
(normal-erase-is-backspace-mode): Don't use the `eq' place.
* lisp/winner.el (winner-configuration, winner-make-point-alist)
(winner-set-conf, winner-get-point, winner-set): Don't abuse letf.
* lisp/files.el (locate-file-completion-table): Avoid list*.
Fixes: debbugs:11657
2012-06-22 13:42:38 +00:00
|
|
|
;; Make sure `def' is really absent as opposed to set to nil.
|
1993-07-30 20:15:09 +00:00
|
|
|
(let ((plist (symbol-plist sym)))
|
|
|
|
(while (and plist (not (eq (car plist) tag)))
|
|
|
|
(setq plist (cdr (cdr plist))))
|
|
|
|
(if plist (car (cdr plist)) def)))))
|
2012-06-09 02:26:47 +00:00
|
|
|
(autoload 'cl--compiler-macro-get "cl-macs")
|
1993-07-30 20:15:09 +00:00
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
2012-06-04 01:05:17 +00:00
|
|
|
(defun cl-getf (plist tag &optional def)
|
1993-07-30 20:15:09 +00:00
|
|
|
"Search PROPLIST for property PROPNAME; return its value or DEFAULT.
|
(coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
notevery, signum, isqrt, concatenate, list-length, get*, getf, cl-remprop):
Improve argument/docstring consistency.
2005-05-22 17:48:02 +00:00
|
|
|
PROPLIST is a list of the sort returned by `symbol-plist'.
|
|
|
|
\n(fn PROPLIST PROPNAME &optional DEFAULT)"
|
Further GV/CL cleanups.
* lisp/emacs-lisp/gv.el (gv-get): Autoload functions to find their
gv-expander.
(gv--defun-declaration): New function.
(defun-declarations-alist): Use it.
(gv-define-modify-macro, gv-pushnew!, gv-inc!, gv-dec!): Remove.
(gv-place): Autoload.
* lisp/emacs-lisp/cl.el (cl--dotimes, cl--dolist): Remember subr.el's
original definition of dotimes and dolist.
* lisp/emacs-lisp/cl-macs.el (cl-expr-access-order): Remove unused.
(cl-dolist, cl-dotimes): Use `dolist' and `dotimes'.
* lisp/emacs-lisp/cl-lib.el: Move gv handlers from cl-macs to here.
(cl-fifth, cl-sixth, cl-seventh, cl-eighth)
(cl-ninth, cl-tenth): Move gv handler to the function's definition.
* lisp/emacs-lisp/cl-extra.el (cl-subseq, cl-get, cl-getf): Move gv handler
to the function's definition.
* lisp/Makefile.in (COMPILE_FIRST): Re-order to speed it up by about 50%.
* lisp/window.el:
* lisp/files.el:
* lisp/faces.el:
* lisp/env.el: Don't use CL.
2012-06-22 21:24:54 +00:00
|
|
|
(declare (gv-expander
|
|
|
|
(lambda (do)
|
|
|
|
(gv-letplace (getter setter) plist
|
|
|
|
(macroexp-let2 nil k tag
|
|
|
|
(macroexp-let2 nil d def
|
|
|
|
(funcall do `(cl-getf ,getter ,k ,d)
|
|
|
|
(lambda (v)
|
2013-05-15 02:00:07 +00:00
|
|
|
(macroexp-let2 nil val v
|
|
|
|
`(progn
|
|
|
|
,(funcall setter
|
|
|
|
`(cl--set-getf ,getter ,k ,val))
|
|
|
|
,val))))))))))
|
1993-07-30 20:15:09 +00:00
|
|
|
(setplist '--cl-getf-symbol-- plist)
|
|
|
|
(or (get '--cl-getf-symbol-- tag)
|
2012-06-04 01:05:17 +00:00
|
|
|
;; Originally we called cl-get here,
|
|
|
|
;; but that fails, because cl-get has a compiler macro
|
1999-06-12 03:36:46 +00:00
|
|
|
;; definition that uses getf!
|
|
|
|
(when def
|
Provide generalized variables in core Elisp.
* lisp/emacs-lisp/gv.el: New file.
* lisp/subr.el (push, pop): Extend to generalized variables.
* lisp/loadup.el (macroexp): Unload if preloaded and uncompiled.
* lisp/emacs-lisp/cl-lib.el (cl-pop, cl-push, cl--set-nthcdr): Remove.
* lisp/emacs-lisp/cl-macs.el: Require gv. Use gv-define-setter,
gv-define-simple-setter, and gv-define-expander.
Remove setf-methods defined in gv. Rename cl-setf -> setf.
(cl-setf, cl-do-pop, cl-get-setf-method): Remove.
(cl-letf, cl-letf*, cl-define-modify-macro, cl-defsetf)
(cl-define-setf-expander, cl-struct-setf-expander): Move to cl.el.
(cl-remf, cl-shiftf, cl-rotatef, cl-callf, cl-callf2): Rewrite with
gv-letplace.
(cl-defstruct): Don't define setf-method any more.
* lisp/emacs-lisp/cl.el (flet): Don't autoload.
(cl--letf, letf, cl--letf*, letf*, cl--gv-adapt)
(define-setf-expander, defsetf, define-modify-macro)
(cl-struct-setf-expander): Move from cl-lib.el.
* lisp/emacs-lisp/syntax.el:
* lisp/emacs-lisp/ewoc.el:
* lisp/emacs-lisp/smie.el:
* lisp/emacs-lisp/cconv.el:
* lisp/emacs-lisp/timer.el: Rename cl-setf -> setf, cl-push -> push.
(timer--time): Use gv-define-simple-setter.
* lisp/emacs-lisp/macroexp.el (macroexp-let2): Rename from macroexp-let²
to avoid coding-system problems in subr.el. Adjust all users.
(macroexp--maxsize, macroexp-small-p): New functions.
* lisp/emacs-lisp/bytecomp.el (byte-compile-file): Don't use cl-letf.
* lisp/scroll-bar.el (scroll-bar-mode):
* lisp/simple.el (auto-fill-mode, overwrite-mode, binary-overwrite-mode)
(normal-erase-is-backspace-mode): Don't use the `eq' place.
* lisp/winner.el (winner-configuration, winner-make-point-alist)
(winner-set-conf, winner-get-point, winner-set): Don't abuse letf.
* lisp/files.el (locate-file-completion-table): Avoid list*.
Fixes: debbugs:11657
2012-06-22 13:42:38 +00:00
|
|
|
;; Make sure `def' is really absent as opposed to set to nil.
|
1999-06-12 03:36:46 +00:00
|
|
|
(while (and plist (not (eq (car plist) tag)))
|
|
|
|
(setq plist (cdr (cdr plist))))
|
|
|
|
(if plist (car (cdr plist)) def))))
|
1993-07-30 20:15:09 +00:00
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
Use lexical-binding for all of CL, and clean up its namespace.
* lisp/emacs-lisp/cl-lib.el: Use lexical-binding.
(cl-map-extents, cl-maclisp-member): Remove.
(cl--set-elt, cl--set-nthcdr, cl--set-buffer-substring)
(cl--set-substring, cl--block-wrapper, cl--block-throw)
(cl--compiling-file, cl--mapcar-many, cl--do-subst): Use "cl--" prefix.
* lisp/emacs-lisp/cl-extra.el: Use lexical-binding.
(cl--mapcar-many, cl--map-keymap-recursively, cl--map-intervals)
(cl--map-overlays, cl--set-frame-visible-p, cl--progv-save)
(cl--progv-before, cl--progv-after, cl--finite-do, cl--set-getf)
(cl--do-remf, cl--do-prettyprint): Use "cl--" prefix.
* lisp/emacs-lisp/cl-seq.el: Use lexical-binding.
(cl--parsing-keywords, cl--check-key, cl--check-test-nokey)
(cl--check-test, cl--check-match): Use "cl--" prefix and backquotes.
(cl--alist, cl--sublis-rec, cl--nsublis-rec, cl--tree-equal-rec):
* lisp/emacs-lisp/cl-macs.el (cl--lambda-list-keywords): Use "cl--" prefix.
* lisp/edmacro.el (edmacro-mismatch): Simplify to remove dependence on
CL's internals.
2012-06-11 15:52:50 +00:00
|
|
|
(defun cl--set-getf (plist tag val)
|
1993-07-30 20:15:09 +00:00
|
|
|
(let ((p plist))
|
|
|
|
(while (and p (not (eq (car p) tag))) (setq p (cdr (cdr p))))
|
2012-06-04 01:05:17 +00:00
|
|
|
(if p (progn (setcar (cdr p) val) plist) (cl-list* tag val plist))))
|
1993-07-30 20:15:09 +00:00
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
Use lexical-binding for all of CL, and clean up its namespace.
* lisp/emacs-lisp/cl-lib.el: Use lexical-binding.
(cl-map-extents, cl-maclisp-member): Remove.
(cl--set-elt, cl--set-nthcdr, cl--set-buffer-substring)
(cl--set-substring, cl--block-wrapper, cl--block-throw)
(cl--compiling-file, cl--mapcar-many, cl--do-subst): Use "cl--" prefix.
* lisp/emacs-lisp/cl-extra.el: Use lexical-binding.
(cl--mapcar-many, cl--map-keymap-recursively, cl--map-intervals)
(cl--map-overlays, cl--set-frame-visible-p, cl--progv-save)
(cl--progv-before, cl--progv-after, cl--finite-do, cl--set-getf)
(cl--do-remf, cl--do-prettyprint): Use "cl--" prefix.
* lisp/emacs-lisp/cl-seq.el: Use lexical-binding.
(cl--parsing-keywords, cl--check-key, cl--check-test-nokey)
(cl--check-test, cl--check-match): Use "cl--" prefix and backquotes.
(cl--alist, cl--sublis-rec, cl--nsublis-rec, cl--tree-equal-rec):
* lisp/emacs-lisp/cl-macs.el (cl--lambda-list-keywords): Use "cl--" prefix.
* lisp/edmacro.el (edmacro-mismatch): Simplify to remove dependence on
CL's internals.
2012-06-11 15:52:50 +00:00
|
|
|
(defun cl--do-remf (plist tag)
|
1993-07-30 20:15:09 +00:00
|
|
|
(let ((p (cdr plist)))
|
|
|
|
(while (and (cdr p) (not (eq (car (cdr p)) tag))) (setq p (cdr (cdr p))))
|
|
|
|
(and (cdr p) (progn (setcdr p (cdr (cdr (cdr p)))) t))))
|
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
1993-07-30 20:15:09 +00:00
|
|
|
(defun cl-remprop (sym tag)
|
(coerce, map, maplist, cl-mapc, mapl, mapcan, mapcon, some, every, notany,
notevery, signum, isqrt, concatenate, list-length, get*, getf, cl-remprop):
Improve argument/docstring consistency.
2005-05-22 17:48:02 +00:00
|
|
|
"Remove from SYMBOL's plist the property PROPNAME and its value.
|
|
|
|
\n(fn SYMBOL PROPNAME)"
|
1993-07-30 20:15:09 +00:00
|
|
|
(let ((plist (symbol-plist sym)))
|
|
|
|
(if (and plist (eq tag (car plist)))
|
|
|
|
(progn (setplist sym (cdr (cdr plist))) t)
|
Use lexical-binding for all of CL, and clean up its namespace.
* lisp/emacs-lisp/cl-lib.el: Use lexical-binding.
(cl-map-extents, cl-maclisp-member): Remove.
(cl--set-elt, cl--set-nthcdr, cl--set-buffer-substring)
(cl--set-substring, cl--block-wrapper, cl--block-throw)
(cl--compiling-file, cl--mapcar-many, cl--do-subst): Use "cl--" prefix.
* lisp/emacs-lisp/cl-extra.el: Use lexical-binding.
(cl--mapcar-many, cl--map-keymap-recursively, cl--map-intervals)
(cl--map-overlays, cl--set-frame-visible-p, cl--progv-save)
(cl--progv-before, cl--progv-after, cl--finite-do, cl--set-getf)
(cl--do-remf, cl--do-prettyprint): Use "cl--" prefix.
* lisp/emacs-lisp/cl-seq.el: Use lexical-binding.
(cl--parsing-keywords, cl--check-key, cl--check-test-nokey)
(cl--check-test, cl--check-match): Use "cl--" prefix and backquotes.
(cl--alist, cl--sublis-rec, cl--nsublis-rec, cl--tree-equal-rec):
* lisp/emacs-lisp/cl-macs.el (cl--lambda-list-keywords): Use "cl--" prefix.
* lisp/edmacro.el (edmacro-mismatch): Simplify to remove dependence on
CL's internals.
2012-06-11 15:52:50 +00:00
|
|
|
(cl--do-remf plist tag))))
|
1993-07-30 20:15:09 +00:00
|
|
|
|
|
|
|
;;; Some debugging aids.
|
|
|
|
|
|
|
|
(defun cl-prettyprint (form)
|
|
|
|
"Insert a pretty-printed rendition of a Lisp FORM in current buffer."
|
|
|
|
(let ((pt (point)) last)
|
|
|
|
(insert "\n" (prin1-to-string form) "\n")
|
|
|
|
(setq last (point))
|
|
|
|
(goto-char (1+ pt))
|
|
|
|
(while (search-forward "(quote " last t)
|
Replace Lisp calls to delete-backward-char by delete-char.
* bs.el, expand.el, ido.el, image-dired.el, lpr.el, pcomplete.el,
skeleton.el, term.el, time.el, wid-edit.el, woman.el,
calc/calc-graph.el, calc/calc-help.el, calc/calc-incom.el,
calc/calc.el, emacs-cl-extra.el, emacs-cl-loaddefs.el,
emulation/cua-rect.el, emulation/viper-ex.el, eshell/esh-test.el,
eshell/eshell.el, gnus/gnus-uu.el, gnus/nndoc.el, gnus/nnrss.el,
gnus/rfc2047.el, gnus/utf7.el, international/utf-7.el,
language/ethio-util.el, mh-e/mh-alias.el, mh-e/mh-search.el,
net/imap.el, net/rcirc.el, obsolete/complete.el, play/decipher.el,
progmodes/ada-mode.el, progmodes/cc-awk.el, progmodes/dcl-mode.el,
progmodes/ps-mode.el, progmodes/verilog-mode.el,
progmodes/vhdl-mode.el, textmodes/bibtex.el, textmodes/fill.el,
textmodes/reftex-auc.el, textmodes/rst.el, textmodes/sgml-mode.el,
textmodes/table.el, textmodes/texinfmt.el: Replace Lisp calls to
delete-backward-char by calls to delete-char.
2010-05-25 02:11:08 +00:00
|
|
|
(delete-char -7)
|
1993-07-30 20:15:09 +00:00
|
|
|
(insert "'")
|
|
|
|
(forward-sexp)
|
|
|
|
(delete-char 1))
|
|
|
|
(goto-char (1+ pt))
|
Use lexical-binding for all of CL, and clean up its namespace.
* lisp/emacs-lisp/cl-lib.el: Use lexical-binding.
(cl-map-extents, cl-maclisp-member): Remove.
(cl--set-elt, cl--set-nthcdr, cl--set-buffer-substring)
(cl--set-substring, cl--block-wrapper, cl--block-throw)
(cl--compiling-file, cl--mapcar-many, cl--do-subst): Use "cl--" prefix.
* lisp/emacs-lisp/cl-extra.el: Use lexical-binding.
(cl--mapcar-many, cl--map-keymap-recursively, cl--map-intervals)
(cl--map-overlays, cl--set-frame-visible-p, cl--progv-save)
(cl--progv-before, cl--progv-after, cl--finite-do, cl--set-getf)
(cl--do-remf, cl--do-prettyprint): Use "cl--" prefix.
* lisp/emacs-lisp/cl-seq.el: Use lexical-binding.
(cl--parsing-keywords, cl--check-key, cl--check-test-nokey)
(cl--check-test, cl--check-match): Use "cl--" prefix and backquotes.
(cl--alist, cl--sublis-rec, cl--nsublis-rec, cl--tree-equal-rec):
* lisp/emacs-lisp/cl-macs.el (cl--lambda-list-keywords): Use "cl--" prefix.
* lisp/edmacro.el (edmacro-mismatch): Simplify to remove dependence on
CL's internals.
2012-06-11 15:52:50 +00:00
|
|
|
(cl--do-prettyprint)))
|
1993-07-30 20:15:09 +00:00
|
|
|
|
Use lexical-binding for all of CL, and clean up its namespace.
* lisp/emacs-lisp/cl-lib.el: Use lexical-binding.
(cl-map-extents, cl-maclisp-member): Remove.
(cl--set-elt, cl--set-nthcdr, cl--set-buffer-substring)
(cl--set-substring, cl--block-wrapper, cl--block-throw)
(cl--compiling-file, cl--mapcar-many, cl--do-subst): Use "cl--" prefix.
* lisp/emacs-lisp/cl-extra.el: Use lexical-binding.
(cl--mapcar-many, cl--map-keymap-recursively, cl--map-intervals)
(cl--map-overlays, cl--set-frame-visible-p, cl--progv-save)
(cl--progv-before, cl--progv-after, cl--finite-do, cl--set-getf)
(cl--do-remf, cl--do-prettyprint): Use "cl--" prefix.
* lisp/emacs-lisp/cl-seq.el: Use lexical-binding.
(cl--parsing-keywords, cl--check-key, cl--check-test-nokey)
(cl--check-test, cl--check-match): Use "cl--" prefix and backquotes.
(cl--alist, cl--sublis-rec, cl--nsublis-rec, cl--tree-equal-rec):
* lisp/emacs-lisp/cl-macs.el (cl--lambda-list-keywords): Use "cl--" prefix.
* lisp/edmacro.el (edmacro-mismatch): Simplify to remove dependence on
CL's internals.
2012-06-11 15:52:50 +00:00
|
|
|
(defun cl--do-prettyprint ()
|
1993-07-30 20:15:09 +00:00
|
|
|
(skip-chars-forward " ")
|
|
|
|
(if (looking-at "(")
|
|
|
|
(let ((skip (or (looking-at "((") (looking-at "(prog")
|
|
|
|
(looking-at "(unwind-protect ")
|
|
|
|
(looking-at "(function (")
|
Use lexical-binding for all of CL, and clean up its namespace.
* lisp/emacs-lisp/cl-lib.el: Use lexical-binding.
(cl-map-extents, cl-maclisp-member): Remove.
(cl--set-elt, cl--set-nthcdr, cl--set-buffer-substring)
(cl--set-substring, cl--block-wrapper, cl--block-throw)
(cl--compiling-file, cl--mapcar-many, cl--do-subst): Use "cl--" prefix.
* lisp/emacs-lisp/cl-extra.el: Use lexical-binding.
(cl--mapcar-many, cl--map-keymap-recursively, cl--map-intervals)
(cl--map-overlays, cl--set-frame-visible-p, cl--progv-save)
(cl--progv-before, cl--progv-after, cl--finite-do, cl--set-getf)
(cl--do-remf, cl--do-prettyprint): Use "cl--" prefix.
* lisp/emacs-lisp/cl-seq.el: Use lexical-binding.
(cl--parsing-keywords, cl--check-key, cl--check-test-nokey)
(cl--check-test, cl--check-match): Use "cl--" prefix and backquotes.
(cl--alist, cl--sublis-rec, cl--nsublis-rec, cl--tree-equal-rec):
* lisp/emacs-lisp/cl-macs.el (cl--lambda-list-keywords): Use "cl--" prefix.
* lisp/edmacro.el (edmacro-mismatch): Simplify to remove dependence on
CL's internals.
2012-06-11 15:52:50 +00:00
|
|
|
(looking-at "(cl--block-wrapper ")))
|
1993-07-30 20:15:09 +00:00
|
|
|
(two (or (looking-at "(defun ") (looking-at "(defmacro ")))
|
|
|
|
(let (or (looking-at "(let\\*? ") (looking-at "(while ")))
|
|
|
|
(set (looking-at "(p?set[qf] ")))
|
|
|
|
(if (or skip let
|
|
|
|
(progn
|
|
|
|
(forward-sexp)
|
|
|
|
(and (>= (current-column) 78) (progn (backward-sexp) t))))
|
|
|
|
(let ((nl t))
|
|
|
|
(forward-char 1)
|
Use lexical-binding for all of CL, and clean up its namespace.
* lisp/emacs-lisp/cl-lib.el: Use lexical-binding.
(cl-map-extents, cl-maclisp-member): Remove.
(cl--set-elt, cl--set-nthcdr, cl--set-buffer-substring)
(cl--set-substring, cl--block-wrapper, cl--block-throw)
(cl--compiling-file, cl--mapcar-many, cl--do-subst): Use "cl--" prefix.
* lisp/emacs-lisp/cl-extra.el: Use lexical-binding.
(cl--mapcar-many, cl--map-keymap-recursively, cl--map-intervals)
(cl--map-overlays, cl--set-frame-visible-p, cl--progv-save)
(cl--progv-before, cl--progv-after, cl--finite-do, cl--set-getf)
(cl--do-remf, cl--do-prettyprint): Use "cl--" prefix.
* lisp/emacs-lisp/cl-seq.el: Use lexical-binding.
(cl--parsing-keywords, cl--check-key, cl--check-test-nokey)
(cl--check-test, cl--check-match): Use "cl--" prefix and backquotes.
(cl--alist, cl--sublis-rec, cl--nsublis-rec, cl--tree-equal-rec):
* lisp/emacs-lisp/cl-macs.el (cl--lambda-list-keywords): Use "cl--" prefix.
* lisp/edmacro.el (edmacro-mismatch): Simplify to remove dependence on
CL's internals.
2012-06-11 15:52:50 +00:00
|
|
|
(cl--do-prettyprint)
|
|
|
|
(or skip (looking-at ")") (cl--do-prettyprint))
|
|
|
|
(or (not two) (looking-at ")") (cl--do-prettyprint))
|
1993-07-30 20:15:09 +00:00
|
|
|
(while (not (looking-at ")"))
|
|
|
|
(if set (setq nl (not nl)))
|
|
|
|
(if nl (insert "\n"))
|
|
|
|
(lisp-indent-line)
|
Use lexical-binding for all of CL, and clean up its namespace.
* lisp/emacs-lisp/cl-lib.el: Use lexical-binding.
(cl-map-extents, cl-maclisp-member): Remove.
(cl--set-elt, cl--set-nthcdr, cl--set-buffer-substring)
(cl--set-substring, cl--block-wrapper, cl--block-throw)
(cl--compiling-file, cl--mapcar-many, cl--do-subst): Use "cl--" prefix.
* lisp/emacs-lisp/cl-extra.el: Use lexical-binding.
(cl--mapcar-many, cl--map-keymap-recursively, cl--map-intervals)
(cl--map-overlays, cl--set-frame-visible-p, cl--progv-save)
(cl--progv-before, cl--progv-after, cl--finite-do, cl--set-getf)
(cl--do-remf, cl--do-prettyprint): Use "cl--" prefix.
* lisp/emacs-lisp/cl-seq.el: Use lexical-binding.
(cl--parsing-keywords, cl--check-key, cl--check-test-nokey)
(cl--check-test, cl--check-match): Use "cl--" prefix and backquotes.
(cl--alist, cl--sublis-rec, cl--nsublis-rec, cl--tree-equal-rec):
* lisp/emacs-lisp/cl-macs.el (cl--lambda-list-keywords): Use "cl--" prefix.
* lisp/edmacro.el (edmacro-mismatch): Simplify to remove dependence on
CL's internals.
2012-06-11 15:52:50 +00:00
|
|
|
(cl--do-prettyprint))
|
1993-07-30 20:15:09 +00:00
|
|
|
(forward-char 1))))
|
|
|
|
(forward-sexp)))
|
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;;;###autoload
|
1993-07-30 20:15:09 +00:00
|
|
|
(defun cl-prettyexpand (form &optional full)
|
2012-11-05 08:29:12 +00:00
|
|
|
"Expand macros in FORM and insert the pretty-printed result.
|
|
|
|
Optional argument FULL non-nil means to expand all macros,
|
|
|
|
including `cl-block' and `cl-eval-when'."
|
1993-07-30 20:15:09 +00:00
|
|
|
(message "Expanding...")
|
Use lexical-binding for all of CL, and clean up its namespace.
* lisp/emacs-lisp/cl-lib.el: Use lexical-binding.
(cl-map-extents, cl-maclisp-member): Remove.
(cl--set-elt, cl--set-nthcdr, cl--set-buffer-substring)
(cl--set-substring, cl--block-wrapper, cl--block-throw)
(cl--compiling-file, cl--mapcar-many, cl--do-subst): Use "cl--" prefix.
* lisp/emacs-lisp/cl-extra.el: Use lexical-binding.
(cl--mapcar-many, cl--map-keymap-recursively, cl--map-intervals)
(cl--map-overlays, cl--set-frame-visible-p, cl--progv-save)
(cl--progv-before, cl--progv-after, cl--finite-do, cl--set-getf)
(cl--do-remf, cl--do-prettyprint): Use "cl--" prefix.
* lisp/emacs-lisp/cl-seq.el: Use lexical-binding.
(cl--parsing-keywords, cl--check-key, cl--check-test-nokey)
(cl--check-test, cl--check-match): Use "cl--" prefix and backquotes.
(cl--alist, cl--sublis-rec, cl--nsublis-rec, cl--tree-equal-rec):
* lisp/emacs-lisp/cl-macs.el (cl--lambda-list-keywords): Use "cl--" prefix.
* lisp/edmacro.el (edmacro-mismatch): Simplify to remove dependence on
CL's internals.
2012-06-11 15:52:50 +00:00
|
|
|
(let ((cl--compiling-file full)
|
1993-07-30 20:15:09 +00:00
|
|
|
(byte-compile-macro-environment nil))
|
Move old compatiblity to cl.el. Remove cl-macroexpand-all.
* emacs-lisp/cl-extra.el (cl-map-keymap, cl-copy-tree)
(cl-not-hash-table, cl-builtin-gethash, cl-builtin-remhash)
(cl-builtin-clrhash, cl-builtin-maphash, cl-gethash, cl-puthash)
(cl-remhash, cl-clrhash, cl-maphash, cl-make-hash-table)
(cl-hash-table-p, cl-hash-table-count): Move to cl.el.
(cl-macroexpand-cmacs): Remove var.
(cl-macroexpand-all, cl-macroexpand-body): Remove funs.
Use macroexpand-all instead.
* emacs-lisp/cl-lib.el (cl-macro-environment): Remove decl.
(cl-macroexpand): Move to cl-macs.el and rename to cl--sm-macroexpand.
(cl-member): Remove old alias.
* emacs-lisp/cl-macs.el (cl-macro-environment): Remove var.
Use macroexpand-all-environment instead.
(cl--old-macroexpand): New var.
(cl--sm-macroexpand): New function.
(cl-symbol-macrolet): Use it during macro expansion.
(cl--function-convert-cache): New var.
(cl--function-convert): New function, extracted from
cl-macroexpand-all.
(cl-lexical-let): Use it.
* emacs-lisp/cl.el (cl-macroexpand, cl-macro-environment)
(cl-macroexpand-all, cl-not-hash-table, cl-builtin-gethash)
(cl-builtin-remhash, cl-builtin-clrhash, cl-builtin-maphash)
(cl-map-keymap, cl-copy-tree, cl-gethash, cl-puthash, cl-remhash)
(cl-clrhash, cl-maphash, cl-make-hash-table, cl-hash-table-p)
(cl-hash-table-count): Add old compatibility aliases.
2012-06-07 19:48:22 +00:00
|
|
|
(setq form (macroexpand-all form
|
|
|
|
(and (not full) '((cl-block) (cl-eval-when)))))
|
1993-07-30 20:15:09 +00:00
|
|
|
(message "Formatting...")
|
|
|
|
(prog1 (cl-prettyprint form)
|
|
|
|
(message ""))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(run-hooks 'cl-extra-load-hook)
|
|
|
|
|
2007-06-27 19:13:46 +00:00
|
|
|
;; Local variables:
|
2009-08-25 06:52:09 +00:00
|
|
|
;; byte-compile-dynamic: t
|
2007-06-27 19:13:46 +00:00
|
|
|
;; generated-autoload-file: "cl-loaddefs.el"
|
|
|
|
;; End:
|
|
|
|
|
1993-07-30 20:15:09 +00:00
|
|
|
;;; cl-extra.el ends here
|