summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2022-05-06 16:09:38 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2022-05-06 16:09:38 +0200
commitafc14e4f661194969ef1622e2d9310cfbf662aff (patch)
tree6e480d181b95e40d4f6a807851b9466f935f3113 /lisp/emacs-lisp
parent92bbe911e99968c04509c553767fa83bfdcbeb18 (diff)
downloademacs-afc14e4f661194969ef1622e2d9310cfbf662aff.tar.gz
emacs-afc14e4f661194969ef1622e2d9310cfbf662aff.tar.bz2
emacs-afc14e4f661194969ef1622e2d9310cfbf662aff.zip
Move buffer-local-set-state to subr because it's used at runtime
* lisp/subr.el (buffer-local-set-state) (buffer-local-set-state--get, buffer-local-restore-state): Moved from easy-mmode.el because they have to be available run-time.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/easy-mmode.el36
1 files changed, 0 insertions, 36 deletions
diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el
index 2568eaeb76a..54cac116168 100644
--- a/lisp/emacs-lisp/easy-mmode.el
+++ b/lisp/emacs-lisp/easy-mmode.el
@@ -825,42 +825,6 @@ Interactively, COUNT is the prefix numeric argument, and defaults to 1."
,@body))
(put ',prev-sym 'definition-name ',base))))
-
-(defmacro buffer-local-set-state (&rest pairs)
- "Like `setq-local', but allow restoring the previous state of locals later.
-This macro returns an object that can be passed to `buffer-local-restore-state'
-in order to restore the state of the local variables set via this macro.
-
-\(fn [VARIABLE VALUE]...)"
- (declare (debug setq))
- (unless (zerop (mod (length pairs) 2))
- (error "PAIRS must have an even number of variable/value members"))
- `(prog1
- (buffer-local-set-state--get ',pairs)
- (setq-local ,@pairs)))
-
-;;;###autoload
-(defun buffer-local-set-state--get (pairs)
- (let ((states nil))
- (while pairs
- (push (list (car pairs)
- (and (boundp (car pairs))
- (local-variable-p (car pairs)))
- (and (boundp (car pairs))
- (symbol-value (car pairs))))
- states)
- (setq pairs (cddr pairs)))
- (nreverse states)))
-
-;;;###autoload
-(defun buffer-local-restore-state (states)
- "Restore values of buffer-local variables recorded in STATES.
-STATES should be an object returned by `buffer-local-set-state'."
- (pcase-dolist (`(,variable ,local ,value) states)
- (if local
- (set variable value)
- (kill-local-variable variable))))
-
(provide 'easy-mmode)
;;; easy-mmode.el ends here