Skip to content

Commit cc25647

Browse files
mu: support 1.12 with backward compatibility
mu keeps changing the prefix of their function breaking org-msg in the process. This should address issues #182 and #176. This commit introduces helper functions looking for the right function names as an attempt to support mu 1.12 while offering backward compatibility. Signed-off-by: Jeremy Compostella <[email protected]>
1 parent a425c02 commit cc25647

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

org-msg.el

+21-9
Original file line numberDiff line numberDiff line change
@@ -1481,35 +1481,47 @@ HTML emails."
14811481
nil)))
14821482
"Additional expressions to highlight in OrgMsg mode.")
14831483

1484+
(defun org-msg--mu4e-fun (name)
1485+
"Attempt to find the existing mu4e function suffixed with NAME."
1486+
(let ((funs (mapcar (lambda (prefix) (intern (concat prefix name)))
1487+
'("mu4e~" "mu4e-" "mu4e--"))))
1488+
(car (cl-member-if #'fboundp funs))))
1489+
1490+
(defun org-msg--mu4e-fun-call (name)
1491+
"Call the mu4e function suffixed with NAME if any."
1492+
(when-let ((fun (org-msg--mu4e-fun name)))
1493+
(funcall fun)))
1494+
14841495
(defun org-msg-edit-mode-mu4e ()
14851496
"Setup mu4e faces, addresses completion and run mu4e."
1486-
(mu4e~compose-remap-faces)
1497+
(org-msg--mu4e-fun-call "compose-remap-faces")
14871498
(unless (mu4e-running-p)
1488-
(if (fboundp #'mu4e~start) (mu4e~start) (mu4e--start)))
1499+
(org-msg--mu4e-fun-call "start"))
14891500
(when mu4e-compose-complete-addresses
1490-
(mu4e~compose-setup-completion))
1501+
(org-msg--mu4e-fun-call "compose-setup-completion"))
14911502
;; the following code is verbatim from mu4e-compose.el, `mu4e-compose-mode'
14921503
;; this will setup fcc (saving sent messages) and handle flags
14931504
;; (e.g. replied to)
14941505
(add-hook 'message-send-hook
1495-
(if (functionp #'mu4e~setup-fcc-message-sent-hook-fn)
1496-
#'mu4e~setup-fcc-message-sent-hook-fn
1506+
(if-let ((fun (org-msg--mu4e-fun "setup-fcc-message-sent-hook-fn")))
1507+
fun
14971508
(lambda ()
14981509
;; when in-reply-to was removed, remove references as well.
14991510
(when (eq mu4e-compose-type 'reply)
15001511
(mu4e~remove-refs-maybe))
15011512
(when use-hard-newlines
1502-
(mu4e-send-harden-newlines))
1513+
(org-msg--mu4e-fun-call "send-harden-newlines"))
15031514
;; for safety, always save the draft before sending
15041515
(set-buffer-modified-p t)
15051516
(save-buffer)
1506-
(mu4e~compose-setup-fcc-maybe)
1517+
(org-msg--mu4e-fun-call "compose-setup-fcc-maybe")
15071518
(widen)))
15081519
nil t)
15091520
;; when the message has been sent.
15101521
(add-hook 'message-sent-hook
1511-
(if (functionp #'mu4e~set-sent-handler-message-sent-hook-fn)
1512-
#'mu4e~set-sent-handler-message-sent-hook-fn
1522+
(if-let ((fun (org-msg--mu4e-fun
1523+
"set-sent-handler-message-sent-hook-fn")))
1524+
fun
15131525
(lambda ()
15141526
(setq mu4e-sent-func 'mu4e-sent-handler)
15151527
(mu4e~proc-sent (buffer-file-name))))

0 commit comments

Comments
 (0)