jmite · 2022-12-22 17:39
I'm trying to get emacs to automatically use the Agda input mode whenever I load an Agda file. I currently have the following in my config.el:
```elisp
(add-hook 'agda2-mode-hook
'(lambda ()
; If you do not want to use any input method:
(message "DEBUG setting Agda method")
(set-input-method 'Agda)
))
```
The `DEBUG` message appears in the Messages buffer, so the hook is running, but any time I open a new Agda file, the input mode is `nil`, and I have to manually call `set-input-method`.
Is this the wrong way to set the input method for a specific mode? If not, is there a way to debug this, so I can see why the input method isn't getting set, or if something is un-setting it?
ieure · 2022-12-22 18:03
Does your `SET-INPUT-METHOD` call work if you evaluate in the buffer after opening a file? (with `M-:`)
If you want to debug, turn the lambda into a function and update the hook to call it instead. Then use `C-u C-M-x` to instrument it, and you'll land in [edebug](https://www.gnu.org/software/emacs/manual/html_node/elisp/Edebug.html) where you can step through the function's expressions.
jmite · 2022-12-22 18:32
Yes it does work, which is doubly confusing.
I'm suspicious that the problem isn't the lambda, but something is being set/called after it.
bravosierrasierra · 2022-12-22 20:28
check agda2-mode-hook variable content: may be some other hook exists?
akirakom · 2022-12-23 00:04
I think the argument of `set-input-method` must be a string.
olikn · 2022-12-23 22:21
Are you using evil? Because it could be that same evil-hooks overwrite the input-method.
jmite · 2022-12-23 22:41
Hmm, that very well could be it. I'll look into this more
olikn · 2022-12-24 11:32
I had a similar issue, so I made a very dirty workaround and added a one time hook:
(defun ok/en-exit-hook() "Normal state exit hook."
(set-input-method "german-postfix")
(message "en-exit-hook - Buffer Name: %s. Input Method: %s"
(buffer-name) current-input-method)
(remove-hook 'evil-normal-state-exit-hook 'ok/en-exit-hook))
(add-hook 'evil-normal-state-exit-hook 'ok/en-exit-hook)
(defun ok/text-mode-h() "Text Mode hook."
(add-hook 'evil-normal-state-exit-hook 'ok/en-exit-hook)
(add-hook 'text-mode-hook 'ok/text-mode-h)
If you got a other solution, let me know.
ieure · 2022-12-25 18:34
- Check all the functions in `AGDA2-MODE-HOOK`.
- Use `DEBUG-ON-VARIABLE-CHANGE` to see if something else is changing `DEFAULT-INPUT-METHOD`.
- Try using edebug as I outlined above.