,@body))
(put ',prev-sym 'definition-name ',base))))
-\f
-(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
(function-put 'easy-mmode-defsyntax 'lisp-indent-function '1)
-(autoload 'buffer-local-set-state--get "easy-mmode" "\
-
-
-\(fn PAIRS)" nil nil)
-
-(autoload 'buffer-local-restore-state "easy-mmode" "\
-Restore buffer local variable values in STATES.
-STATES is an object returned by `buffer-local-set-state'.
-
-\(fn STATES)" nil nil)
-
-(register-definition-prefixes "easy-mmode" '("buffer-local-set-state" "easy-mmode-"))
+(register-definition-prefixes "easy-mmode" '("easy-mmode-"))
;;;***
\f
(:success t)
(void-variable nil)))
+(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)))
+
+(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)))
+
+(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))))
+
(defmacro push (newelt place)
"Add NEWELT to the list stored in the generalized variable PLACE.
This is morally equivalent to (setf PLACE (cons NEWELT PLACE)),
(easy-mmode-test-mode 'toggle)
(should (eq easy-mmode-test-mode t))))
-(ert-deftest test-local-set-state ()
- (setq global 1)
- (with-temp-buffer
- (setq-local local 2)
- (let ((state (buffer-local-set-state global 10
- local 20
- unexist 30)))
- (buffer-local-restore-state state)
- (should (= global 1))
- (should (= local 2))
- (should-not (boundp 'unexist)))))
-
;;; easy-mmode-tests.el ends here
(should (equal (kbd "C-x ( C-d C-x )") "\ 4"))
(should (equal (kbd "C-x ( C-x )") "")))
+(ert-deftest test-local-set-state ()
+ (setq global 1)
+ (with-temp-buffer
+ (setq-local local 2)
+ (let ((state (buffer-local-set-state global 10
+ local 20
+ unexist 30)))
+ (buffer-local-restore-state state)
+ (should (= global 1))
+ (should (= local 2))
+ (should-not (boundp 'unexist)))))
+
(provide 'subr-tests)
;;; subr-tests.el ends here