New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
agda-mode: Make unicode play well with evil-mode #2141
Comments
Using unicode in the regular /-search would also be beneficial. |
I do not know evil-mode, but the Agda input method can be toggled by |
I am able to reproduce this when evil-mode is disabled. Furthermore, if I run with (require 'evil-mode), open an Agda program, and run (turn-on-evil-mode), it still works. It even works using evil-mode's /-search. It also works in the normaliser and in the typechecker. But, if you have (evil-mode 1) in your configuration, which turns on evil-mode globally -- it doesn't work in search. I don't know why this is significant. It's all very confusing. The good news is that your C-\ tips always works for the normaliser and in the typechecker, even with evil-mode, so that's a godsend. Now if only search would be a little bit more collaborative as well. |
Shooting in the dark: could it be that if evil-mode is on globally, then the C-\ functionality is bound to something else globally, even in the search minibuffer?! [Not very consistent with the fact it works in Agda interaction though...] Unfortunately, I am not good a emacs-lisp and I am not a vi user at all. Maybe @UlfNorell knows something, he is a vi user. |
Interestingly C-h k C-\ says "C-\ runs the command toggle-input-method". I'm not an advanced emacs user yet, so I'm not sure how I can check what C-\ is bound to at the moment of attempting to search (either via / or via C-s). Amusingly, I found out that C-h d supports C-\ for some reason. It's all seemingly quite random to me as an inexperienced user. |
I'm a vi user, but not an emacs user (except for Agda coding) and no evil-mode experience. |
Let's try to figure out where the problem lies. Load the following code (by placing the cursor right after the final closing parenthesis and typing
Now execute the code (using |
I'm not sure what you mean by "preserved", but I can indeed activate it in this prompt. |
I interpret your response as saying that, despite the Agda input method being active just before you run |
This ensures that the input method after deactivating evil-local-mode is the same as the input method used for states with an :input-method property of non-nil. 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]: agda/agda#2141 [1]: 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
This ensures that the input method after deactivating evil-local-mode is the same as the input method used for states with an :input-method property of non-nil. 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]: agda/agda#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
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]: agda/agda#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
I've experienced the same issue. It's correct that evil is the problem in this case. I opened a pull request addressing this issue. In the meantime, for everyone who is annoyed by this: Putting the following code snippet in your Emacs config solves this issue (eliminates the need for pressing (defun set-agda-input-method ()
(evil-without-input-method-hooks ;; Disable evil's hooks which reset current-input-method in favor of evil-input-method before the evil minor mode has been loaded.
(set-input-method "Agda")))
(add-hook 'agda2-mode-hook 'set-agda-input-method) |
This works for me! Thank you so much. 😃 GNU Emacs 28.1 |
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]: agda/agda#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
Unicode input does not work in normalisation (via C-c C-n) or typechecking (C-c C-d) when using evil-mode.
To demonstrate this, install agda-mode and evil-mode, require evil-mode and load-file agda-mode, then open an Agda source file where you M-x evil-mode, and try to C-c C-n with e.g. '\bn'. Spoiler alert: you'll end up typing literally '\bn'.
The text was updated successfully, but these errors were encountered: