summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2022-05-06 13:10:45 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2022-05-06 13:10:45 +0200
commitb13356487fc3eaf82bfe51bee24ddf70c27c5834 (patch)
tree4e3f91a3b0bfc416a40d6366365fdff8d232b65f /test
parent0bda1803bb83de41d4f1d55ee3e2437f2177c076 (diff)
downloademacs-b13356487fc3eaf82bfe51bee24ddf70c27c5834.tar.gz
Add new helper macros for minor modes to restore variables
* doc/lispref/modes.texi (Defining Minor Modes): Document it. * lisp/emacs-lisp/easy-mmode.el (buffer-local-set-state): New macro. (buffer-local-set-state--get): Helper function. (buffer-local-restore-state): New function. * lisp/textmodes/word-wrap-mode.el (word-wrap-whitespace-mode): Use it to simplify code.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/emacs-lisp/easy-mmode-tests.el12
1 files changed, 11 insertions, 1 deletions
diff --git a/test/lisp/emacs-lisp/easy-mmode-tests.el b/test/lisp/emacs-lisp/easy-mmode-tests.el
index 0a3bbb189ba..697bf6c2152 100644
--- a/test/lisp/emacs-lisp/easy-mmode-tests.el
+++ b/test/lisp/emacs-lisp/easy-mmode-tests.el
@@ -60,6 +60,16 @@
(easy-mmode-test-mode 'toggle)
(should (eq easy-mmode-test-mode t))))
-(provide 'easy-mmode-tests)
+(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