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

How to temporarily disable Org-Msg for other functions (e.g. gnus-icalendar) #136

Open morganwillcock opened 2 years ago

morganwillcock commented 2 years ago

As an example of where Org-Msg being enabled causes a problem, there is some built-in functionality of Gnus which can handle calendar appointments by constructing the appointment responses and sending them on behalf of the user (see function gnus-icalendar-send-buffer-by-mail and note how the regular mail signature is suppressed). I believe the appointment handling in mu4e also just wraps the Gnus code.

I imagine it would be possible to add advice to these functions to check that Org-Msg is enabled, disable it, and then re-enable it again afterwards, but is that the only/best way to do it? Or possibly this particular feature and issue is within scope for Org-Msg to set the advice directly?

morganwillcock commented 2 years ago

I'm using this for the moment:

(defun mw/call-without-org-msg-mode (orig-fun &rest args)
  (let ((was-active org-msg-mode))
    (when was-active
      (org-msg-mode -1))
    (prog1
        (apply orig-fun args)
      (when was-active
        (org-msg-mode 1)))))

(require 'gnus-icalendar)
(advice-add 'gnus-icalendar-send-buffer-by-mail
            :around #'mw/call-without-org-msg-mode)

Since this is solving a problem which potentially exists for all of the mail user agents (Gnus and mu4e are affected for sure) perhaps it would be acceptable to include the workaround in the package itself, or at least document it. Possibly there is a better way to temporarily toggle a mode but I couldn't find one when searching.

jeremy-compostella commented 2 years ago

Thanks for the suggestion, I have integrated it.

morganwillcock commented 2 years ago

Thanks!

I'm not sure whether to leave this issue open with the question of how to temporarily disable Org-Msg in more general cases or whether that is out of scope. I'll leave it to your judgement, either way is fine by me.

johnhamelink commented 2 years ago

This doesn't work for me, but #149 does work

jumper047 commented 2 years ago

BTW, I wonder if there are other mail clients also have icalendar integration and needed same fixes for them.