Provide generalized variables in core Elisp.
* lisp/emacs-lisp/gv.el: New file. * lisp/subr.el (push, pop): Extend to generalized variables. * lisp/loadup.el (macroexp): Unload if preloaded and uncompiled. * lisp/emacs-lisp/cl-lib.el (cl-pop, cl-push, cl--set-nthcdr): Remove. * lisp/emacs-lisp/cl-macs.el: Require gv. Use gv-define-setter, gv-define-simple-setter, and gv-define-expander. Remove setf-methods defined in gv. Rename cl-setf -> setf. (cl-setf, cl-do-pop, cl-get-setf-method): Remove. (cl-letf, cl-letf*, cl-define-modify-macro, cl-defsetf) (cl-define-setf-expander, cl-struct-setf-expander): Move to cl.el. (cl-remf, cl-shiftf, cl-rotatef, cl-callf, cl-callf2): Rewrite with gv-letplace. (cl-defstruct): Don't define setf-method any more. * lisp/emacs-lisp/cl.el (flet): Don't autoload. (cl--letf, letf, cl--letf*, letf*, cl--gv-adapt) (define-setf-expander, defsetf, define-modify-macro) (cl-struct-setf-expander): Move from cl-lib.el. * lisp/emacs-lisp/syntax.el: * lisp/emacs-lisp/ewoc.el: * lisp/emacs-lisp/smie.el: * lisp/emacs-lisp/cconv.el: * lisp/emacs-lisp/timer.el: Rename cl-setf -> setf, cl-push -> push. (timer--time): Use gv-define-simple-setter. * lisp/emacs-lisp/macroexp.el (macroexp-let2): Rename from macroexp-let² to avoid coding-system problems in subr.el. Adjust all users. (macroexp--maxsize, macroexp-small-p): New functions. * lisp/emacs-lisp/bytecomp.el (byte-compile-file): Don't use cl-letf. * lisp/scroll-bar.el (scroll-bar-mode): * lisp/simple.el (auto-fill-mode, overwrite-mode, binary-overwrite-mode) (normal-erase-is-backspace-mode): Don't use the `eq' place. * lisp/winner.el (winner-configuration, winner-make-point-alist) (winner-set-conf, winner-get-point, winner-set): Don't abuse letf. * lisp/files.el (locate-file-completion-table): Avoid list*. Fixes: debbugs:11657
This commit is contained in:
parent
575db3f1a8
commit
2ee3d7f0aa
23 changed files with 2043 additions and 1972 deletions
|
@ -263,7 +263,7 @@ definitions to shadow the loaded ones for use in file byte-compilation."
|
|||
((memq (car-safe then) '(if cond)) (macroexp-if `(not ,test) else then))
|
||||
(t `(if ,test ,then ,else))))
|
||||
|
||||
(defmacro macroexp-let² (test var exp &rest exps)
|
||||
(defmacro macroexp-let2 (test var exp &rest exps)
|
||||
"Bind VAR to a copyable expression that returns the value of EXP.
|
||||
This is like `(let ((v ,EXP)) ,EXPS) except that `v' is a new generated
|
||||
symbol which EXPS can find in VAR.
|
||||
|
@ -280,6 +280,27 @@ be skipped; if nil, as is usual, `macroexp-const-p' is used."
|
|||
(macroexp-let* (list (list ,var ,expsym))
|
||||
,bodysym)))))
|
||||
|
||||
(defun macroexp--maxsize (exp size)
|
||||
(cond ((< size 0) size)
|
||||
((symbolp exp) (1- size))
|
||||
((stringp exp) (- size (/ (length exp) 16)))
|
||||
((vectorp exp)
|
||||
(dotimes (i (length exp))
|
||||
(setq size (macroexp--maxsize (aref exp i) size)))
|
||||
(1- size))
|
||||
((consp exp)
|
||||
;; We could try to be more clever with quote&function,
|
||||
;; but it is difficult to do so correctly, and it's not obvious that
|
||||
;; it would be worth the effort.
|
||||
(dolist (e exp)
|
||||
(setq size (macroexp--maxsize e size)))
|
||||
(1- size))
|
||||
(t -1)))
|
||||
|
||||
(defun macroexp-small-p (exp)
|
||||
"Return non-nil if EXP can be considered small."
|
||||
(> (macroexp--maxsize exp 10) 0))
|
||||
|
||||
(defsubst macroexp--const-symbol-p (symbol &optional any-value)
|
||||
"Non-nil if SYMBOL is constant.
|
||||
If ANY-VALUE is nil, only return non-nil if the value of the symbol is the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue