Skip to content
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

Wrong cursor position after reply — missing call to goto-body #167

Open
david-alvarez-rosa opened this issue Jun 1, 2023 · 1 comment

Comments

@david-alvarez-rosa
Copy link

When using mu4e and just after hitting R for replying to an email the cursor position is just after the "text follows this line" message:

--text follows this line--
[cursor] #+OPTIONS: html-postamble:nil num:nil ^:{} toc:nil author:nil email:nil tex:dvipng d:nil
#+STARTUP: 
:PROPERTIES:
:reply-to: ("/var/folders/vv/v20qymzd6xs88lycdmdw63ww0000gr/T/mm-LxlqRs.html")
:attachment: nil
:alternatives: (text html)
:END:

Hitting C-c C-b for org-msg-goto-body works as expected:

--text follows this line--
#+OPTIONS: html-postamble:nil num:nil ^:{} toc:nil author:nil email:nil tex:dvipng d:nil
#+STARTUP: 
:PROPERTIES:
:reply-to: ("/var/folders/vv/v20qymzd6xs88lycdmdw63ww0000gr/T/mm-LxlqRs.html")
:attachment: nil
:alternatives: (text html)
:END:
[cursor]

I'm suspecting a missing call to org-msg-goto-body, but from the code I see that it's where it should. Any ideas how this can be fixed?

Thank you in advance!

@wangwb98
Copy link

wangwb98 commented May 18, 2024

I had same question, and after check mu4e code, I realized it's related to mu4e~compose-handler's implementation.
That function will first call mu4e-compose-mode to change the major mode, thus its mode hook (mu4e-compose-mode-hook) will invoke org-msg-post-setup, which will use org-msg-goto-body.
But, after all those things done, mu4e~compose-handler still has something to do, which includes jumping to "to" or mail body. This jump override the effect of org-msg-goto-body.

My temporary solution is like below, to go to body again, by adding advice to mu4e-display-buffer. You may have a try to see if it solved your problem as well.

(defun my-goto-body-before-display (buffer-or-name &optional select)
  "Replace message-goto-body with org-msg-goto-body"
  (if (derived-mode-p 'org-msg-edit-mode)
      (if (org-msg-message-fetch-field "to")
          (org-msg-goto-body)
        (message-goto-to))))
(advice-add 'mu4e-display-buffer :before #'my-goto-body-before-display)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants