summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2012-06-10 09:28:26 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2012-06-10 09:28:26 -0400
commitf80efb8695cd8b4480c5f041c484beb5486afb37 (patch)
tree11cdf753a8e8a270fa79eb1dc794aa8426d3893e /lisp/emacs-lisp
parent31ca4639ad1bfaa355a3f30ef92eb977bd2c6b78 (diff)
downloademacs-f80efb8695cd8b4480c5f041c484beb5486afb37.tar.gz
Reduce use of cl in lisp/emacs-lisp/.
* lisp/emacs-lisp/timer.el, lisp/emacs-lisp/syntax.el, lisp/emacs-lisp/smie.el: * lisp/emacs-lisp/ewoc.el, lisp/emacs-lisp/cconv.el,lisp/emacs-lisp/derived.el: * lisp/emacs-lisp/byte-opt.el, lisp/emacs-lisp/autoload.el: Convert to cl-lib. * lisp/emacs-lisp/easymenu.el, lisp/emacs-lisp/easy-mmode.el: * lisp/emacs-lisp/bytecomp.el: Use pcase instead of `cl'. * lisp/emacs-lisp/cl-lib.el: Get rid of special cl-macs auto load.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/autoload.el6
-rw-r--r--lisp/emacs-lisp/byte-opt.el10
-rw-r--r--lisp/emacs-lisp/bytecomp.el42
-rw-r--r--lisp/emacs-lisp/cconv.el56
-rw-r--r--lisp/emacs-lisp/cl-lib.el23
-rw-r--r--lisp/emacs-lisp/derived.el12
-rw-r--r--lisp/emacs-lisp/easy-mmode.el56
-rw-r--r--lisp/emacs-lisp/easymenu.el34
-rw-r--r--lisp/emacs-lisp/ewoc.el56
-rw-r--r--lisp/emacs-lisp/smie.el111
-rw-r--r--lisp/emacs-lisp/syntax.el36
-rw-r--r--lisp/emacs-lisp/timer.el48
12 files changed, 232 insertions, 258 deletions
diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el
index d9fc0fccf0e..9cd626c52f4 100644
--- a/lisp/emacs-lisp/autoload.el
+++ b/lisp/emacs-lisp/autoload.el
@@ -32,7 +32,7 @@
(require 'lisp-mode) ;for `doc-string-elt' properties.
(require 'help-fns) ;for help-add-fundoc-usage.
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
(defvar generated-autoload-file nil
"File into which to write autoload definitions.
@@ -154,7 +154,7 @@ expression, in which case we want to handle forms differently."
defun* defmacro* define-overloadable-function))
(let* ((macrop (memq car '(defmacro defmacro*)))
(name (nth 1 form))
- (args (case car
+ (args (cl-case car
((defun defmacro defun* defmacro*
define-overloadable-function) (nth 2 form))
((define-skeleton) '(&optional str arg))
@@ -546,7 +546,7 @@ Return non-nil if and only if FILE adds no autoloads to OUTFILE
(save-excursion
;; Insert the section-header line which lists the file name
;; and which functions are in it, etc.
- (assert (= ostart output-start))
+ (cl-assert (= ostart output-start))
(goto-char output-start)
(let ((relfile (file-relative-name absfile)))
(autoload-insert-section-header
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index 25b4686f87d..ab0e22fb5ce 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -183,7 +183,7 @@
;;; Code:
(require 'bytecomp)
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
(require 'macroexp)
(defun byte-compile-log-lap-1 (format &rest args)
@@ -642,7 +642,7 @@
(while (eq (car-safe form) 'progn)
(setq form (car (last (cdr form)))))
(cond ((consp form)
- (case (car form)
+ (cl-case (car form)
(quote (cadr form))
;; Can't use recursion in a defsubst.
;; (progn (byte-compile-trueconstp (car (last (cdr form)))))
@@ -656,7 +656,7 @@
(while (eq (car-safe form) 'progn)
(setq form (car (last (cdr form)))))
(cond ((consp form)
- (case (car form)
+ (cl-case (car form)
(quote (null (cadr form)))
;; Can't use recursion in a defsubst.
;; (progn (byte-compile-nilconstp (car (last (cdr form)))))
@@ -1376,7 +1376,7 @@
;; This uses dynamic-scope magic.
offset (disassemble-offset bytes))
(let ((opcode (aref byte-code-vector bytedecomp-op)))
- (assert opcode)
+ (cl-assert opcode)
(setq bytedecomp-op opcode))
(cond ((memq bytedecomp-op byte-goto-ops)
;; It's a pc.
@@ -1619,7 +1619,7 @@ If FOR-EFFECT is non-nil, the return value is assumed to be of no importance."
(byte-compile-log-lap " dup %s discard\t-->\t%s" lap1 lap1)
(setq keep-going t
rest (cdr rest))
- (if (eq 'byte-stack-set (car lap1)) (decf (cdr lap1)))
+ (if (eq 'byte-stack-set (car lap1)) (cl-decf (cdr lap1)))
(setq lap (delq lap0 (delq lap2 lap))))
;;
;; not goto-X-if-nil --> goto-X-if-non-nil
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 25a901fd248..98bdcc69f95 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -120,7 +120,7 @@
(require 'backquote)
(require 'macroexp)
(require 'cconv)
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
(or (fboundp 'defsubst)
;; This really ought to be loaded already!
@@ -738,7 +738,7 @@ BYTES and PC are updated after evaluating all the arguments."
(bytes-var (car (last args 2)))
(pc-var (car (last args))))
`(setq ,bytes-var ,(if (null (cdr byte-exprs))
- `(progn (assert (<= 0 ,(car byte-exprs)))
+ `(progn (cl-assert (<= 0 ,(car byte-exprs)))
(cons ,@byte-exprs ,bytes-var))
`(nconc (list ,@(reverse byte-exprs)) ,bytes-var))
,pc-var (+ ,(length byte-exprs) ,pc-var))))
@@ -1591,7 +1591,7 @@ that already has a `.elc' file."
(not (auto-save-file-name-p source))
(not (string-equal dir-locals-file
(file-name-nondirectory source))))
- (progn (case (byte-recompile-file source force arg)
+ (progn (cl-case (byte-recompile-file source force arg)
(no-byte-compile (setq skip-count (1+ skip-count)))
((t) (setq file-count (1+ file-count)))
((nil) (setq fail-count (1+ fail-count))))
@@ -1725,12 +1725,12 @@ The value is non-nil if there were no errors, nil if errors."
(set-buffer-multibyte nil))
;; Run hooks including the uncompression hook.
;; If they change the file name, then change it for the output also.
- (letf ((buffer-file-name filename)
- ((default-value 'major-mode) 'emacs-lisp-mode)
- ;; Ignore unsafe local variables.
- ;; We only care about a few of them for our purposes.
- (enable-local-variables :safe)
- (enable-local-eval nil))
+ (cl-letf ((buffer-file-name filename)
+ ((default-value 'major-mode) 'emacs-lisp-mode)
+ ;; Ignore unsafe local variables.
+ ;; We only care about a few of them for our purposes.
+ (enable-local-variables :safe)
+ (enable-local-eval nil))
;; Arg of t means don't alter enable-local-variables.
(normal-mode t)
;; There may be a file local variable setting (bug#10419).
@@ -2611,7 +2611,7 @@ for symbols generated by the byte compiler itself."
(byte-compile-make-lambda-lexenv fun))
reserved-csts)))
;; Build the actual byte-coded function.
- (assert (eq 'byte-code (car-safe compiled)))
+ (cl-assert (eq 'byte-code (car-safe compiled)))
(apply #'make-byte-code
(if lexical-binding
(byte-compile-make-args-desc arglist)
@@ -2654,7 +2654,7 @@ for symbols generated by the byte compiler itself."
(while (and rest (< i limit))
(cond
((numberp (car rest))
- (assert (< (car rest) byte-compile-reserved-constants)))
+ (cl-assert (< (car rest) byte-compile-reserved-constants)))
((setq tmp (assq (car (car rest)) ret))
(setcdr (car rest) (cdr tmp)))
(t
@@ -2933,9 +2933,9 @@ That command is designed for interactive use only" fn))
(mapc 'byte-compile-form (cdr form))
(unless fmax2
;; Old-style byte-code.
- (assert (listp fargs))
+ (cl-assert (listp fargs))
(while fargs
- (case (car fargs)
+ (cl-case (car fargs)
(&optional (setq fargs (cdr fargs)))
(&rest (setq fmax2 (+ (* 2 (length dynbinds)) 1))
(push (cadr fargs) dynbinds)
@@ -2954,7 +2954,7 @@ That command is designed for interactive use only" fn))
(t
;; Turn &rest args into a list.
(let ((n (- alen (/ (1- fmax2) 2))))
- (assert (> n 0) nil "problem: fmax2=%S alen=%S n=%S" fmax2 alen n)
+ (cl-assert (> n 0) nil "problem: fmax2=%S alen=%S n=%S" fmax2 alen n)
(if (< n 5)
(byte-compile-out
(aref [byte-list1 byte-list2 byte-list3 byte-list4] (1- n))
@@ -2967,7 +2967,7 @@ That command is designed for interactive use only" fn))
;; Unbind dynamic variables.
(when dynbinds
(byte-compile-out 'byte-unbind (length dynbinds)))
- (assert (eq byte-compile-depth (1+ start-depth))
+ (cl-assert (eq byte-compile-depth (1+ start-depth))
nil "Wrong depth start=%s end=%s" start-depth byte-compile-depth)))
(defun byte-compile-check-variable (var access-type)
@@ -2985,7 +2985,7 @@ That command is designed for interactive use only" fn))
(and od
(not (memq var byte-compile-not-obsolete-vars))
(not (memq var byte-compile-global-not-obsolete-vars))
- (or (case (nth 1 od)
+ (or (cl-case (nth 1 od)
(set (not (eq access-type 'reference)))
(get (eq access-type 'reference))
(t t)))))
@@ -3312,8 +3312,8 @@ discarding."
(body (nthcdr 3 form))
(fun
(byte-compile-lambda `(lambda ,vars . ,body) nil (length env))))
- (assert (> (length env) 0)) ;Otherwise, we don't need a closure.
- (assert (byte-code-function-p fun))
+ (cl-assert (> (length env) 0)) ;Otherwise, we don't need a closure.
+ (cl-assert (byte-code-function-p fun))
(byte-compile-form `(make-byte-code
',(aref fun 0) ',(aref fun 1)
(vconcat (vector . ,env) ',(aref fun 2))
@@ -3891,8 +3891,8 @@ binding slots have been popped."
(if lexical-binding
;; Unbind both lexical and dynamic variables.
(progn
- (assert (or (eq byte-compile-depth init-stack-depth)
- (eq byte-compile-depth (1+ init-stack-depth))))
+ (cl-assert (or (eq byte-compile-depth init-stack-depth)
+ (eq byte-compile-depth (1+ init-stack-depth))))
(byte-compile-unbind clauses init-lexenv (> byte-compile-depth
init-stack-depth)))
;; Unbind dynamic variables.
@@ -4312,7 +4312,7 @@ invoked interactively."
(if byte-compile-call-tree-sort
(setq byte-compile-call-tree
(sort byte-compile-call-tree
- (case byte-compile-call-tree-sort
+ (cl-case byte-compile-call-tree-sort
(callers
(lambda (x y) (< (length (nth 1 x))
(length (nth 1 y)))))
diff --git a/lisp/emacs-lisp/cconv.el b/lisp/emacs-lisp/cconv.el
index f43dd9e7ee4..6f411bdeb30 100644
--- a/lisp/emacs-lisp/cconv.el
+++ b/lisp/emacs-lisp/cconv.el
@@ -110,7 +110,7 @@
;; ,@(mapcar (lambda (binder) (if (consp binder) (cadr binder)))
;; binders)))
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
(defconst cconv-liftwhen 6
"Try to do lambda lifting if the number of arguments + free variables
@@ -173,7 +173,7 @@ Returns a form where all lambdas don't have any free variables."
;; Here we assume that X appears at most once in M.
(let* ((b (assq x m))
(res (if b (remq b m) m)))
- (assert (null (assq x res))) ;; Check the assumption was warranted.
+ (cl-assert (null (assq x res))) ;; Check the assumption was warranted.
res))
(defun cconv--map-diff-set (m s)
@@ -185,7 +185,7 @@ Returns a form where all lambdas don't have any free variables."
(nreverse res)))
(defun cconv--convert-function (args body env parentform)
- (assert (equal body (caar cconv-freevars-alist)))
+ (cl-assert (equal body (caar cconv-freevars-alist)))
(let* ((fvs (cdr (pop cconv-freevars-alist)))
(body-new '())
(letbind '())
@@ -251,11 +251,11 @@ ENV is a list where each entry takes the shape either:
EXTEND is a list of variables which might need to be accessed even from places
where they are shadowed, because some part of ENV causes them to be used at
places where they originally did not directly appear."
- (assert (not (delq nil (mapcar (lambda (mapping)
- (if (eq (cadr mapping) 'apply-partially)
- (cconv--set-diff (cdr (cddr mapping))
- extend)))
- env))))
+ (cl-assert (not (delq nil (mapcar (lambda (mapping)
+ (if (eq (cadr mapping) 'apply-partially)
+ (cconv--set-diff (cdr (cddr mapping))
+ extend)))
+ env))))
;; What's the difference between fvrs and envs?
;; Suppose that we have the code
@@ -287,10 +287,10 @@ places where they originally did not directly appear."
;; Check if var is a candidate for lambda lifting.
((and (member (cons binder form) cconv-lambda-candidates)
(progn
- (assert (and (eq (car value) 'function)
- (eq (car (cadr value)) 'lambda)))
- (assert (equal (cddr (cadr value))
- (caar cconv-freevars-alist)))
+ (cl-assert (and (eq (car value) 'function)
+ (eq (car (cadr value)) 'lambda)))
+ (cl-assert (equal (cddr (cadr value))
+ (caar cconv-freevars-alist)))
;; Peek at the freevars to decide whether to λ-lift.
(let* ((fvs (cdr (car cconv-freevars-alist)))
(fun (cadr value))
@@ -307,7 +307,7 @@ places where they originally did not directly appear."
(funcbody-env ()))
(push `(,var . (apply-partially ,var . ,fvs)) new-env)
(dolist (fv fvs)
- (pushnew fv new-extend)
+ (cl-pushnew fv new-extend)
(if (and (eq 'car (car-safe (cdr (assq fv env))))
(not (memq fv funargs)))
(push `(,fv . (car ,fv)) funcbody-env)))
@@ -345,14 +345,14 @@ places where they originally did not directly appear."
(mapcar (lambda (mapping)
(if (not (eq (cadr mapping) 'apply-partially))
mapping
- (assert (eq (car mapping) (nth 2 mapping)))
- (list* (car mapping)
- 'apply-partially
- (car mapping)
- (mapcar (lambda (arg)
- (if (eq var arg)
- closedsym arg))
- (nthcdr 3 mapping)))))
+ (cl-assert (eq (car mapping) (nth 2 mapping)))
+ (cl-list* (car mapping)
+ 'apply-partially
+ (car mapping)
+ (mapcar (lambda (arg)
+ (if (eq var arg)
+ closedsym arg))
+ (nthcdr 3 mapping)))))
new-env))
(setq new-extend (remq var new-extend))
(push closedsym new-extend)
@@ -455,7 +455,7 @@ places where they originally did not directly appear."
(let ((mapping (cdr (assq fun env))))
(pcase mapping
(`(apply-partially ,_ . ,(and fvs `(,_ . ,_)))
- (assert (eq (cadr mapping) fun))
+ (cl-assert (eq (cadr mapping) fun))
`(,callsym ,fun
,@(mapcar (lambda (fv)
(let ((exp (or (cdr (assq fv env)) fv)))
@@ -551,7 +551,7 @@ FORM is the parent form that binds this var."
;; Transfer uses collected in `envcopy' (via `newenv') back to `env';
;; and compute free variables.
(while env
- (assert (and envcopy (eq (caar env) (caar envcopy))))
+ (cl-assert (and envcopy (eq (caar env) (caar envcopy))))
(let ((free nil)
(x (cdr (car env)))
(y (cdr (car envcopy))))
@@ -559,8 +559,8 @@ FORM is the parent form that binds this var."
(when (car y) (setcar x t) (setq free t))
(setq x (cdr x) y (cdr y)))
(when free
- (push (caar env) (cdr freevars))
- (setf (nth 3 (car env)) t))
+ (cl-push (caar env) (cdr freevars))
+ (cl-setf (nth 3 (car env)) t))
(setq env (cdr env) envcopy (cdr envcopy))))))
(defun cconv-analyse-form (form env)
@@ -610,7 +610,7 @@ and updates the data stored in ENV."
;; it is a mutated variable.
(while forms
(let ((v (assq (car forms) env))) ; v = non nil if visible
- (when v (setf (nth 2 v) t)))
+ (when v (cl-setf (nth 2 v) t)))
(cconv-analyse-form (cadr forms) env)
(setq forms (cddr forms))))
@@ -656,7 +656,7 @@ and updates the data stored in ENV."
;; lambda candidate list.
(let ((fdata (and (symbolp fun) (assq fun env))))
(if fdata
- (setf (nth 4 fdata) t)
+ (cl-setf (nth 4 fdata) t)
(cconv-analyse-form fun env)))
(dolist (form args) (cconv-analyse-form form env)))
@@ -676,7 +676,7 @@ and updates the data stored in ENV."
((pred symbolp)
(let ((dv (assq form env))) ; dv = declared and visible
(when dv
- (setf (nth 1 dv) t))))))
+ (cl-setf (nth 1 dv) t))))))
(provide 'cconv)
;;; cconv.el ends here
diff --git a/lisp/emacs-lisp/cl-lib.el b/lisp/emacs-lisp/cl-lib.el
index 6ec1060e39f..8c0743001f7 100644
--- a/lisp/emacs-lisp/cl-lib.el
+++ b/lisp/emacs-lisp/cl-lib.el
@@ -644,29 +644,6 @@ If ALIST is non-nil, the new pairs are prepended to it."
(load "cl-loaddefs" nil 'quiet)
-;; This goes here so that cl-macs can find it if it loads right now.
-(provide 'cl-lib)
-
-;; Things to do after byte-compiler is loaded.
-
-(defvar cl-hacked-flag nil)
-(defun cl-hack-byte-compiler ()
- (and (not cl-hacked-flag) (fboundp 'byte-compile-file-form)
- (progn
- (setq cl-hacked-flag t) ; Do it first, to prevent recursion.
- (load "cl-macs" nil t)
- (run-hooks 'cl-hack-bytecomp-hook))))
-
-;; Try it now in case the compiler has already been loaded.
-(cl-hack-byte-compiler)
-
-;; Also make a hook in case compiler is loaded after this file.
-(add-hook 'bytecomp-load-hook 'cl-hack-byte-compiler)
-
-
-;; The following ensures that packages which expect the old-style cl.el
-;; will be happy with this one.
-
(provide 'cl-lib)
(run-hooks 'cl-load-hook)
diff --git a/lisp/emacs-lisp/derived.el b/lisp/emacs-lisp/derived.el
index 119479b2c0a..ea72e9492f0 100644
--- a/lisp/emacs-lisp/derived.el
+++ b/lisp/emacs-lisp/derived.el
@@ -90,8 +90,6 @@
;;; Code:
-(eval-when-compile (require 'cl))
-
;;; PRIVATE: defsubst must be defined before they are first used
(defsubst derived-mode-hook-name (mode)
@@ -183,11 +181,11 @@ See Info node `(elisp)Derived Modes' for more details."
;; Process the keyword args.
(while (keywordp (car body))
- (case (pop body)
- (:group (setq group (pop body)))
- (:abbrev-table (setq abbrev (pop body)) (setq declare-abbrev nil))
- (:syntax-table (setq syntax (pop body)) (setq declare-syntax nil))
- (t (pop body))))
+ (pcase (pop body)
+ (`:group (setq group (pop body)))
+ (`:abbrev-table (setq abbrev (pop body)) (setq declare-abbrev nil))
+ (`:syntax-table (setq syntax (pop body)) (setq declare-syntax nil))
+ (_ (pop body))))
(setq docstring (derived-mode-make-docstring
parent child docstring syntax abbrev))
diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el
index abb1edca4ee..4da48805278 100644
--- a/lisp/emacs-lisp/easy-mmode.el
+++ b/lisp/emacs-lisp/easy-mmode.el
@@ -51,8 +51,6 @@
;;; Code:
-(eval-when-compile (require 'cl))
-
(defun easy-mmode-pretty-mode-name (mode &optional lighter)
"Turn the symbol MODE into a string intended for the user.
If provided, LIGHTER will be used to help choose capitalization by,
@@ -153,10 +151,10 @@ For example, you could write
;; Allow skipping the first three args.
(cond
((keywordp init-value)
- (setq body (list* init-value lighter keymap body)
+ (setq body `(,init-value ,lighter ,keymap ,@body)
init-value nil lighter nil keymap nil))
((keywordp lighter)
- (setq body (list* lighter keymap body) lighter nil keymap nil))
+ (setq body `(,lighter ,keymap ,@body) lighter nil keymap nil))
((keywordp keymap) (push keymap body) (setq keymap nil)))
(let* ((last-message (make-symbol "last-message"))
@@ -182,18 +180,18 @@ For example, you could write
;; Check keys.
(while (keywordp (setq keyw (car body)))
(setq body (cdr body))
- (case keyw
- (:init-value (setq init-value (pop body)))
- (:lighter (setq lighter (purecopy (pop body))))
- (:global (setq globalp (pop body)))
- (:extra-args (setq extra-args (pop body)))
- (:set (setq set (list :set (pop body))))
- (:initialize (setq initialize (list :initialize (pop body))))
- (:group (setq group (nconc group (list :group (pop body)))))
- (:type (setq type (list :type (pop body))))
- (:require (setq require (pop body)))
- (:keymap (setq keymap (pop body)))
- (:variable (setq variable (pop body))
+ (pcase keyw
+ (`:init-value (setq init-value (pop body)))
+ (`:lighter (setq lighter (purecopy (pop body))))
+ (`:global (setq globalp (pop body)))
+ (`:extra-args (setq extra-args (pop body)))
+ (`:set (setq set (list :set (pop body))))
+ (`:initialize (setq initialize (list :initialize (pop body))))
+ (`:group (setq group (nconc group (list :group (pop body)))))
+ (`:type (setq type (list :type (pop body))))
+ (`:require (setq require (pop body)))
+ (`:keymap (setq keymap (pop body)))
+ (`:variable (setq variable (pop body))
(if (not (and (setq tmp (cdr-safe variable))
(or (symbolp tmp)
(functionp tmp))))
@@ -201,8 +199,8 @@ For example, you could write
(setq mode variable)
(setq mode (car variable))
(setq setter (cdr variable))))
- (:after-hook (setq after-hook (pop body)))
- (t (push keyw extra-keywords) (push (pop body) extra-keywords))))
+ (`:after-hook (setq after-hook (pop body)))
+ (_ (push keyw extra-keywords) (push (pop body) extra-keywords))))
(setq keymap-sym (if (and keymap (symbolp keymap)) keymap
(intern (concat mode-name "-map"))))
@@ -355,10 +353,10 @@ call another major mode in their body."
;; Check keys.
(while (keywordp (setq keyw (car keys)))
(setq keys (cdr keys))
- (case keyw
- (:group (setq group (nconc group (list :group (pop keys)))))
- (:global (setq keys (cdr keys)))
- (t (push keyw extra-keywords) (push (pop keys) extra-keywords))))
+ (pcase keyw
+ (`:group (setq group (nconc group (list :group (pop keys)))))
+ (`:global (setq keys (cdr keys)))
+ (_ (push keyw extra-keywords) (push (pop keys) extra-keywords))))
(unless group
;; We might as well provide a best-guess default group.
@@ -479,13 +477,13 @@ Valid keywords and arguments are:
(while args
(let ((key (pop args))
(val (pop args)))
- (case key
- (:name (setq name val))
- (:dense (setq dense val))
- (:inherit (setq inherit val))
- (:suppress (setq suppress val))
- (:group)
- (t (message "Unknown argument %s in defmap" key)))))
+ (pcase key
+ (`:name (setq name val))
+ (`:dense (setq dense val))
+ (`:inherit (setq inherit val))
+ (`:suppress (setq suppress val))
+ (`:group)
+ (_ (message "Unknown argument %s in defmap" key)))))
(unless (keymapp m)
(setq bs (append m bs))
(setq m (if dense (make-keymap name) (make-sparse-keymap name))))
diff --git a/lisp/emacs-lisp/easymenu.el b/lisp/emacs-lisp/easymenu.el
index b3e54b415d8..7f9f8a33634 100644
--- a/lisp/emacs-lisp/easymenu.el
+++ b/lisp/emacs-lisp/easymenu.el
@@ -29,8 +29,6 @@
;;; Code:
-(eval-when-compile (require 'cl))
-
(defvar easy-menu-precalculate-equivalent-keybindings nil
"Determine when equivalent key bindings are computed for easy-menu menus.
It can take some time to calculate the equivalent key bindings that are shown
@@ -236,14 +234,14 @@ possibly preceded by keyword pairs as described in `easy-menu-define'."
(keywordp (setq keyword (car menu-items))))
(setq arg (cadr menu-items))
(setq menu-items (cddr menu-items))
- (case keyword
- (:filter
+ (pcase keyword
+ (`:filter
(setq filter `(lambda (menu)
(easy-menu-filter-return (,arg menu) ,menu-name))))
- ((:enable :active) (setq enable (or arg ''nil)))
- (:label (setq label arg))
- (:help (setq help arg))
- ((:included :visible) (setq visible (or arg ''nil)))))
+ ((or `:enable `:active) (setq enable (or arg ''nil)))
+ (`:label (setq label arg))
+ (`:help (setq help arg))
+ ((or `:included `:visible) (setq visible (or arg ''nil)))))
(if (equal visible ''nil)
nil ; Invisible menu entry, return nil.
(if (and visible (not (easy-menu-always-true-p visible)))
@@ -334,16 +332,16 @@ ITEM defines an item as in `easy-menu-define'."
(setq keyword (aref item count))
(setq arg (aref item (1+ count)))
(setq count (+ 2 count))
- (case keyword
- ((:included :visible) (setq visible (or arg ''nil)))
- (:key-sequence (setq cache arg cache-specified t))
- (:keys (setq keys arg no-name nil))
- (:label (setq label arg))
- ((:active :enable) (setq active (or arg ''nil)))
- (:help (setq prop (cons :help (cons arg prop))))
- (:suffix (setq suffix arg))
- (:style (setq style arg))
- (:selected (setq selected (or arg ''nil)))))
+ (pcase keyword
+ ((or `:included `:visible) (setq visible (or arg ''nil)))
+ (`:key-sequence (setq cache arg cache-specified t))
+ (`:keys (setq keys arg no-name nil))
+ (`:label (setq label arg))
+ ((or `:active `:enable) (setq active (or arg ''nil)))
+ (`:help (setq prop (cons :help (cons arg prop))))
+ (`:suffix (setq suffix arg))
+ (`:style (setq style arg))
+ (`:selected (setq selected (or arg ''nil)))))
(if suffix
(setq label
(if (stringp suffix)
diff --git a/lisp/emacs-lisp/ewoc.el b/lisp/emacs-lisp/ewoc.el
index 9e214a9703c..02fdbc6e77f 100644
--- a/lisp/emacs-lisp/ewoc.el
+++ b/lisp/emacs-lisp/ewoc.el
@@ -96,11 +96,11 @@
;;; Code:
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
;; The doubly linked list is implemented as a circular list with a dummy
;; node first and last. The dummy node is used as "the dll".
-(defstruct (ewoc--node
+(cl-defstruct (ewoc--node
(:type vector) ;ewoc--node-nth needs this
(:constructor nil)
(:constructor ewoc--node-create (start-marker data)))
@@ -140,7 +140,7 @@ and (ewoc--node-nth dll -1) returns the last node."
;;; The ewoc data type
-(defstruct (ewoc
+(cl-defstruct (ewoc
(:constructor nil)
(:constructor ewoc--create (buffer pretty-printer dll))
(:conc-name ewoc--))
@@ -196,10 +196,10 @@ NODE and leaving the new node's start there. Return the new node."
(save-excursion
(let ((elemnode (ewoc--node-create
(copy-marker (ewoc--node-start-marker node)) data)))
- (setf (ewoc--node-left elemnode) (ewoc--node-left node)
- (ewoc--node-right elemnode) node
- (ewoc--node-right (ewoc--node-left node)) elemnode
- (ewoc--node-left node) elemnode)
+ (cl-setf (ewoc--node-left elemnode) (ewoc--node-left node)
+ (ewoc--node-right elemnode) node
+ (ewoc--node-right (ewoc--node-left node)) elemnode
+ (ewoc--node-left node) elemnode)
(ewoc--refresh-node pretty-printer elemnode dll)
elemnode)))
@@ -244,8 +244,8 @@ Normally, a newline is automatically inserted after the header,
the footer and every node's printed representation. Optional
fourth arg NOSEP non-nil inhibits this."
(let* ((dummy-node (ewoc--node-create 'DL-LIST 'DL-LIST))
- (dll (progn (setf (ewoc--node-right dummy-node) dummy-node)
- (setf (ewoc--node-left dummy-node) dummy-node)
+ (dll (progn (cl-setf (ewoc--node-right dummy-node) dummy-node)
+ (cl-setf (ewoc--node-left dummy-node) dummy-node)
dummy-node))
(wrap (if nosep 'identity 'ewoc--wrap))
(new-ewoc (ewoc--create (current-buffer)
@@ -258,12 +258,12 @@ fourth arg NOSEP non-nil inhibits this."
;; Set default values
(unless header (setq header ""))
(unless footer (setq footer ""))
- (setf (ewoc--node-start-marker dll) (copy-marker pos)
- foot (ewoc--insert-new-node dll footer hf-pp dll)
- head (ewoc--insert-new-node foot header hf-pp dll)
- (ewoc--hf-pp new-ewoc) hf-pp
- (ewoc--footer new-ewoc) foot
- (ewoc--header new-ewoc) head))
+ (cl-setf (ewoc--node-start-marker dll) (copy-marker pos)
+ foot (ewoc--insert-new-node dll footer hf-pp dll)
+ head (ewoc--insert-new-node foot header hf-pp dll)
+ (ewoc--hf-pp new-ewoc) hf-pp
+ (ewoc--footer new-ewoc) foot
+ (ewoc--header new-ewoc) head))
;; Return the ewoc
new-ewoc))
@@ -274,7 +274,7 @@ fourth arg NOSEP non-nil inhibits this."
(defun ewoc-set-data (node data)
"Set NODE to encapsulate DATA."
- (setf (ewoc--node-data node) data))
+ (cl-setf (ewoc--node-data node) data))
(defun ewoc-enter-first (ewoc data)
"Enter DATA first in EWOC.
@@ -356,18 +356,18 @@ arguments will be passed to MAP-FUNCTION."
;; If we are about to delete the node pointed at by last-node,
;; set last-node to nil.
(when (eq last node)
- (setf last nil (ewoc--last-node ewoc) nil))
+ (cl-setf last nil (ewoc--last-node ewoc) nil))
(delete-region (ewoc--node-start-marker node)
(ewoc--node-start-marker (ewoc--node-next dll node)))
(set-marker (ewoc--node-start-marker node) nil)
- (setf L (ewoc--node-left node)
- R (ewoc--node-right node)
- ;; Link neighbors to each other.
- (ewoc--node-right L) R
- (ewoc--node-left R) L
- ;; Forget neighbors.
- (ewoc--node-left node) nil
- (ewoc--node-right node) nil))))
+ (cl-setf L (ewoc--node-left node)
+ R (ewoc--node-right node)
+ ;; Link neighbors to each other.
+ (ewoc--node-right L) R
+ (ewoc--node-left R) L
+ ;; Forget neighbors.
+ (ewoc--node-left node) nil
+ (ewoc--node-right node) nil))))
(defun ewoc-filter (ewoc predicate &rest args)
"Remove all elements in EWOC for which PREDICATE returns nil.
@@ -503,7 +503,7 @@ Return the node (or nil if we just passed the last node)."
(ewoc--set-buffer-bind-dll ewoc
(goto-char (ewoc--node-start-marker node))
(if goal-column (move-to-column goal-column))
- (setf (ewoc--last-node ewoc) node)))
+ (cl-setf (ewoc--last-node ewoc) node)))
(defun ewoc-refresh (ewoc)
"Refresh all data in EWOC.
@@ -564,8 +564,8 @@ Return nil if the buffer has been deleted."
((head (ewoc--header ewoc))
(foot (ewoc--footer ewoc))
(hf-pp (ewoc--hf-pp ewoc)))
- (setf (ewoc--node-data head) header
- (ewoc--node-data foot) footer)
+ (cl-setf (ewoc--node-data head) header
+ (ewoc--node-data foot) footer)
(save-excursion
(ewoc--refresh-node hf-pp head dll)
(ewoc--refresh-node hf-pp foot dll))))
diff --git a/lisp/emacs-lisp/smie.el b/lisp/emacs-lisp/smie.el
index 01274b7ba20..136dff6df68 100644
--- a/lisp/emacs-lisp/smie.el
+++ b/lisp/emacs-lisp/smie.el
@@ -121,7 +121,7 @@
;; - smie-indent-comment doesn't interact well with mis-indented lines (where
;; the indent rules don't do what the user wants). Not sure what to do.
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
(defgroup smie nil
"Simple Minded Indentation Engine."
@@ -155,7 +155,7 @@
(defvar smie-warning-count 0)
(defun smie-set-prec2tab (table x y val &optional override)
- (assert (and x y))
+ (cl-assert (and x y))
(let* ((key (cons x y))
(old (gethash key table)))
(if (and old (not (eq old val)))
@@ -166,7 +166,7 @@
;; don't hide real conflicts.
(puthash key (gethash key override) table)
(display-warning 'smie (format "Conflict: %s %s/%s %s" x old val y))
- (incf smie-warning-count))
+ (cl-incf smie-warning-count))
(puthash key val table))))
(put 'smie-precs->prec2 'pure t)
@@ -268,8 +268,8 @@ be either:
(unless (consp rhs)
(signal 'wrong-type-argument `(consp ,rhs)))
(if (not (member (car rhs) nts))
- (pushnew (car rhs) first-ops)
- (pushnew (car rhs) first-nts)
+ (cl-pushnew (car rhs) first-ops)
+ (cl-pushnew (car rhs) first-nts)
(when (consp (cdr rhs))
;; If the first is not an OP we add the second (which
;; should be an OP if BNF is an "operator grammar").
@@ -282,16 +282,16 @@ be either:
(when (member (cadr rhs) nts)
(error "Adjacent non-terminals: %s %s"
(car rhs) (cadr rhs)))
- (pushnew (cadr rhs) first-ops)))
+ (cl-pushnew (cadr rhs) first-ops)))
(let ((shr (reverse rhs)))
(if (not (member (car shr) nts))
- (pushnew (car shr) last-ops)
- (pushnew (car shr) last-nts)
+ (cl-pushnew (car shr) last-ops)
+ (cl-pushnew (car shr) last-nts)
(when (consp (cdr shr))
(when (member (cadr shr) nts)
(error "Adjacent non-terminals: %s %s"
(cadr shr) (car shr)))
- (pushnew (cadr shr) last-ops)))))
+ (cl-pushnew (cadr shr) last-ops)))))
(push (cons nt first-ops) first-ops-table)
(push (cons nt last-ops) last-ops-table)
(push (cons nt first-nts) first-nts-table)
@@ -307,7 +307,7 @@ be either:
(dolist (op (cdr (assoc first-nt first-ops-table)))
(unless (member op first-ops)
(setq again t)
- (push op (cdr first-ops))))))))
+ (cl-push op (cdr first-ops))))))))
;; Same thing for last-ops.
(setq again t)
(while (prog1 again (setq again nil))
@@ -318,7 +318,7 @@ be either:
(dolist (op (cdr (assoc last-nt last-ops-table)))
(unless (member op last-ops)
(setq again t)
- (push op (cdr last-ops))))))))
+ (cl-push op (cdr last-ops))))))))
;; Now generate the 2D precedence table.
(dolist (rules bnf)
(dolist (rhs (cdr rules))
@@ -416,12 +416,12 @@ from the table, e.g. the table will not include things like (\"if\" . \"else\").
(if no-inners
(let ((last (car (last rhs))))
(unless (member last nts)
- (pushnew (cons (car rhs) last) alist :test #'equal)))
+ (cl-pushnew (cons (car rhs) last) alist :test #'equal)))
;; Reverse so that the "real" closer gets there first,
;; which is important for smie-close-block.
(dolist (term (reverse (cdr rhs)))
(unless (member term nts)
- (pushnew (cons (car rhs) term) alist :test #'equal)))))))
+ (cl-pushnew (cons (car rhs) term) alist :test #'equal)))))))
(nreverse alist)))
(defun smie-bnf--set-class (table token class)
@@ -483,7 +483,7 @@ CSTS is a list of pairs representing arcs in a graph."
(push (concat "." (car elem)) res))
(if (eq (cddr elem) val)
(push (concat (car elem) ".") res)))
- (assert res)
+ (cl-assert res)
res))
cycle)))
(mapconcat
@@ -498,9 +498,9 @@ CSTS is a list of pairs representing arcs in a graph."
;; (right (nth 1 (assoc (cdr k) grammar))))
;; (when (and left right)
;; (cond
-;; ((< left right) (assert (eq v '<)))
-;; ((> left right) (assert (eq v '>)))
-;; (t (assert (eq v '=))))))))
+;; ((< left right) (cl-assert (eq v '<)))
+;; ((> left right) (cl-assert (eq v '>)))
+;; (t (cl-assert (eq v '=))))))))
;; prec2))
(put 'smie-prec2->grammar 'pure t)
@@ -514,25 +514,28 @@ PREC2 is a table as returned by `smie-precs->prec2' or
;; final `table'. The value of each "variable" is kept in the `car'.
(let ((table ())
(csts ())
- (eqs ())
- tmp x y)
+ (eqs ()))
;; From `prec2' we construct a list of constraints between
;; variables (aka "precedence levels"). These can be either
;; equality constraints (in `eqs') or `<' constraints (in `csts').
(maphash (lambda (k v)
(when (consp k)
- (if (setq tmp (assoc (car k) table))
- (setq x (cddr tmp))
- (setq x (cons nil nil))
- (push (cons (car k) (cons nil x)) table))
- (if (setq tmp (assoc (cdr k) table))
- (setq y (cdr tmp))
- (setq y (cons nil (cons nil nil)))
- (push (cons (cdr k) y) table))
- (ecase v
- (= (push (cons x y) eqs))
- (< (push (cons x y) csts))
- (> (push (cons y x) csts)))))
+ (let ((tmp (assoc (car k) table))
+ x y)
+ (if tmp
+ (setq x (cddr tmp))
+ (setq x (cons nil nil))
+ (push (cons (car k) (cons nil x)) table))
+ (if (setq tmp (assoc (cdr k) table))
+ (setq y (cdr tmp))
+ (setq y (cons nil (cons nil nil)))
+ (push (cons (cdr k) y) table))
+ (pcase v
+ (`= (push (cons x y) eqs))
+ (`< (push (cons x y) csts))
+ (`> (push (cons y x) csts))
+ (_ (error "SMIE error: prec2 has %S↦%S which ∉ {<,+,>}"
+ k v))))))
prec2)
;; First process the equality constraints.
(let ((eqs eqs))
@@ -572,13 +575,13 @@ PREC2 is a table as returned by `smie-precs->prec2' or
(unless (caar cst)
(setcar (car cst) i)
;; (smie-check-grammar table prec2 'step1)
- (incf i))
+ (cl-incf i))
(setq csts (delq cst csts))))
(unless progress
(error "Can't resolve the precedence cycle: %s"
(smie-debug--describe-cycle
table (smie-debug--prec2-cycle csts)))))
- (incf i 10))
+ (cl-incf i 10))
;; Propagate equality constraints back to their sources.
(dolist (eq (nreverse eqs))
(when (null (cadr eq))
@@ -589,8 +592,8 @@ PREC2 is a table as returned by `smie-precs->prec2' or
;; So set it here rather than below since doing it below
;; makes it more difficult to obey the equality constraints.
(setcar (cdr eq) i)
- (incf i))
- (assert (or (null (caar eq)) (eq (caar eq) (cadr eq))))
+ (cl-incf i))
+ (cl-assert (or (null (caar eq)) (eq (caar eq) (cadr eq))))
(setcar (car eq) (cadr eq))
;; (smie-check-grammar table prec2 'step2)
)
@@ -598,19 +601,19 @@ PREC2 is a table as returned by `smie-precs->prec2' or
;; left side of any < constraint).
(dolist (x table)
(unless (nth 1 x)
- (setf (nth 1 x) i)
- (incf i)) ;See other (incf i) above.
+ (cl-setf (nth 1 x) i)
+ (cl-incf i)) ;See other (cl-incf i) above.
(unless (nth 2 x)
- (setf (nth 2 x) i)
- (incf i)))) ;See other (incf i) above.
+ (cl-setf (nth 2 x) i)
+ (cl-incf i)))) ;See other (cl-incf i) above.
;; Mark closers and openers.
(dolist (x (gethash :smie-open/close-alist prec2))
(let* ((token (car x))
- (cons (case (cdr x)
- (closer (cddr (assoc token table)))
- (opener (cdr (assoc token table))))))
- (assert (numberp (car cons)))
- (setf (car cons) (list (car cons)))))
+ (cons (pcase (cdr x)
+ (`closer (cddr (assoc token table)))
+ (`opener (cdr (assoc token table))))))
+ (cl-assert (numberp (car cons)))
+ (cl-setf (car cons) (list (car cons)))))
(let ((ca (gethash :smie-closer-alist prec2)))
(when ca (push (cons :smie-closer-alist ca) table)))
;; (smie-check-grammar table prec2 'step3)
@@ -706,19 +709,19 @@ Possible return values:
(condition-case err
(progn (goto-char pos) (funcall next-sexp 1) nil)
(scan-error (throw 'return
- (list t (caddr err)
+ (list t (cl-caddr err)
(buffer-substring-no-properties
- (caddr err)
- (+ (caddr err)
- (if (< (point) (caddr err))
+ (cl-caddr err)
+ (+ (cl-caddr err)
+ (if (< (point) (cl-caddr err))
-1 1)))))))
(if (eq pos (point))
;; We did not move, so let's abort the loop.
(throw 'return (list t (point))))))
((not (numberp (funcall op-back toklevels)))
;; A token like a paren-close.
- (assert (numberp ; Otherwise, why mention it in smie-grammar.
- (funcall op-forw toklevels)))
+ (cl-assert (numberp ; Otherwise, why mention it in smie-grammar.
+ (funcall op-forw toklevels)))
(push toklevels levels))
(t
(while (and levels (< (funcall op-back toklevels)
@@ -1672,12 +1675,12 @@ KEYWORDS are additional arguments, which can use the following keywords:
(while keywords
(let ((k (pop keywords))
(v (pop keywords)))
- (case k
- (:forward-token
+ (pcase k
+ (`:forward-token
(set (make-local-variable 'smie-forward-token-function) v))
- (:backward-token
+ (`:backward-token
(set (make-local-variable 'smie-backward-token-function) v))
- (t (message "smie-setup: ignoring unknown keyword %s" k)))))
+ (_ (message "smie-setup: ignoring unknown keyword %s" k)))))
(let ((ca (cdr (assq :smie-closer-alist grammar))))
(when ca
(set (make-local-variable 'smie-closer-alist) ca)
diff --git a/lisp/emacs-lisp/syntax.el b/lisp/emacs-lisp/syntax.el
index 583d0b151c9..51bfc05ff5f 100644
--- a/lisp/emacs-lisp/syntax.el
+++ b/lisp/emacs-lisp/syntax.el
@@ -41,7 +41,7 @@
;; Note: PPSS stands for `parse-partial-sexp state'
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
(defvar font-lock-beginning-of-syntax-function)
@@ -181,7 +181,7 @@ Note: back-references in REGEXPs do not work."
;; If there's more than 1 rule, and the rule want to apply
;; highlight to match 0, create an extra group to be able to
;; tell when *this* match 0 has succeeded.
- (incf offset)
+ (cl-incf offset)
(setq re (concat "\\(" re "\\)")))
(setq re (syntax-propertize--shift-groups re offset))
(let ((code '())
@@ -215,7 +215,7 @@ Note: back-references in REGEXPs do not work."
(setq offset 0)))
;; Now construct the code for each subgroup rules.
(dolist (case (cdr rule))
- (assert (null (cddr case)))
+ (cl-assert (null (cddr case)))
(let* ((gn (+ offset (car case)))
(action (nth 1 case))
(thiscode
@@ -260,7 +260,7 @@ Note: back-references in REGEXPs do not work."
code))))
(push (cons condition (nreverse code))
branches))
- (incf offset (regexp-opt-depth orig-re))
+ (cl-incf offset (regexp-opt-depth orig-re))
re))
rules
"\\|")))
@@ -418,8 +418,8 @@ Point is at POS when this function returns."
(* 2 (/ (cdr (aref syntax-ppss-stats 5))
(1+ (car (aref syntax-ppss-stats 5)))))))
(progn
- (incf (car (aref syntax-ppss-stats 0)))
- (incf (cdr (aref syntax-ppss-stats 0)) (- pos old-pos))
+ (cl-incf (car (aref syntax-ppss-stats 0)))
+ (cl-incf (cdr (aref syntax-ppss-stats 0)) (- pos old-pos))
(parse-partial-sexp old-pos pos nil nil old-ppss))
(cond
@@ -435,8 +435,8 @@ Point is at POS when this function returns."
(setq pt-min (or (syntax-ppss-toplevel-pos old-ppss)
(nth 2 old-ppss)))
(<= pt-min pos) (< (- pos pt-min) syntax-ppss-max-span))
- (incf (car (aref syntax-ppss-stats 1)))
- (incf (cdr (aref syntax-ppss-stats 1)) (- pos pt-min))
+ (cl-incf (car (aref syntax-ppss-stats 1)))
+ (cl-incf (cdr (aref syntax-ppss-stats 1)) (- pos pt-min))
(setq ppss (parse-partial-sexp pt-min pos)))
;; The OLD-* data can't be used. Consult the cache.
(t
@@ -464,8 +464,8 @@ Point is at POS when this function returns."
;; Use the best of OLD-POS and CACHE.
(if (or (not old-pos) (< old-pos pt-min))
(setq pt-best pt-min ppss-best ppss)
- (incf (car (aref syntax-ppss-stats 4)))
- (incf (cdr (aref syntax-ppss-stats 4)) (- pos old-pos))
+ (cl-incf (car (aref syntax-ppss-stats 4)))
+ (cl-incf (cdr (aref syntax-ppss-stats 4)) (- pos old-pos))
(setq pt-best old-pos ppss-best old-ppss))
;; Use the `syntax-begin-function' if available.
@@ -490,21 +490,21 @@ Point is at POS when this function returns."
(not (memq (get-text-property (point) 'face)
'(font-lock-string-face font-lock-doc-face
font-lock-comment-face))))
- (incf (car (aref syntax-ppss-stats 5)))
- (incf (cdr (aref syntax-ppss-stats 5)) (- pos (point)))
+ (cl-incf (car (aref syntax-ppss-stats 5)))
+ (cl-incf (cdr (aref syntax-ppss-stats 5)) (- pos (point)))
(setq pt-best (point) ppss-best nil))
(cond
;; Quick case when we found a nearby pos.
((< (- pos pt-best) syntax-ppss-max-span)
- (incf (car (aref syntax-ppss-stats 2)))
- (incf (cdr (aref syntax-ppss-stats 2)) (- pos pt-best))
+ (cl-incf (car (aref syntax-ppss-stats 2)))
+ (cl-incf (cdr (aref syntax-ppss-stats 2)) (- pos pt-best))
(setq ppss (parse-partial-sexp pt-best pos nil nil ppss-best)))
;; Slow case: compute the state from some known position and
;; populate the cache so we won't need to do it again soon.
(t
- (incf (car (aref syntax-ppss-stats 3)))
- (incf (cdr (aref syntax-ppss-stats 3)) (- pos pt-min))
+ (cl-incf (car (aref syntax-ppss-stats 3)))
+ (cl-incf (cdr (aref syntax-ppss-stats 3)) (- pos pt-min))
;; If `pt-min' is too far, add a few intermediate entries.
(while (> (- pos pt-min) (* 2 syntax-ppss-max-span))
@@ -513,7 +513,7 @@ Point is at POS when this function returns."
nil nil ppss))
(let ((pair (cons pt-min ppss)))
(if cache-pred
- (push pair (cdr cache-pred))
+ (cl-push pair (cdr cache-pred))
(push pair syntax-ppss-cache))))
;; Compute the actual return value.
@@ -533,7 +533,7 @@ Point is at POS when this function returns."
(let ((pair (cons pos ppss)))
(if cache-pred
(if (> (- (caar cache-pred) pos) syntax-ppss-max-span)
- (push pair (cdr cache-pred))
+ (cl-push pair (cdr cache-pred))
(setcar cache-pred pair))
(if (or (null syntax-ppss-cache)
(> (- (caar syntax-ppss-cache) pos)
diff --git a/lisp/emacs-lisp/timer.el b/lisp/emacs-lisp/timer.el
index 11ec0f0614c..1c30563c6a3 100644
--- a/lisp/emacs-lisp/timer.el
+++ b/lisp/emacs-lisp/timer.el
@@ -33,9 +33,9 @@
;; triggered-p is nil if the timer is active (waiting to be triggered),
;; t if it is inactive ("already triggered", in theory)
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
-(defstruct (timer
+(cl-defstruct (timer
(:constructor nil)
(:copier nil)
(:constructor timer-create ())
@@ -54,15 +54,15 @@
(timer--low-seconds timer)
(timer--usecs timer)))
-(defsetf timer--time
+(cl-defsetf timer--time
(lambda (timer time)
(or (timerp timer) (error "Invalid timer"))
- (setf (timer--high-seconds timer) (pop time))
- (setf (timer--low-seconds timer)
- (if (consp time) (car time) time))
- (setf (timer--usecs timer) (or (and (consp time) (consp (cdr time))
- (cadr time))
- 0))))
+ (cl-setf (timer--high-seconds timer) (pop time))
+ (cl-setf (timer--low-seconds timer)
+ (if (consp time) (car time) time))
+ (cl-setf (timer--usecs timer) (or (and (consp time) (consp (cdr time))
+ (cadr time))
+ 0))))
(defun timer-set-time (timer time &optional delta)
@@ -70,8 +70,8 @@
TIME must be in the internal format returned by, e.g., `current-time'.
If optional third argument DELTA is a positive number, make the timer
fire repeatedly that many seconds apart."
- (setf (timer--time timer) time)
- (setf (timer--repeat-delay timer) (and (numberp delta) (> delta 0) delta))
+ (cl-setf (timer--time timer) time)
+ (cl-setf (timer--repeat-delay timer) (and (numberp delta) (> delta 0) delta))
timer)
(defun timer-set-idle-time (timer secs &optional repeat)
@@ -81,10 +81,10 @@ time format (HIGH LOW USECS) returned by, e.g., `current-idle-time'.
If optional third argument REPEAT is non-nil, make the timer
fire each time Emacs is idle for that many seconds."
(if (consp secs)
- (setf (timer--time timer) secs)
- (setf (timer--time timer) '(0 0 0))
+ (cl-setf (timer--time timer) secs)
+ (cl-setf (timer--time timer) '(0 0 0))
(timer-inc-time timer secs))
- (setf (timer--repeat-delay timer) repeat)
+ (cl-setf (timer--repeat-delay timer) repeat)
timer)
(defun timer-next-integral-multiple-of-time (time secs)
@@ -124,8 +124,8 @@ SECS may be either an integer or a floating point number."
(defun timer-inc-time (timer secs &optional usecs)
"Increment the time set in TIMER by SECS seconds and USECS microseconds.
SECS may be a fraction. If USECS is omitted, that means it is zero."
- (setf (timer--time timer)
- (timer-relative-time (timer--time timer) secs usecs)))
+ (cl-setf (timer--time timer)
+ (timer-relative-time (timer--time timer) secs usecs)))
(defun timer-set-time-with-usecs (timer time usecs &optional delta)
"Set the trigger time of TIMER to TIME plus USECS.
@@ -133,9 +133,9 @@ TIME must be in the internal format returned by, e.g., `current-time'.
The microsecond count from TIME is ignored, and USECS is used instead.
If optional fourth argument DELTA is a positive number, make the timer
fire repeatedly that many seconds apart."
- (setf (timer--time timer) time)
- (setf (timer--usecs timer) usecs)
- (setf (timer--repeat-delay timer) (and (numberp delta) (> delta 0) delta))
+ (cl-setf (timer--time timer) time)
+ (cl-setf (timer--usecs timer) usecs)
+ (cl-setf (timer--repeat-delay timer) (and (numberp delta) (> delta 0) delta))
timer)
(make-obsolete 'timer-set-time-with-usecs
"use `timer-set-time' and `timer-inc-time' instead."
@@ -145,8 +145,8 @@ fire repeatedly that many seconds apart."
"Make TIMER call FUNCTION with optional ARGS when triggering."
(or (timerp timer)
(error "Invalid timer"))
- (setf (timer--function timer) function)
- (setf (timer--args timer) args)
+ (cl-setf (timer--function timer) function)
+ (cl-setf (timer--args timer) args)
timer)
(defun timer--activate (timer &optional triggered-p reuse-cell idle)
@@ -170,8 +170,8 @@ fire repeatedly that many seconds apart."
(cond (last (setcdr last reuse-cell))
(idle (setq timer-idle-list reuse-cell))
(t (setq timer-list reuse-cell)))
- (setf (timer--triggered timer) triggered-p)
- (setf (timer--idle-delay timer) idle)
+ (cl-setf (timer--triggered timer) triggered-p)
+ (cl-setf (timer--idle-delay timer) idle)
nil)
(error "Invalid or uninitialized timer")))
@@ -294,7 +294,7 @@ This function is called, by name, directly by the C code."
(apply (timer--function timer) (timer--args timer)))
(error nil))
(if retrigger
- (setf (timer--triggered timer) nil)))
+ (cl-setf (timer--triggered timer) nil)))
(error "Bogus timer event"))))
;; This function is incompatible with the one in levents.el.