Skip to content

Commit

Permalink
gnus-icalendar action compatibility
Browse files Browse the repository at this point in the history
Highly inspired from a suggestion from Morgan Willcock in #136.

Suggested-by: Morgan Willcock
Signed-off-by: Jeremy Compostella <[email protected]>
  • Loading branch information
jeremy-compostella committed Mar 31, 2022
1 parent 94e4f66 commit c6c9475
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions org-msg.el
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
(require 'gnus-art)
(require 'gnus-cite)
(require 'gnus-dired)
(require 'gnus-icalendar)
(require 'gnus-msg)
(require 'htmlize)
(require 'message)
Expand Down Expand Up @@ -1400,14 +1401,27 @@ This function is used as an advice function of
(advice-add 'message-mail :after #'org-msg-post-setup)
(advice-remove 'message-mail #'org-msg-post-setup)))

(defun org-msg-inhibited (orig-fun &rest args)
"Call ORIG-FUN with OrgMsg mode disabled."
(let ((enable org-msg-mode))
(when enable
(org-msg-mode 0))
(prog1
(apply orig-fun args)
(when enable
(org-msg-mode 1)))))

(defun org-msg-mode-gnus ()
"Setup the hook for gnus mail user agent."
(if org-msg-mode
(progn
(add-hook 'gnus-message-setup-hook 'org-msg-post-setup)
(add-hook 'gnus-message-setup-hook 'org-msg-store-mml-buffers))
(add-hook 'gnus-message-setup-hook 'org-msg-store-mml-buffers)
(advice-add 'gnus-icalendar-send-buffer-by-mail
:around #'org-msg-inhibited))
(remove-hook 'gnus-message-setup-hook 'org-msg-post-setup)
(remove-hook 'gnus-message-setup-hook 'org-msg-store-mml-buffers)))
(remove-hook 'gnus-message-setup-hook 'org-msg-store-mml-buffers)
(advice-remove 'gnus-icalendar-send-buffer-by-mail 'org-msg-inhibited)))

(defun org-msg-mode-mu4e ()
"Setup the hook for mu4e mail user agent."
Expand Down

0 comments on commit c6c9475

Please sign in to comment.