aboutsummaryrefslogtreecommitdiff
path: root/evil-tests.el
diff options
context:
space:
mode:
authoribbem <ibbem@ibbem.net>2023-03-15 10:39:48 +0100
committerAxel Forsman <axelsfor@gmail.com>2023-03-17 11:43:04 +0100
commit53fb7af0204d297661949aa208a867d74362a256 (patch)
treedcbe577dee29828890b555247e56861ebf003bc9 /evil-tests.el
parentbdbf41bb91792418f96049d063c5d28a0777dad2 (diff)
Restore the input method on deactivation of evil-local-mode
This ensures that the input method after deactivating evil-local-mode is the same as the input method used for states with a non-nil :input-method property. This issue was discovered while investigating why the input method couldn't be set by the agda2-mode while evil was active [1]. As the change in major mode (to agda2-mode) caused evil-local-mode to be disabled and reenabled by `define-globalized-minor-mode evil-mode`, the input method was lost because the default state (i.e. normal state) does have an :input-method property of nil. In summary this patch fixes the approach used by agda2-mode [2] and the official recommendation in the Emacs manual [3], e.g. (add-hook 'text-mode-hook (lambda () (set-input-method "german-prefix"))) [1]: https://github.com/agda/agda/issues/2141 [2]: https://github.com/agda/agda/blob/37554c46cbd770fa630f9b164e2b543506acbdbc/src/data/emacs-mode/agda2-mode.el#L432 [3]: https://www.gnu.org/software/emacs/manual/html_node/emacs/Select-Input-Method.html
Diffstat (limited to 'evil-tests.el')
-rw-r--r--evil-tests.el20
1 files changed, 20 insertions, 0 deletions
diff --git a/evil-tests.el b/evil-tests.el
index 0a0bb4c..fbf1cd4 100644
--- a/evil-tests.el
+++ b/evil-tests.el
@@ -9679,6 +9679,26 @@ main(argc, argv) char **argv; {
(test-3-mode)
(should (eq evil-state 'insert))))
+(ert-deftest evil-test-keep-input-method ()
+ "Test that the input method is preserved when changing the major mode."
+ :tags '(evil core input-method)
+ (cl-flet ((use-german-input-method () (set-input-method "german-prefix")))
+ (unwind-protect
+ (progn
+ (add-hook 'text-mode-hook #'use-german-input-method)
+ (evil-test-buffer
+ "[]"
+ (should (equal evil-input-method nil))
+ ("a\"a" [escape])
+ "\"[a]"
+ (text-mode)
+ (should (equal evil-input-method "german-prefix"))
+ ("a\"a" [escape])
+ "\"a[รค]"
+ (emacs-lisp-mode)
+ (should (equal evil-input-method "german-prefix"))))
+ (remove-hook 'text-mode-hook #'use-german-input-method))))
+
(provide 'evil-tests)
;;; evil-tests.el ends here