1

A recent update must have slipped my testing afterwords and now this hook mu4e-compose-mode-hook does not work anymore. On every new email I must set the input-method manually again.

Any ideas about how to fix this behaviour?

(add-hook 'mu4e-compose-mode-hook
          (lambda () (set-input-method "german-postfix")))

tried this snippet as well without success

  (add-hook 'mu4e-compose-mode-hook 'my-mu4e-mode-hook)
  (defun my-mu4e-mode-hook ()
    "Custom behaviours for `mu4e-compose-mode'."
    (activate-input-method "german-postfix"))

Notes

C-h v major-mode

  major-mode is a variable defined in ‘C source code’.

  Its value is ‘mu4e-compose-mode’
  Original value was ‘fundamental-mode’
  Local in buffer *draft*; global value is fundamental-mode

C-h v mu4e-compose-mode-hook

  mu4e-compose-mode-hook is a variable defined in ‘mu4e-compose.el’.

  Its value is
  ((lambda nil
    (use-hard-newlines t 'guess))
  my-mu4e-mode-hook)

M-x trace-function RET activate-input-method RET

  ======================================================================
  1 -> (activate-input-method "german-postfix")
  1 <- activate-input-method: nil

The moment I start composing the message / typing:

  ======================================================================
  1 -> (activate-input-method nil)
  1 <- activate-input-method: nil
  ======================================================================

M-x debug-on-entry RET activate-input-method RET

Initially:

Debugger entered--entering a function:
* activate-input-method("german-postfix")
  my-mu4e-mode-hook()
  run-hooks(change-major-mode-after-body-hook text-mode-hook message-mode-hook mu4e-compose-mode-hook)
  apply(run-hooks (change-major-mode-after-body-hook text-mode-hook message-mode-hook mu4e-compose-mode-hook))
  run-mode-hooks(mu4e-compose-mode-hook)
  mu4e-compose-mode()
  mu4e~compose-handler(new)
  mu4e-compose(new)
  mu4e-compose-new()
  funcall-interactively(mu4e-compose-new)
  call-interactively(mu4e-compose-new nil nil)
  command-execute(mu4e-compose-new)

Upon hitting i to insert text / compose message:

* activate-input-method(nil)
  evil-insert-state(1)
  evil-insert(1 nil nil)
  evil-append(1 nil)
  funcall-interactively(evil-append 1 nil)
  call-interactively(evil-append nil nil)
  command-execute(evil-append)
9
  • 1
    Does C-h v mu4e-compose-mode-hook show anything unexpected?
    – phils
    Mar 13, 2023 at 23:51
  • 1
    If the hook value looks good, I suggest running M-x trace-function RET activate-input-method RET and then composing a new message (untrace-function to remove). If there's an unexpected call, then use M-x debug-on-entry RET activate-input-method RET and find out where it's coming from (cancel-debug-on-entry to remove). See C-h i g (elisp)Debugger Commands for driving the debugger. Edit any relevant details into your question.
    – phils
    Mar 13, 2023 at 23:56
  • 1
    I strongly recommend NOT using the lambda approach in any case -- lambdas in hooks are a bad idea in general... they make the hook hard to inspect; the functions themselves can't be updated and are annoying to remove; and they can't be linked to the source code. Using named functions avoids all these issues.
    – phils
    Mar 14, 2023 at 0:12
  • Good updates. Your hook is clearly working, but something else deactivates the input method again afterwards, so it's that second call (activate-input-method nil) you want the debugger to tell you about. Check the debugger command documentation again, and use c to continue execution until you trigger the second call, and then show the backtrace for that.
    – phils
    Mar 14, 2023 at 10:44
  • Perfect, we can see clearly that it's evil-insert-state which is disabling the active input method. Why? I have no idea -- I don't use evil, so I'll leave it to someone who has that installed to provide an Answer for you -- but I think that's a very clear question now.
    – phils
    Mar 15, 2023 at 21:41

1 Answer 1

0
+50

Based on the comments, a successful workaround is to update your hook function so that it enables evil-insert-state first and then sets the input method:

(add-hook 'mu4e-compose-mode-hook 'my-mu4e-mode-hook)

(defun my-mu4e-mode-hook ()
  "Custom behaviours for `mu4e-compose-mode'."
  (evil-insert-state)
  (activate-input-method "german-postfix"))
1
  • @jjk Please make edits to this answer to add details/clarity as appropriate. I've used a slightly different approach to the code you added to your answer, which I would expect to be equivalent; but obviously I've not tested it.
    – phils
    Mar 17, 2023 at 12:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.