1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 18:40:39 -08:00

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.
This commit is contained in:
Stefan Monnier 2012-06-10 09:28:26 -04:00
parent 31ca4639ad
commit f80efb8695
13 changed files with 245 additions and 262 deletions

View file

@ -1,3 +1,12 @@
2012-06-10 Stefan Monnier <monnier@iro.umontreal.ca>
* emacs-lisp/timer.el, emacs-lisp/syntax.el, emacs-lisp/smie.el:
* emacs-lisp/ewoc.el, emacs-lisp/cconv.el, emacs-lisp/bytecomp.el:
* emacs-lisp/byte-opt.el, emacs-lisp/autoload.el: Convert to cl-lib.
* emacs-lisp/easymenu.el, emacs-lisp/easy-mmode.el:
* emacs-lisp/derived.el: Use pcase instead of `cl'.
* emacs-lisp/cl-lib.el: Get rid of special cl-macs auto load.
2012-06-10 Glenn Morris <rgm@gnu.org> 2012-06-10 Glenn Morris <rgm@gnu.org>
* mail/rmail.el (rmail-yank-current-message): Leave point at * mail/rmail.el (rmail-yank-current-message): Leave point at
@ -9,8 +18,8 @@
2012-06-10 Chong Yidong <cyd@gnu.org> 2012-06-10 Chong Yidong <cyd@gnu.org>
* cus-edit.el (customize-changed-options-previous-release): Bump * cus-edit.el (customize-changed-options-previous-release):
to 24.1. Bump to 24.1.
2012-06-09 Andreas Schwab <schwab@linux-m68k.org> 2012-06-09 Andreas Schwab <schwab@linux-m68k.org>
@ -142,8 +151,8 @@
* textmodes/flyspell.el (flyspell-incorrect, flyspell-duplicate): * textmodes/flyspell.el (flyspell-incorrect, flyspell-duplicate):
Likewise. Likewise.
(flyspell-incorrect-face, flyspell-duplicate-face): Remove (flyspell-incorrect-face, flyspell-duplicate-face):
obsolete aliases. Remove obsolete aliases.
2012-06-08 Michael Albinus <michael.albinus@gmx.de> 2012-06-08 Michael Albinus <michael.albinus@gmx.de>

View file

@ -32,7 +32,7 @@
(require 'lisp-mode) ;for `doc-string-elt' properties. (require 'lisp-mode) ;for `doc-string-elt' properties.
(require 'help-fns) ;for help-add-fundoc-usage. (require 'help-fns) ;for help-add-fundoc-usage.
(eval-when-compile (require 'cl)) (eval-when-compile (require 'cl-lib))
(defvar generated-autoload-file nil (defvar generated-autoload-file nil
"File into which to write autoload definitions. "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)) defun* defmacro* define-overloadable-function))
(let* ((macrop (memq car '(defmacro defmacro*))) (let* ((macrop (memq car '(defmacro defmacro*)))
(name (nth 1 form)) (name (nth 1 form))
(args (case car (args (cl-case car
((defun defmacro defun* defmacro* ((defun defmacro defun* defmacro*
define-overloadable-function) (nth 2 form)) define-overloadable-function) (nth 2 form))
((define-skeleton) '(&optional str arg)) ((define-skeleton) '(&optional str arg))
@ -546,7 +546,7 @@ Return non-nil if and only if FILE adds no autoloads to OUTFILE
(save-excursion (save-excursion
;; Insert the section-header line which lists the file name ;; Insert the section-header line which lists the file name
;; and which functions are in it, etc. ;; and which functions are in it, etc.
(assert (= ostart output-start)) (cl-assert (= ostart output-start))
(goto-char output-start) (goto-char output-start)
(let ((relfile (file-relative-name absfile))) (let ((relfile (file-relative-name absfile)))
(autoload-insert-section-header (autoload-insert-section-header

View file

@ -183,7 +183,7 @@
;;; Code: ;;; Code:
(require 'bytecomp) (require 'bytecomp)
(eval-when-compile (require 'cl)) (eval-when-compile (require 'cl-lib))
(require 'macroexp) (require 'macroexp)
(defun byte-compile-log-lap-1 (format &rest args) (defun byte-compile-log-lap-1 (format &rest args)
@ -642,7 +642,7 @@
(while (eq (car-safe form) 'progn) (while (eq (car-safe form) 'progn)
(setq form (car (last (cdr form))))) (setq form (car (last (cdr form)))))
(cond ((consp form) (cond ((consp form)
(case (car form) (cl-case (car form)
(quote (cadr form)) (quote (cadr form))
;; Can't use recursion in a defsubst. ;; Can't use recursion in a defsubst.
;; (progn (byte-compile-trueconstp (car (last (cdr form))))) ;; (progn (byte-compile-trueconstp (car (last (cdr form)))))
@ -656,7 +656,7 @@
(while (eq (car-safe form) 'progn) (while (eq (car-safe form) 'progn)
(setq form (car (last (cdr form))))) (setq form (car (last (cdr form)))))
(cond ((consp form) (cond ((consp form)
(case (car form) (cl-case (car form)
(quote (null (cadr form))) (quote (null (cadr form)))
;; Can't use recursion in a defsubst. ;; Can't use recursion in a defsubst.
;; (progn (byte-compile-nilconstp (car (last (cdr form))))) ;; (progn (byte-compile-nilconstp (car (last (cdr form)))))
@ -1376,7 +1376,7 @@
;; This uses dynamic-scope magic. ;; This uses dynamic-scope magic.
offset (disassemble-offset bytes)) offset (disassemble-offset bytes))
(let ((opcode (aref byte-code-vector bytedecomp-op))) (let ((opcode (aref byte-code-vector bytedecomp-op)))
(assert opcode) (cl-assert opcode)
(setq bytedecomp-op opcode)) (setq bytedecomp-op opcode))
(cond ((memq bytedecomp-op byte-goto-ops) (cond ((memq bytedecomp-op byte-goto-ops)
;; It's a pc. ;; 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) (byte-compile-log-lap " dup %s discard\t-->\t%s" lap1 lap1)
(setq keep-going t (setq keep-going t
rest (cdr rest)) 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)))) (setq lap (delq lap0 (delq lap2 lap))))
;; ;;
;; not goto-X-if-nil --> goto-X-if-non-nil ;; not goto-X-if-nil --> goto-X-if-non-nil

View file

@ -120,7 +120,7 @@
(require 'backquote) (require 'backquote)
(require 'macroexp) (require 'macroexp)
(require 'cconv) (require 'cconv)
(eval-when-compile (require 'cl)) (eval-when-compile (require 'cl-lib))
(or (fboundp 'defsubst) (or (fboundp 'defsubst)
;; This really ought to be loaded already! ;; 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))) (bytes-var (car (last args 2)))
(pc-var (car (last args)))) (pc-var (car (last args))))
`(setq ,bytes-var ,(if (null (cdr byte-exprs)) `(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)) (cons ,@byte-exprs ,bytes-var))
`(nconc (list ,@(reverse byte-exprs)) ,bytes-var)) `(nconc (list ,@(reverse byte-exprs)) ,bytes-var))
,pc-var (+ ,(length byte-exprs) ,pc-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 (auto-save-file-name-p source))
(not (string-equal dir-locals-file (not (string-equal dir-locals-file
(file-name-nondirectory source)))) (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))) (no-byte-compile (setq skip-count (1+ skip-count)))
((t) (setq file-count (1+ file-count))) ((t) (setq file-count (1+ file-count)))
((nil) (setq fail-count (1+ fail-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)) (set-buffer-multibyte nil))
;; Run hooks including the uncompression hook. ;; Run hooks including the uncompression hook.
;; If they change the file name, then change it for the output also. ;; If they change the file name, then change it for the output also.
(letf ((buffer-file-name filename) (cl-letf ((buffer-file-name filename)
((default-value 'major-mode) 'emacs-lisp-mode) ((default-value 'major-mode) 'emacs-lisp-mode)
;; Ignore unsafe local variables. ;; Ignore unsafe local variables.
;; We only care about a few of them for our purposes. ;; We only care about a few of them for our purposes.
(enable-local-variables :safe) (enable-local-variables :safe)
(enable-local-eval nil)) (enable-local-eval nil))
;; Arg of t means don't alter enable-local-variables. ;; Arg of t means don't alter enable-local-variables.
(normal-mode t) (normal-mode t)
;; There may be a file local variable setting (bug#10419). ;; 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)) (byte-compile-make-lambda-lexenv fun))
reserved-csts))) reserved-csts)))
;; Build the actual byte-coded function. ;; 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 (apply #'make-byte-code
(if lexical-binding (if lexical-binding
(byte-compile-make-args-desc arglist) (byte-compile-make-args-desc arglist)
@ -2654,7 +2654,7 @@ for symbols generated by the byte compiler itself."
(while (and rest (< i limit)) (while (and rest (< i limit))
(cond (cond
((numberp (car rest)) ((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)) ((setq tmp (assq (car (car rest)) ret))
(setcdr (car rest) (cdr tmp))) (setcdr (car rest) (cdr tmp)))
(t (t
@ -2933,9 +2933,9 @@ That command is designed for interactive use only" fn))
(mapc 'byte-compile-form (cdr form)) (mapc 'byte-compile-form (cdr form))
(unless fmax2 (unless fmax2
;; Old-style byte-code. ;; Old-style byte-code.
(assert (listp fargs)) (cl-assert (listp fargs))
(while fargs (while fargs
(case (car fargs) (cl-case (car fargs)
(&optional (setq fargs (cdr fargs))) (&optional (setq fargs (cdr fargs)))
(&rest (setq fmax2 (+ (* 2 (length dynbinds)) 1)) (&rest (setq fmax2 (+ (* 2 (length dynbinds)) 1))
(push (cadr fargs) dynbinds) (push (cadr fargs) dynbinds)
@ -2954,7 +2954,7 @@ That command is designed for interactive use only" fn))
(t (t
;; Turn &rest args into a list. ;; Turn &rest args into a list.
(let ((n (- alen (/ (1- fmax2) 2)))) (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) (if (< n 5)
(byte-compile-out (byte-compile-out
(aref [byte-list1 byte-list2 byte-list3 byte-list4] (1- n)) (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. ;; Unbind dynamic variables.
(when dynbinds (when dynbinds
(byte-compile-out 'byte-unbind (length 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))) nil "Wrong depth start=%s end=%s" start-depth byte-compile-depth)))
(defun byte-compile-check-variable (var access-type) (defun byte-compile-check-variable (var access-type)
@ -2985,7 +2985,7 @@ That command is designed for interactive use only" fn))
(and od (and od
(not (memq var byte-compile-not-obsolete-vars)) (not (memq var byte-compile-not-obsolete-vars))
(not (memq var byte-compile-global-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))) (set (not (eq access-type 'reference)))
(get (eq access-type 'reference)) (get (eq access-type 'reference))
(t t))))) (t t)))))
@ -3312,8 +3312,8 @@ discarding."
(body (nthcdr 3 form)) (body (nthcdr 3 form))
(fun (fun
(byte-compile-lambda `(lambda ,vars . ,body) nil (length env)))) (byte-compile-lambda `(lambda ,vars . ,body) nil (length env))))
(assert (> (length env) 0)) ;Otherwise, we don't need a closure. (cl-assert (> (length env) 0)) ;Otherwise, we don't need a closure.
(assert (byte-code-function-p fun)) (cl-assert (byte-code-function-p fun))
(byte-compile-form `(make-byte-code (byte-compile-form `(make-byte-code
',(aref fun 0) ',(aref fun 1) ',(aref fun 0) ',(aref fun 1)
(vconcat (vector . ,env) ',(aref fun 2)) (vconcat (vector . ,env) ',(aref fun 2))
@ -3891,8 +3891,8 @@ binding slots have been popped."
(if lexical-binding (if lexical-binding
;; Unbind both lexical and dynamic variables. ;; Unbind both lexical and dynamic variables.
(progn (progn
(assert (or (eq byte-compile-depth init-stack-depth) (cl-assert (or (eq byte-compile-depth init-stack-depth)
(eq byte-compile-depth (1+ init-stack-depth)))) (eq byte-compile-depth (1+ init-stack-depth))))
(byte-compile-unbind clauses init-lexenv (> byte-compile-depth (byte-compile-unbind clauses init-lexenv (> byte-compile-depth
init-stack-depth))) init-stack-depth)))
;; Unbind dynamic variables. ;; Unbind dynamic variables.
@ -4312,7 +4312,7 @@ invoked interactively."
(if byte-compile-call-tree-sort (if byte-compile-call-tree-sort
(setq byte-compile-call-tree (setq byte-compile-call-tree
(sort byte-compile-call-tree (sort byte-compile-call-tree
(case byte-compile-call-tree-sort (cl-case byte-compile-call-tree-sort
(callers (callers
(lambda (x y) (< (length (nth 1 x)) (lambda (x y) (< (length (nth 1 x))
(length (nth 1 y))))) (length (nth 1 y)))))

View file

@ -110,7 +110,7 @@
;; ,@(mapcar (lambda (binder) (if (consp binder) (cadr binder))) ;; ,@(mapcar (lambda (binder) (if (consp binder) (cadr binder)))
;; binders))) ;; binders)))
(eval-when-compile (require 'cl)) (eval-when-compile (require 'cl-lib))
(defconst cconv-liftwhen 6 (defconst cconv-liftwhen 6
"Try to do lambda lifting if the number of arguments + free variables "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. ;; Here we assume that X appears at most once in M.
(let* ((b (assq x m)) (let* ((b (assq x m))
(res (if b (remq b m) 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)) res))
(defun cconv--map-diff-set (m s) (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))) (nreverse res)))
(defun cconv--convert-function (args body env parentform) (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))) (let* ((fvs (cdr (pop cconv-freevars-alist)))
(body-new '()) (body-new '())
(letbind '()) (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 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 where they are shadowed, because some part of ENV causes them to be used at
places where they originally did not directly appear." places where they originally did not directly appear."
(assert (not (delq nil (mapcar (lambda (mapping) (cl-assert (not (delq nil (mapcar (lambda (mapping)
(if (eq (cadr mapping) 'apply-partially) (if (eq (cadr mapping) 'apply-partially)
(cconv--set-diff (cdr (cddr mapping)) (cconv--set-diff (cdr (cddr mapping))
extend))) extend)))
env)))) env))))
;; What's the difference between fvrs and envs? ;; What's the difference between fvrs and envs?
;; Suppose that we have the code ;; 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. ;; Check if var is a candidate for lambda lifting.
((and (member (cons binder form) cconv-lambda-candidates) ((and (member (cons binder form) cconv-lambda-candidates)
(progn (progn
(assert (and (eq (car value) 'function) (cl-assert (and (eq (car value) 'function)
(eq (car (cadr value)) 'lambda))) (eq (car (cadr value)) 'lambda)))
(assert (equal (cddr (cadr value)) (cl-assert (equal (cddr (cadr value))
(caar cconv-freevars-alist))) (caar cconv-freevars-alist)))
;; Peek at the freevars to decide whether to λ-lift. ;; Peek at the freevars to decide whether to λ-lift.
(let* ((fvs (cdr (car cconv-freevars-alist))) (let* ((fvs (cdr (car cconv-freevars-alist)))
(fun (cadr value)) (fun (cadr value))
@ -307,7 +307,7 @@ places where they originally did not directly appear."
(funcbody-env ())) (funcbody-env ()))
(push `(,var . (apply-partially ,var . ,fvs)) new-env) (push `(,var . (apply-partially ,var . ,fvs)) new-env)
(dolist (fv fvs) (dolist (fv fvs)
(pushnew fv new-extend) (cl-pushnew fv new-extend)
(if (and (eq 'car (car-safe (cdr (assq fv env)))) (if (and (eq 'car (car-safe (cdr (assq fv env))))
(not (memq fv funargs))) (not (memq fv funargs)))
(push `(,fv . (car ,fv)) funcbody-env))) (push `(,fv . (car ,fv)) funcbody-env)))
@ -345,14 +345,14 @@ places where they originally did not directly appear."
(mapcar (lambda (mapping) (mapcar (lambda (mapping)
(if (not (eq (cadr mapping) 'apply-partially)) (if (not (eq (cadr mapping) 'apply-partially))
mapping mapping
(assert (eq (car mapping) (nth 2 mapping))) (cl-assert (eq (car mapping) (nth 2 mapping)))
(list* (car mapping) (cl-list* (car mapping)
'apply-partially 'apply-partially
(car mapping) (car mapping)
(mapcar (lambda (arg) (mapcar (lambda (arg)
(if (eq var arg) (if (eq var arg)
closedsym arg)) closedsym arg))
(nthcdr 3 mapping))))) (nthcdr 3 mapping)))))
new-env)) new-env))
(setq new-extend (remq var new-extend)) (setq new-extend (remq var new-extend))
(push closedsym new-extend) (push closedsym new-extend)
@ -455,7 +455,7 @@ places where they originally did not directly appear."
(let ((mapping (cdr (assq fun env)))) (let ((mapping (cdr (assq fun env))))
(pcase mapping (pcase mapping
(`(apply-partially ,_ . ,(and fvs `(,_ . ,_))) (`(apply-partially ,_ . ,(and fvs `(,_ . ,_)))
(assert (eq (cadr mapping) fun)) (cl-assert (eq (cadr mapping) fun))
`(,callsym ,fun `(,callsym ,fun
,@(mapcar (lambda (fv) ,@(mapcar (lambda (fv)
(let ((exp (or (cdr (assq fv env)) 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'; ;; Transfer uses collected in `envcopy' (via `newenv') back to `env';
;; and compute free variables. ;; and compute free variables.
(while env (while env
(assert (and envcopy (eq (caar env) (caar envcopy)))) (cl-assert (and envcopy (eq (caar env) (caar envcopy))))
(let ((free nil) (let ((free nil)
(x (cdr (car env))) (x (cdr (car env)))
(y (cdr (car envcopy)))) (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)) (when (car y) (setcar x t) (setq free t))
(setq x (cdr x) y (cdr y))) (setq x (cdr x) y (cdr y)))
(when free (when free
(push (caar env) (cdr freevars)) (cl-push (caar env) (cdr freevars))
(setf (nth 3 (car env)) t)) (cl-setf (nth 3 (car env)) t))
(setq env (cdr env) envcopy (cdr envcopy)))))) (setq env (cdr env) envcopy (cdr envcopy))))))
(defun cconv-analyse-form (form env) (defun cconv-analyse-form (form env)
@ -610,7 +610,7 @@ and updates the data stored in ENV."
;; it is a mutated variable. ;; it is a mutated variable.
(while forms (while forms
(let ((v (assq (car forms) env))) ; v = non nil if visible (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) (cconv-analyse-form (cadr forms) env)
(setq forms (cddr forms)))) (setq forms (cddr forms))))
@ -656,7 +656,7 @@ and updates the data stored in ENV."
;; lambda candidate list. ;; lambda candidate list.
(let ((fdata (and (symbolp fun) (assq fun env)))) (let ((fdata (and (symbolp fun) (assq fun env))))
(if fdata (if fdata
(setf (nth 4 fdata) t) (cl-setf (nth 4 fdata) t)
(cconv-analyse-form fun env))) (cconv-analyse-form fun env)))
(dolist (form args) (cconv-analyse-form form env))) (dolist (form args) (cconv-analyse-form form env)))
@ -676,7 +676,7 @@ and updates the data stored in ENV."
((pred symbolp) ((pred symbolp)
(let ((dv (assq form env))) ; dv = declared and visible (let ((dv (assq form env))) ; dv = declared and visible
(when dv (when dv
(setf (nth 1 dv) t)))))) (cl-setf (nth 1 dv) t))))))
(provide 'cconv) (provide 'cconv)
;;; cconv.el ends here ;;; cconv.el ends here

View file

@ -644,29 +644,6 @@ If ALIST is non-nil, the new pairs are prepended to it."
(load "cl-loaddefs" nil 'quiet) (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) (provide 'cl-lib)
(run-hooks 'cl-load-hook) (run-hooks 'cl-load-hook)

View file

@ -90,8 +90,6 @@
;;; Code: ;;; Code:
(eval-when-compile (require 'cl))
;;; PRIVATE: defsubst must be defined before they are first used ;;; PRIVATE: defsubst must be defined before they are first used
(defsubst derived-mode-hook-name (mode) (defsubst derived-mode-hook-name (mode)
@ -183,11 +181,11 @@ See Info node `(elisp)Derived Modes' for more details."
;; Process the keyword args. ;; Process the keyword args.
(while (keywordp (car body)) (while (keywordp (car body))
(case (pop body) (pcase (pop body)
(:group (setq group (pop body))) (`:group (setq group (pop body)))
(:abbrev-table (setq abbrev (pop body)) (setq declare-abbrev nil)) (`:abbrev-table (setq abbrev (pop body)) (setq declare-abbrev nil))
(:syntax-table (setq syntax (pop body)) (setq declare-syntax nil)) (`:syntax-table (setq syntax (pop body)) (setq declare-syntax nil))
(t (pop body)))) (_ (pop body))))
(setq docstring (derived-mode-make-docstring (setq docstring (derived-mode-make-docstring
parent child docstring syntax abbrev)) parent child docstring syntax abbrev))

View file

@ -51,8 +51,6 @@
;;; Code: ;;; Code:
(eval-when-compile (require 'cl))
(defun easy-mmode-pretty-mode-name (mode &optional lighter) (defun easy-mmode-pretty-mode-name (mode &optional lighter)
"Turn the symbol MODE into a string intended for the user. "Turn the symbol MODE into a string intended for the user.
If provided, LIGHTER will be used to help choose capitalization by, 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. ;; Allow skipping the first three args.
(cond (cond
((keywordp init-value) ((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)) init-value nil lighter nil keymap nil))
((keywordp lighter) ((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))) ((keywordp keymap) (push keymap body) (setq keymap nil)))
(let* ((last-message (make-symbol "last-message")) (let* ((last-message (make-symbol "last-message"))
@ -182,18 +180,18 @@ For example, you could write
;; Check keys. ;; Check keys.
(while (keywordp (setq keyw (car body))) (while (keywordp (setq keyw (car body)))
(setq body (cdr body)) (setq body (cdr body))
(case keyw (pcase keyw
(:init-value (setq init-value (pop body))) (`:init-value (setq init-value (pop body)))
(:lighter (setq lighter (purecopy (pop body)))) (`:lighter (setq lighter (purecopy (pop body))))
(:global (setq globalp (pop body))) (`:global (setq globalp (pop body)))
(:extra-args (setq extra-args (pop body))) (`:extra-args (setq extra-args (pop body)))
(:set (setq set (list :set (pop body)))) (`:set (setq set (list :set (pop body))))
(:initialize (setq initialize (list :initialize (pop body)))) (`:initialize (setq initialize (list :initialize (pop body))))
(:group (setq group (nconc group (list :group (pop body))))) (`:group (setq group (nconc group (list :group (pop body)))))
(:type (setq type (list :type (pop body)))) (`:type (setq type (list :type (pop body))))
(:require (setq require (pop body))) (`:require (setq require (pop body)))
(:keymap (setq keymap (pop body))) (`:keymap (setq keymap (pop body)))
(:variable (setq variable (pop body)) (`:variable (setq variable (pop body))
(if (not (and (setq tmp (cdr-safe variable)) (if (not (and (setq tmp (cdr-safe variable))
(or (symbolp tmp) (or (symbolp tmp)
(functionp tmp)))) (functionp tmp))))
@ -201,8 +199,8 @@ For example, you could write
(setq mode variable) (setq mode variable)
(setq mode (car variable)) (setq mode (car variable))
(setq setter (cdr variable)))) (setq setter (cdr variable))))
(:after-hook (setq after-hook (pop body))) (`:after-hook (setq after-hook (pop body)))
(t (push keyw extra-keywords) (push (pop body) extra-keywords)))) (_ (push keyw extra-keywords) (push (pop body) extra-keywords))))
(setq keymap-sym (if (and keymap (symbolp keymap)) keymap (setq keymap-sym (if (and keymap (symbolp keymap)) keymap
(intern (concat mode-name "-map")))) (intern (concat mode-name "-map"))))
@ -355,10 +353,10 @@ call another major mode in their body."
;; Check keys. ;; Check keys.
(while (keywordp (setq keyw (car keys))) (while (keywordp (setq keyw (car keys)))
(setq keys (cdr keys)) (setq keys (cdr keys))
(case keyw (pcase keyw
(:group (setq group (nconc group (list :group (pop keys))))) (`:group (setq group (nconc group (list :group (pop keys)))))
(:global (setq keys (cdr keys))) (`:global (setq keys (cdr keys)))
(t (push keyw extra-keywords) (push (pop keys) extra-keywords)))) (_ (push keyw extra-keywords) (push (pop keys) extra-keywords))))
(unless group (unless group
;; We might as well provide a best-guess default group. ;; We might as well provide a best-guess default group.
@ -479,13 +477,13 @@ Valid keywords and arguments are:
(while args (while args
(let ((key (pop args)) (let ((key (pop args))
(val (pop args))) (val (pop args)))
(case key (pcase key
(:name (setq name val)) (`:name (setq name val))
(:dense (setq dense val)) (`:dense (setq dense val))
(:inherit (setq inherit val)) (`:inherit (setq inherit val))
(:suppress (setq suppress val)) (`:suppress (setq suppress val))
(:group) (`:group)
(t (message "Unknown argument %s in defmap" key))))) (_ (message "Unknown argument %s in defmap" key)))))
(unless (keymapp m) (unless (keymapp m)
(setq bs (append m bs)) (setq bs (append m bs))
(setq m (if dense (make-keymap name) (make-sparse-keymap name)))) (setq m (if dense (make-keymap name) (make-sparse-keymap name))))

View file

@ -29,8 +29,6 @@
;;; Code: ;;; Code:
(eval-when-compile (require 'cl))
(defvar easy-menu-precalculate-equivalent-keybindings nil (defvar easy-menu-precalculate-equivalent-keybindings nil
"Determine when equivalent key bindings are computed for easy-menu menus. "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 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)))) (keywordp (setq keyword (car menu-items))))
(setq arg (cadr menu-items)) (setq arg (cadr menu-items))
(setq menu-items (cddr menu-items)) (setq menu-items (cddr menu-items))
(case keyword (pcase keyword
(:filter (`:filter
(setq filter `(lambda (menu) (setq filter `(lambda (menu)
(easy-menu-filter-return (,arg menu) ,menu-name)))) (easy-menu-filter-return (,arg menu) ,menu-name))))
((:enable :active) (setq enable (or arg ''nil))) ((or `:enable `:active) (setq enable (or arg ''nil)))
(:label (setq label arg)) (`:label (setq label arg))
(:help (setq help arg)) (`:help (setq help arg))
((:included :visible) (setq visible (or arg ''nil))))) ((or `:included `:visible) (setq visible (or arg ''nil)))))
(if (equal visible ''nil) (if (equal visible ''nil)
nil ; Invisible menu entry, return nil. nil ; Invisible menu entry, return nil.
(if (and visible (not (easy-menu-always-true-p visible))) (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 keyword (aref item count))
(setq arg (aref item (1+ count))) (setq arg (aref item (1+ count)))
(setq count (+ 2 count)) (setq count (+ 2 count))
(case keyword (pcase keyword
((:included :visible) (setq visible (or arg ''nil))) ((or `:included `:visible) (setq visible (or arg ''nil)))
(:key-sequence (setq cache arg cache-specified t)) (`:key-sequence (setq cache arg cache-specified t))
(:keys (setq keys arg no-name nil)) (`:keys (setq keys arg no-name nil))
(:label (setq label arg)) (`:label (setq label arg))
((:active :enable) (setq active (or arg ''nil))) ((or `:active `:enable) (setq active (or arg ''nil)))
(:help (setq prop (cons :help (cons arg prop)))) (`:help (setq prop (cons :help (cons arg prop))))
(:suffix (setq suffix arg)) (`:suffix (setq suffix arg))
(:style (setq style arg)) (`:style (setq style arg))
(:selected (setq selected (or arg ''nil))))) (`:selected (setq selected (or arg ''nil)))))
(if suffix (if suffix
(setq label (setq label
(if (stringp suffix) (if (stringp suffix)

View file

@ -96,11 +96,11 @@
;;; Code: ;;; 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 ;; 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". ;; 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 (:type vector) ;ewoc--node-nth needs this
(:constructor nil) (:constructor nil)
(:constructor ewoc--node-create (start-marker data))) (: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 ;;; The ewoc data type
(defstruct (ewoc (cl-defstruct (ewoc
(:constructor nil) (:constructor nil)
(:constructor ewoc--create (buffer pretty-printer dll)) (:constructor ewoc--create (buffer pretty-printer dll))
(:conc-name ewoc--)) (:conc-name ewoc--))
@ -196,10 +196,10 @@ NODE and leaving the new node's start there. Return the new node."
(save-excursion (save-excursion
(let ((elemnode (ewoc--node-create (let ((elemnode (ewoc--node-create
(copy-marker (ewoc--node-start-marker node)) data))) (copy-marker (ewoc--node-start-marker node)) data)))
(setf (ewoc--node-left elemnode) (ewoc--node-left node) (cl-setf (ewoc--node-left elemnode) (ewoc--node-left node)
(ewoc--node-right elemnode) node (ewoc--node-right elemnode) node
(ewoc--node-right (ewoc--node-left node)) elemnode (ewoc--node-right (ewoc--node-left node)) elemnode
(ewoc--node-left node) elemnode) (ewoc--node-left node) elemnode)
(ewoc--refresh-node pretty-printer elemnode dll) (ewoc--refresh-node pretty-printer elemnode dll)
elemnode))) elemnode)))
@ -244,8 +244,8 @@ Normally, a newline is automatically inserted after the header,
the footer and every node's printed representation. Optional the footer and every node's printed representation. Optional
fourth arg NOSEP non-nil inhibits this." fourth arg NOSEP non-nil inhibits this."
(let* ((dummy-node (ewoc--node-create 'DL-LIST 'DL-LIST)) (let* ((dummy-node (ewoc--node-create 'DL-LIST 'DL-LIST))
(dll (progn (setf (ewoc--node-right dummy-node) dummy-node) (dll (progn (cl-setf (ewoc--node-right dummy-node) dummy-node)
(setf (ewoc--node-left dummy-node) dummy-node) (cl-setf (ewoc--node-left dummy-node) dummy-node)
dummy-node)) dummy-node))
(wrap (if nosep 'identity 'ewoc--wrap)) (wrap (if nosep 'identity 'ewoc--wrap))
(new-ewoc (ewoc--create (current-buffer) (new-ewoc (ewoc--create (current-buffer)
@ -258,12 +258,12 @@ fourth arg NOSEP non-nil inhibits this."
;; Set default values ;; Set default values
(unless header (setq header "")) (unless header (setq header ""))
(unless footer (setq footer "")) (unless footer (setq footer ""))
(setf (ewoc--node-start-marker dll) (copy-marker pos) (cl-setf (ewoc--node-start-marker dll) (copy-marker pos)
foot (ewoc--insert-new-node dll footer hf-pp dll) foot (ewoc--insert-new-node dll footer hf-pp dll)
head (ewoc--insert-new-node foot header hf-pp dll) head (ewoc--insert-new-node foot header hf-pp dll)
(ewoc--hf-pp new-ewoc) hf-pp (ewoc--hf-pp new-ewoc) hf-pp
(ewoc--footer new-ewoc) foot (ewoc--footer new-ewoc) foot
(ewoc--header new-ewoc) head)) (ewoc--header new-ewoc) head))
;; Return the ewoc ;; Return the ewoc
new-ewoc)) new-ewoc))
@ -274,7 +274,7 @@ fourth arg NOSEP non-nil inhibits this."
(defun ewoc-set-data (node data) (defun ewoc-set-data (node data)
"Set NODE to encapsulate 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) (defun ewoc-enter-first (ewoc data)
"Enter DATA first in EWOC. "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, ;; If we are about to delete the node pointed at by last-node,
;; set last-node to nil. ;; set last-node to nil.
(when (eq last node) (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) (delete-region (ewoc--node-start-marker node)
(ewoc--node-start-marker (ewoc--node-next dll node))) (ewoc--node-start-marker (ewoc--node-next dll node)))
(set-marker (ewoc--node-start-marker node) nil) (set-marker (ewoc--node-start-marker node) nil)
(setf L (ewoc--node-left node) (cl-setf L (ewoc--node-left node)
R (ewoc--node-right node) R (ewoc--node-right node)
;; Link neighbors to each other. ;; Link neighbors to each other.
(ewoc--node-right L) R (ewoc--node-right L) R
(ewoc--node-left R) L (ewoc--node-left R) L
;; Forget neighbors. ;; Forget neighbors.
(ewoc--node-left node) nil (ewoc--node-left node) nil
(ewoc--node-right node) nil)))) (ewoc--node-right node) nil))))
(defun ewoc-filter (ewoc predicate &rest args) (defun ewoc-filter (ewoc predicate &rest args)
"Remove all elements in EWOC for which PREDICATE returns nil. "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 (ewoc--set-buffer-bind-dll ewoc
(goto-char (ewoc--node-start-marker node)) (goto-char (ewoc--node-start-marker node))
(if goal-column (move-to-column goal-column)) (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) (defun ewoc-refresh (ewoc)
"Refresh all data in EWOC. "Refresh all data in EWOC.
@ -564,8 +564,8 @@ Return nil if the buffer has been deleted."
((head (ewoc--header ewoc)) ((head (ewoc--header ewoc))
(foot (ewoc--footer ewoc)) (foot (ewoc--footer ewoc))
(hf-pp (ewoc--hf-pp ewoc))) (hf-pp (ewoc--hf-pp ewoc)))
(setf (ewoc--node-data head) header (cl-setf (ewoc--node-data head) header
(ewoc--node-data foot) footer) (ewoc--node-data foot) footer)
(save-excursion (save-excursion
(ewoc--refresh-node hf-pp head dll) (ewoc--refresh-node hf-pp head dll)
(ewoc--refresh-node hf-pp foot dll)))) (ewoc--refresh-node hf-pp foot dll))))

View file

@ -121,7 +121,7 @@
;; - smie-indent-comment doesn't interact well with mis-indented lines (where ;; - 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. ;; 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 (defgroup smie nil
"Simple Minded Indentation Engine." "Simple Minded Indentation Engine."
@ -155,7 +155,7 @@
(defvar smie-warning-count 0) (defvar smie-warning-count 0)
(defun smie-set-prec2tab (table x y val &optional override) (defun smie-set-prec2tab (table x y val &optional override)
(assert (and x y)) (cl-assert (and x y))
(let* ((key (cons x y)) (let* ((key (cons x y))
(old (gethash key table))) (old (gethash key table)))
(if (and old (not (eq old val))) (if (and old (not (eq old val)))
@ -166,7 +166,7 @@
;; don't hide real conflicts. ;; don't hide real conflicts.
(puthash key (gethash key override) table) (puthash key (gethash key override) table)
(display-warning 'smie (format "Conflict: %s %s/%s %s" x old val y)) (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)))) (puthash key val table))))
(put 'smie-precs->prec2 'pure t) (put 'smie-precs->prec2 'pure t)
@ -268,8 +268,8 @@ be either:
(unless (consp rhs) (unless (consp rhs)
(signal 'wrong-type-argument `(consp ,rhs))) (signal 'wrong-type-argument `(consp ,rhs)))
(if (not (member (car rhs) nts)) (if (not (member (car rhs) nts))
(pushnew (car rhs) first-ops) (cl-pushnew (car rhs) first-ops)
(pushnew (car rhs) first-nts) (cl-pushnew (car rhs) first-nts)
(when (consp (cdr rhs)) (when (consp (cdr rhs))
;; If the first is not an OP we add the second (which ;; If the first is not an OP we add the second (which
;; should be an OP if BNF is an "operator grammar"). ;; should be an OP if BNF is an "operator grammar").
@ -282,16 +282,16 @@ be either:
(when (member (cadr rhs) nts) (when (member (cadr rhs) nts)
(error "Adjacent non-terminals: %s %s" (error "Adjacent non-terminals: %s %s"
(car rhs) (cadr rhs))) (car rhs) (cadr rhs)))
(pushnew (cadr rhs) first-ops))) (cl-pushnew (cadr rhs) first-ops)))
(let ((shr (reverse rhs))) (let ((shr (reverse rhs)))
(if (not (member (car shr) nts)) (if (not (member (car shr) nts))
(pushnew (car shr) last-ops) (cl-pushnew (car shr) last-ops)
(pushnew (car shr) last-nts) (cl-pushnew (car shr) last-nts)
(when (consp (cdr shr)) (when (consp (cdr shr))
(when (member (cadr shr) nts) (when (member (cadr shr) nts)
(error "Adjacent non-terminals: %s %s" (error "Adjacent non-terminals: %s %s"
(cadr shr) (car shr))) (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 first-ops) first-ops-table)
(push (cons nt last-ops) last-ops-table) (push (cons nt last-ops) last-ops-table)
(push (cons nt first-nts) first-nts-table) (push (cons nt first-nts) first-nts-table)
@ -307,7 +307,7 @@ be either:
(dolist (op (cdr (assoc first-nt first-ops-table))) (dolist (op (cdr (assoc first-nt first-ops-table)))
(unless (member op first-ops) (unless (member op first-ops)
(setq again t) (setq again t)
(push op (cdr first-ops)))))))) (cl-push op (cdr first-ops))))))))
;; Same thing for last-ops. ;; Same thing for last-ops.
(setq again t) (setq again t)
(while (prog1 again (setq again nil)) (while (prog1 again (setq again nil))
@ -318,7 +318,7 @@ be either:
(dolist (op (cdr (assoc last-nt last-ops-table))) (dolist (op (cdr (assoc last-nt last-ops-table)))
(unless (member op last-ops) (unless (member op last-ops)
(setq again t) (setq again t)
(push op (cdr last-ops)))))))) (cl-push op (cdr last-ops))))))))
;; Now generate the 2D precedence table. ;; Now generate the 2D precedence table.
(dolist (rules bnf) (dolist (rules bnf)
(dolist (rhs (cdr rules)) (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 (if no-inners
(let ((last (car (last rhs)))) (let ((last (car (last rhs))))
(unless (member last nts) (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, ;; Reverse so that the "real" closer gets there first,
;; which is important for smie-close-block. ;; which is important for smie-close-block.
(dolist (term (reverse (cdr rhs))) (dolist (term (reverse (cdr rhs)))
(unless (member term nts) (unless (member term nts)
(pushnew (cons (car rhs) term) alist :test #'equal))))))) (cl-pushnew (cons (car rhs) term) alist :test #'equal)))))))
(nreverse alist))) (nreverse alist)))
(defun smie-bnf--set-class (table token class) (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)) (push (concat "." (car elem)) res))
(if (eq (cddr elem) val) (if (eq (cddr elem) val)
(push (concat (car elem) ".") res))) (push (concat (car elem) ".") res)))
(assert res) (cl-assert res)
res)) res))
cycle))) cycle)))
(mapconcat (mapconcat
@ -498,9 +498,9 @@ CSTS is a list of pairs representing arcs in a graph."
;; (right (nth 1 (assoc (cdr k) grammar)))) ;; (right (nth 1 (assoc (cdr k) grammar))))
;; (when (and left right) ;; (when (and left right)
;; (cond ;; (cond
;; ((< left right) (assert (eq v '<))) ;; ((< left right) (cl-assert (eq v '<)))
;; ((> left right) (assert (eq v '>))) ;; ((> left right) (cl-assert (eq v '>)))
;; (t (assert (eq v '=)))))))) ;; (t (cl-assert (eq v '=))))))))
;; prec2)) ;; prec2))
(put 'smie-prec2->grammar 'pure t) (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'. ;; final `table'. The value of each "variable" is kept in the `car'.
(let ((table ()) (let ((table ())
(csts ()) (csts ())
(eqs ()) (eqs ()))
tmp x y)
;; From `prec2' we construct a list of constraints between ;; From `prec2' we construct a list of constraints between
;; variables (aka "precedence levels"). These can be either ;; variables (aka "precedence levels"). These can be either
;; equality constraints (in `eqs') or `<' constraints (in `csts'). ;; equality constraints (in `eqs') or `<' constraints (in `csts').
(maphash (lambda (k v) (maphash (lambda (k v)
(when (consp k) (when (consp k)
(if (setq tmp (assoc (car k) table)) (let ((tmp (assoc (car k) table))
(setq x (cddr tmp)) x y)
(setq x (cons nil nil)) (if tmp
(push (cons (car k) (cons nil x)) table)) (setq x (cddr tmp))
(if (setq tmp (assoc (cdr k) table)) (setq x (cons nil nil))
(setq y (cdr tmp)) (push (cons (car k) (cons nil x)) table))
(setq y (cons nil (cons nil nil))) (if (setq tmp (assoc (cdr k) table))
(push (cons (cdr k) y) table)) (setq y (cdr tmp))
(ecase v (setq y (cons nil (cons nil nil)))
(= (push (cons x y) eqs)) (push (cons (cdr k) y) table))
(< (push (cons x y) csts)) (pcase v
(> (push (cons y x) csts))))) (`= (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) prec2)
;; First process the equality constraints. ;; First process the equality constraints.
(let ((eqs eqs)) (let ((eqs eqs))
@ -572,13 +575,13 @@ PREC2 is a table as returned by `smie-precs->prec2' or
(unless (caar cst) (unless (caar cst)
(setcar (car cst) i) (setcar (car cst) i)
;; (smie-check-grammar table prec2 'step1) ;; (smie-check-grammar table prec2 'step1)
(incf i)) (cl-incf i))
(setq csts (delq cst csts)))) (setq csts (delq cst csts))))
(unless progress (unless progress
(error "Can't resolve the precedence cycle: %s" (error "Can't resolve the precedence cycle: %s"
(smie-debug--describe-cycle (smie-debug--describe-cycle
table (smie-debug--prec2-cycle csts))))) table (smie-debug--prec2-cycle csts)))))
(incf i 10)) (cl-incf i 10))
;; Propagate equality constraints back to their sources. ;; Propagate equality constraints back to their sources.
(dolist (eq (nreverse eqs)) (dolist (eq (nreverse eqs))
(when (null (cadr eq)) (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 ;; So set it here rather than below since doing it below
;; makes it more difficult to obey the equality constraints. ;; makes it more difficult to obey the equality constraints.
(setcar (cdr eq) i) (setcar (cdr eq) i)
(incf i)) (cl-incf i))
(assert (or (null (caar eq)) (eq (caar eq) (cadr eq)))) (cl-assert (or (null (caar eq)) (eq (caar eq) (cadr eq))))
(setcar (car eq) (cadr eq)) (setcar (car eq) (cadr eq))
;; (smie-check-grammar table prec2 'step2) ;; (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). ;; left side of any < constraint).
(dolist (x table) (dolist (x table)
(unless (nth 1 x) (unless (nth 1 x)
(setf (nth 1 x) i) (cl-setf (nth 1 x) i)
(incf i)) ;See other (incf i) above. (cl-incf i)) ;See other (cl-incf i) above.
(unless (nth 2 x) (unless (nth 2 x)
(setf (nth 2 x) i) (cl-setf (nth 2 x) i)
(incf i)))) ;See other (incf i) above. (cl-incf i)))) ;See other (cl-incf i) above.
;; Mark closers and openers. ;; Mark closers and openers.
(dolist (x (gethash :smie-open/close-alist prec2)) (dolist (x (gethash :smie-open/close-alist prec2))
(let* ((token (car x)) (let* ((token (car x))
(cons (case (cdr x) (cons (pcase (cdr x)
(closer (cddr (assoc token table))) (`closer (cddr (assoc token table)))
(opener (cdr (assoc token table)))))) (`opener (cdr (assoc token table))))))
(assert (numberp (car cons))) (cl-assert (numberp (car cons)))
(setf (car cons) (list (car cons))))) (cl-setf (car cons) (list (car cons)))))
(let ((ca (gethash :smie-closer-alist prec2))) (let ((ca (gethash :smie-closer-alist prec2)))
(when ca (push (cons :smie-closer-alist ca) table))) (when ca (push (cons :smie-closer-alist ca) table)))
;; (smie-check-grammar table prec2 'step3) ;; (smie-check-grammar table prec2 'step3)
@ -706,19 +709,19 @@ Possible return values:
(condition-case err (condition-case err
(progn (goto-char pos) (funcall next-sexp 1) nil) (progn (goto-char pos) (funcall next-sexp 1) nil)
(scan-error (throw 'return (scan-error (throw 'return
(list t (caddr err) (list t (cl-caddr err)
(buffer-substring-no-properties (buffer-substring-no-properties
(caddr err) (cl-caddr err)
(+ (caddr err) (+ (cl-caddr err)
(if (< (point) (caddr err)) (if (< (point) (cl-caddr err))
-1 1))))))) -1 1)))))))
(if (eq pos (point)) (if (eq pos (point))
;; We did not move, so let's abort the loop. ;; We did not move, so let's abort the loop.
(throw 'return (list t (point)))))) (throw 'return (list t (point))))))
((not (numberp (funcall op-back toklevels))) ((not (numberp (funcall op-back toklevels)))
;; A token like a paren-close. ;; A token like a paren-close.
(assert (numberp ; Otherwise, why mention it in smie-grammar. (cl-assert (numberp ; Otherwise, why mention it in smie-grammar.
(funcall op-forw toklevels))) (funcall op-forw toklevels)))
(push toklevels levels)) (push toklevels levels))
(t (t
(while (and levels (< (funcall op-back toklevels) (while (and levels (< (funcall op-back toklevels)
@ -1672,12 +1675,12 @@ KEYWORDS are additional arguments, which can use the following keywords:
(while keywords (while keywords
(let ((k (pop keywords)) (let ((k (pop keywords))
(v (pop keywords))) (v (pop keywords)))
(case k (pcase k
(:forward-token (`:forward-token
(set (make-local-variable 'smie-forward-token-function) v)) (set (make-local-variable 'smie-forward-token-function) v))
(:backward-token (`:backward-token
(set (make-local-variable 'smie-backward-token-function) v)) (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)))) (let ((ca (cdr (assq :smie-closer-alist grammar))))
(when ca (when ca
(set (make-local-variable 'smie-closer-alist) ca) (set (make-local-variable 'smie-closer-alist) ca)

View file

@ -41,7 +41,7 @@
;; Note: PPSS stands for `parse-partial-sexp state' ;; 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) (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 ;; 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 ;; highlight to match 0, create an extra group to be able to
;; tell when *this* match 0 has succeeded. ;; tell when *this* match 0 has succeeded.
(incf offset) (cl-incf offset)
(setq re (concat "\\(" re "\\)"))) (setq re (concat "\\(" re "\\)")))
(setq re (syntax-propertize--shift-groups re offset)) (setq re (syntax-propertize--shift-groups re offset))
(let ((code '()) (let ((code '())
@ -215,7 +215,7 @@ Note: back-references in REGEXPs do not work."
(setq offset 0))) (setq offset 0)))
;; Now construct the code for each subgroup rules. ;; Now construct the code for each subgroup rules.
(dolist (case (cdr rule)) (dolist (case (cdr rule))
(assert (null (cddr case))) (cl-assert (null (cddr case)))
(let* ((gn (+ offset (car case))) (let* ((gn (+ offset (car case)))
(action (nth 1 case)) (action (nth 1 case))
(thiscode (thiscode
@ -260,7 +260,7 @@ Note: back-references in REGEXPs do not work."
code)))) code))))
(push (cons condition (nreverse code)) (push (cons condition (nreverse code))
branches)) branches))
(incf offset (regexp-opt-depth orig-re)) (cl-incf offset (regexp-opt-depth orig-re))
re)) re))
rules rules
"\\|"))) "\\|")))
@ -418,8 +418,8 @@ Point is at POS when this function returns."
(* 2 (/ (cdr (aref syntax-ppss-stats 5)) (* 2 (/ (cdr (aref syntax-ppss-stats 5))
(1+ (car (aref syntax-ppss-stats 5))))))) (1+ (car (aref syntax-ppss-stats 5)))))))
(progn (progn
(incf (car (aref syntax-ppss-stats 0))) (cl-incf (car (aref syntax-ppss-stats 0)))
(incf (cdr (aref syntax-ppss-stats 0)) (- pos old-pos)) (cl-incf (cdr (aref syntax-ppss-stats 0)) (- pos old-pos))
(parse-partial-sexp old-pos pos nil nil old-ppss)) (parse-partial-sexp old-pos pos nil nil old-ppss))
(cond (cond
@ -435,8 +435,8 @@ Point is at POS when this function returns."
(setq pt-min (or (syntax-ppss-toplevel-pos old-ppss) (setq pt-min (or (syntax-ppss-toplevel-pos old-ppss)
(nth 2 old-ppss))) (nth 2 old-ppss)))
(<= pt-min pos) (< (- pos pt-min) syntax-ppss-max-span)) (<= pt-min pos) (< (- pos pt-min) syntax-ppss-max-span))
(incf (car (aref syntax-ppss-stats 1))) (cl-incf (car (aref syntax-ppss-stats 1)))
(incf (cdr (aref syntax-ppss-stats 1)) (- pos pt-min)) (cl-incf (cdr (aref syntax-ppss-stats 1)) (- pos pt-min))
(setq ppss (parse-partial-sexp pt-min pos))) (setq ppss (parse-partial-sexp pt-min pos)))
;; The OLD-* data can't be used. Consult the cache. ;; The OLD-* data can't be used. Consult the cache.
(t (t
@ -464,8 +464,8 @@ Point is at POS when this function returns."
;; Use the best of OLD-POS and CACHE. ;; Use the best of OLD-POS and CACHE.
(if (or (not old-pos) (< old-pos pt-min)) (if (or (not old-pos) (< old-pos pt-min))
(setq pt-best pt-min ppss-best ppss) (setq pt-best pt-min ppss-best ppss)
(incf (car (aref syntax-ppss-stats 4))) (cl-incf (car (aref syntax-ppss-stats 4)))
(incf (cdr (aref syntax-ppss-stats 4)) (- pos old-pos)) (cl-incf (cdr (aref syntax-ppss-stats 4)) (- pos old-pos))
(setq pt-best old-pos ppss-best old-ppss)) (setq pt-best old-pos ppss-best old-ppss))
;; Use the `syntax-begin-function' if available. ;; 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) (not (memq (get-text-property (point) 'face)
'(font-lock-string-face font-lock-doc-face '(font-lock-string-face font-lock-doc-face
font-lock-comment-face)))) font-lock-comment-face))))
(incf (car (aref syntax-ppss-stats 5))) (cl-incf (car (aref syntax-ppss-stats 5)))
(incf (cdr (aref syntax-ppss-stats 5)) (- pos (point))) (cl-incf (cdr (aref syntax-ppss-stats 5)) (- pos (point)))
(setq pt-best (point) ppss-best nil)) (setq pt-best (point) ppss-best nil))
(cond (cond
;; Quick case when we found a nearby pos. ;; Quick case when we found a nearby pos.
((< (- pos pt-best) syntax-ppss-max-span) ((< (- pos pt-best) syntax-ppss-max-span)
(incf (car (aref syntax-ppss-stats 2))) (cl-incf (car (aref syntax-ppss-stats 2)))
(incf (cdr (aref syntax-ppss-stats 2)) (- pos pt-best)) (cl-incf (cdr (aref syntax-ppss-stats 2)) (- pos pt-best))
(setq ppss (parse-partial-sexp pt-best pos nil nil ppss-best))) (setq ppss (parse-partial-sexp pt-best pos nil nil ppss-best)))
;; Slow case: compute the state from some known position and ;; Slow case: compute the state from some known position and
;; populate the cache so we won't need to do it again soon. ;; populate the cache so we won't need to do it again soon.
(t (t
(incf (car (aref syntax-ppss-stats 3))) (cl-incf (car (aref syntax-ppss-stats 3)))
(incf (cdr (aref syntax-ppss-stats 3)) (- pos pt-min)) (cl-incf (cdr (aref syntax-ppss-stats 3)) (- pos pt-min))
;; If `pt-min' is too far, add a few intermediate entries. ;; If `pt-min' is too far, add a few intermediate entries.
(while (> (- pos pt-min) (* 2 syntax-ppss-max-span)) (while (> (- pos pt-min) (* 2 syntax-ppss-max-span))
@ -513,7 +513,7 @@ Point is at POS when this function returns."
nil nil ppss)) nil nil ppss))
(let ((pair (cons pt-min ppss))) (let ((pair (cons pt-min ppss)))
(if cache-pred (if cache-pred
(push pair (cdr cache-pred)) (cl-push pair (cdr cache-pred))
(push pair syntax-ppss-cache)))) (push pair syntax-ppss-cache))))
;; Compute the actual return value. ;; Compute the actual return value.
@ -533,7 +533,7 @@ Point is at POS when this function returns."
(let ((pair (cons pos ppss))) (let ((pair (cons pos ppss)))
(if cache-pred (if cache-pred
(if (> (- (caar cache-pred) pos) syntax-ppss-max-span) (if (> (- (caar cache-pred) pos) syntax-ppss-max-span)
(push pair (cdr cache-pred)) (cl-push pair (cdr cache-pred))
(setcar cache-pred pair)) (setcar cache-pred pair))
(if (or (null syntax-ppss-cache) (if (or (null syntax-ppss-cache)
(> (- (caar syntax-ppss-cache) pos) (> (- (caar syntax-ppss-cache) pos)

View file

@ -33,9 +33,9 @@
;; triggered-p is nil if the timer is active (waiting to be triggered), ;; triggered-p is nil if the timer is active (waiting to be triggered),
;; t if it is inactive ("already triggered", in theory) ;; 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) (:constructor nil)
(:copier nil) (:copier nil)
(:constructor timer-create ()) (:constructor timer-create ())
@ -54,15 +54,15 @@
(timer--low-seconds timer) (timer--low-seconds timer)
(timer--usecs timer))) (timer--usecs timer)))
(defsetf timer--time (cl-defsetf timer--time
(lambda (timer time) (lambda (timer time)
(or (timerp timer) (error "Invalid timer")) (or (timerp timer) (error "Invalid timer"))
(setf (timer--high-seconds timer) (pop time)) (cl-setf (timer--high-seconds timer) (pop time))
(setf (timer--low-seconds timer) (cl-setf (timer--low-seconds timer)
(if (consp time) (car time) time)) (if (consp time) (car time) time))
(setf (timer--usecs timer) (or (and (consp time) (consp (cdr time)) (cl-setf (timer--usecs timer) (or (and (consp time) (consp (cdr time))
(cadr time)) (cadr time))
0)))) 0))))
(defun timer-set-time (timer time &optional delta) (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'. 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 If optional third argument DELTA is a positive number, make the timer
fire repeatedly that many seconds apart." fire repeatedly that many seconds apart."
(setf (timer--time timer) time) (cl-setf (timer--time timer) time)
(setf (timer--repeat-delay timer) (and (numberp delta) (> delta 0) delta)) (cl-setf (timer--repeat-delay timer) (and (numberp delta) (> delta 0) delta))
timer) timer)
(defun timer-set-idle-time (timer secs &optional repeat) (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 If optional third argument REPEAT is non-nil, make the timer
fire each time Emacs is idle for that many seconds." fire each time Emacs is idle for that many seconds."
(if (consp secs) (if (consp secs)
(setf (timer--time timer) secs) (cl-setf (timer--time timer) secs)
(setf (timer--time timer) '(0 0 0)) (cl-setf (timer--time timer) '(0 0 0))
(timer-inc-time timer secs)) (timer-inc-time timer secs))
(setf (timer--repeat-delay timer) repeat) (cl-setf (timer--repeat-delay timer) repeat)
timer) timer)
(defun timer-next-integral-multiple-of-time (time secs) (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) (defun timer-inc-time (timer secs &optional usecs)
"Increment the time set in TIMER by SECS seconds and USECS microseconds. "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." SECS may be a fraction. If USECS is omitted, that means it is zero."
(setf (timer--time timer) (cl-setf (timer--time timer)
(timer-relative-time (timer--time timer) secs usecs))) (timer-relative-time (timer--time timer) secs usecs)))
(defun timer-set-time-with-usecs (timer time usecs &optional delta) (defun timer-set-time-with-usecs (timer time usecs &optional delta)
"Set the trigger time of TIMER to TIME plus USECS. "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. The microsecond count from TIME is ignored, and USECS is used instead.
If optional fourth argument DELTA is a positive number, make the timer If optional fourth argument DELTA is a positive number, make the timer
fire repeatedly that many seconds apart." fire repeatedly that many seconds apart."
(setf (timer--time timer) time) (cl-setf (timer--time timer) time)
(setf (timer--usecs timer) usecs) (cl-setf (timer--usecs timer) usecs)
(setf (timer--repeat-delay timer) (and (numberp delta) (> delta 0) delta)) (cl-setf (timer--repeat-delay timer) (and (numberp delta) (> delta 0) delta))
timer) timer)
(make-obsolete 'timer-set-time-with-usecs (make-obsolete 'timer-set-time-with-usecs
"use `timer-set-time' and `timer-inc-time' instead." "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." "Make TIMER call FUNCTION with optional ARGS when triggering."
(or (timerp timer) (or (timerp timer)
(error "Invalid timer")) (error "Invalid timer"))
(setf (timer--function timer) function) (cl-setf (timer--function timer) function)
(setf (timer--args timer) args) (cl-setf (timer--args timer) args)
timer) timer)
(defun timer--activate (timer &optional triggered-p reuse-cell idle) (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)) (cond (last (setcdr last reuse-cell))
(idle (setq timer-idle-list reuse-cell)) (idle (setq timer-idle-list reuse-cell))
(t (setq timer-list reuse-cell))) (t (setq timer-list reuse-cell)))
(setf (timer--triggered timer) triggered-p) (cl-setf (timer--triggered timer) triggered-p)
(setf (timer--idle-delay timer) idle) (cl-setf (timer--idle-delay timer) idle)
nil) nil)
(error "Invalid or uninitialized timer"))) (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))) (apply (timer--function timer) (timer--args timer)))
(error nil)) (error nil))
(if retrigger (if retrigger
(setf (timer--triggered timer) nil))) (cl-setf (timer--triggered timer) nil)))
(error "Bogus timer event")))) (error "Bogus timer event"))))
;; This function is incompatible with the one in levents.el. ;; This function is incompatible with the one in levents.el.