1 ;;; cl.el --- Compatibility aliases for the old CL library.
3 ;; Copyright (C) 2012 Free Software Foundation, Inc.
5 ;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
6 ;; Keywords: extensions
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25 ;; This is a compatibility file which provides the old names provided by CL
26 ;; before we cleaned up its namespace usage.
32 ;; (defun cl--rename ()
35 ;; (case-fold-search nil)
36 ;; (files '("cl.el" "cl-macs.el" "cl-seq.el" "cl-extra.el")))
37 ;; (dolist (file files)
38 ;; (with-current-buffer (find-file-noselect file)
39 ;; (goto-char (point-min))
40 ;; (while (re-search-forward
41 ;; "^(\\(def[^ \t\n]*\\) +'?\\(\\(\\sw\\|\\s_\\)+\\)" nil t)
42 ;; (let ((name (match-string-no-properties 2))
43 ;; (type (match-string-no-properties 1)))
44 ;; (unless (string-match-p "\\`cl-" name)
46 ;; ((member type '("defvar" "defconst"))
47 ;; (unless (member name vdefs) (push name vdefs)))
48 ;; ((member type '("defun" "defsubst" "defalias" "defmacro"))
49 ;; (unless (member name fdefs) (push name fdefs)))
50 ;; ((member type '("def-edebug-spec" "defsetf" "define-setf-method"
51 ;; "define-compiler-macro"))
53 ;; (t (error "Unknown type %S" type))))))))
54 ;; (let ((re (concat "\\_<" (regexp-opt (append vdefs fdefs)) "\\_>"))
56 ;; (dolist (file files)
57 ;; (with-current-buffer (find-file-noselect file)
58 ;; (goto-char (point-min))
59 ;; (while (re-search-forward re nil t)
60 ;; (replace-match "cl-\\&"))
62 ;; (with-current-buffer (find-file-noselect "cl-rename.el")
63 ;; (dolist (def vdefs)
64 ;; (insert (format "(defvaralias '%s 'cl-%s)\n" def def)))
65 ;; (dolist (def fdefs)
66 ;; (insert (format "(defalias '%s 'cl-%s)\n" def def)))
69 ;; (defun cl--unrename ()
70 ;; ;; Taken from "Naming Conventions" node of the doc.
71 ;; (let* ((names '(defun* defsubst* defmacro* function* member*
72 ;; assoc* rassoc* get* remove* delete*
73 ;; mapcar* sort* floor* ceiling* truncate*
74 ;; round* mod* rem* random*))
75 ;; (files '("cl.el" "cl-lib.el" "cl-macs.el" "cl-seq.el" "cl-extra.el"))
76 ;; (re (concat "\\_<cl-" (regexp-opt (mapcar #'symbol-name names))
78 ;; (dolist (file files)
79 ;; (with-current-buffer (find-file-noselect file)
80 ;; (goto-char (point-min))
81 ;; (while (re-search-forward re nil t)
82 ;; (delete-region (1- (point)) (point)))
93 ;; lambda-list-keywords
94 float-negative-epsilon
96 least-negative-normalized-float
97 least-positive-normalized-float
102 ;; custom-print-functions
104 (defvaralias var
(intern (format "cl-%s" var
))))
108 (random* . cl-random
)
112 (truncate* . cl-truncate
)
113 (ceiling* . cl-ceiling
)
115 (rassoc* . cl-rassoc
)
117 (member* . cl-member
)
118 (delete* . cl-delete
)
119 (remove* . cl-remove
)
120 (defsubst* . cl-defsubst
)
122 (function* . cl-function
)
123 (defmacro* . cl-defmacro
)
125 (mapcar* . cl-mapcar
)
204 define-compiler-macro
222 (define-setf-method . cl-define-setf-expander
)
320 (let ((new (if (consp fun
) (prog1 (cdr fun
) (setq fun
(car fun
)))
321 (intern (format "cl-%s" fun
)))))
323 ;; If `cl-foo' is declare inline, then make `foo' inline as well, and
324 ;; similarly. Same for edebug specifications, indent rules and
325 ;; doc-string position.
326 ;; FIXME: For most of them, we should instead follow aliases
328 (dolist (prop '(byte-optimizer doc-string-elt edebug-form-spec
329 lisp-indent-function
))
331 (put fun prop
(get new prop
))))))