jeremy-compostella / org-msg

OrgMsg is a GNU/Emacs global minor mode mixing up Org mode and Message mode to compose and reply to emails in a Outlook HTML friendly style.
GNU General Public License v3.0
276 stars 57 forks source link

Duplicate headers with Helm-mu #105

Closed danielfleischer closed 3 years ago

danielfleischer commented 3 years ago

Using Helm-mu for address suggestion; once you choose an address you can compose an email to that contact. Once the composing buffer appears, there are 2 copies of the org headers, i.e. options and startup, each twice.

danielfleischer commented 3 years ago

Relevant config:

  (use-package helm-mu
    :ensure t
    :bind
    (("C-c h h c" . 'helm-mu-contacts)
     (:map mu4e-main-mode-map ("s" . 'helm-mu))
     (:map mu4e-headers-mode-map ("s" . 'helm-mu))
     (:map mu4e-view-mode-map ("s" . 'helm-mu)))
    :config
    (setq helm-mu-append-implicit-wildcard t
          helm-mu-gnu-sed-program "gsed"))
  (use-package org-msg
    :ensure t
    :config
    (setq org-msg-options "html-postamble:nil H:5 num:nil ^:{} toc:nil author:nil email:nil \\n:t tex:imagemagick"
          org-msg-startup "hidestars indent inlineimages"
          org-msg-default-alternatives '((new           . (html text))
                                         (reply-to-html . (html text))
                                         (reply-to-text . (text)))
          org-msg-convert-citation t)
    (org-msg-mode))
jeremy-compostella commented 3 years ago

I don't use the mu4e backend (I use the gnus backend). Therefore I can't debug it and you will have to do part of the job.

My guess is that because of your configuration, org-msg-post-setup gets called multiple times. However, org-msg-post-setup is supposed to be robust to multiple calls as it checks that the current major mode is not org-msg-edit-mode and once it is done initializing the buffer, it activates org-msg-edit-mode. I know that it works because under certain circonstances, gnus also calls org-msg-post-setup twice and I don't observe your "duplication" behavior.

danielfleischer commented 3 years ago

Helm-mu calls the following:

(defun helm-mu-compose-mail (candidate)
  "Compose a new email directed to the selected contacts."
  (mu4e~compose-mail (mapconcat 'helm-mu-format-contact
                                (helm-marked-candidates) ", "))
  (mu4e-compose-mode))

The first call sets the org-msg headers, sets the mode as org-msg-mode. Then calling the 2nd time, the mode is set back to mu4e-compose-mode, making org-msg insert headers again.

Looking at git blame, the 2nd line is there for users-defined hooks. I can remove it and the issue is solved but I don't know what are the possible consequences. Maybe I should take this to the helm-mu project.

jeremy-compostella commented 3 years ago

I don't get it. mu4e~compose-mail calls mu4e~compose-handler which call mu4e-compose-mode already. So the extra call to mu4e-compose-mode does not make sense to me.

I suggest that you take it to helm-mu project and see what they have to say.

danielfleischer commented 3 years ago

Ok, thanks for having a look.