diff --git a/.emacs.d/lisp/init-message.el b/.emacs.d/lisp/init-message.el index 39bb5d66..39a67b5b 100644 --- a/.emacs.d/lisp/init-message.el +++ b/.emacs.d/lisp/init-message.el @@ -20,7 +20,7 @@ ;; https://old.reddit.com/r/emacs/comments/5iievm/nice_email_configuration_using_emacs_mbsync/ -(defun message-recipients (&optional include-from) +(defun ambrevar/message-recipients (&optional include-from) "Return a list of all recipients in the message, looking at TO, CC and BCC. Each recipient is in the format of `mail-extract-address-components'." @@ -50,20 +50,20 @@ Trust is defined as per `ambrevar/trust-threshold'." (push (cadr (mail-extract-address-components (epg-user-id-string user-id))) valid-addresses)))))) -(defun message-sign-encrypt-if-all-keys-trusted () +(defun ambrevar/message-sign-encrypt-if-all-keys-trusted () "Add MML tag to encrypt message when there is a key for each recipient. Consider adding this function to `message-send-hook' to systematically send encrypted emails when possible." - (let* ((recipients (message-recipients)) - (untrusted-recipients (seq-difference recipients (ambrevar/trusted-addresses)))) - (unless untrusted-recipients - (mml-secure-message-sign-encrypt) - ;; (warn "Not encrypting because of untrusted %s" untrusted-recipients) - ))) + (let* ((recipients (ambrevar/message-recipients)) + (untrusted-recipients (seq-difference (mapcar #'cadr recipients) + (ambrevar/trusted-addresses)))) + (if untrusted-recipients + (warn "Not encrypting because of untrusted %s." untrusted-recipients) + (mml-secure-message-sign-encrypt)))) ;; TODO: Test and report upstream (Emacs + Notmuch). -(add-hook 'message-send-hook #'message-sign-encrypt-if-all-keys-trusted) +(add-hook 'message-send-hook #'ambrevar/message-sign-encrypt-if-all-keys-trusted) ;; Fix replying to GitHub. TODO: Does not work. @@ -101,7 +101,7 @@ A fortune is appended if `ambrevar/message-compose-fortune-p' is non-nil." "Set dictionary according to the LANGUAGE property of the first \"To:\" recipient found in the Org contacts file." (interactive) - (let ((addresses (mapcar 'cadr (message-recipients))) + (let ((addresses (mapcar 'cadr (ambrevar/message-recipients))) address-lang-map) (setq address-lang-map (cl-loop for contact in (org-contacts-filter) @@ -141,7 +141,7 @@ A fortune is appended if `ambrevar/message-compose-fortune-p' is non-nil." return buffer))) (save-window-excursion (with-current-buffer last-buffer - (let* ((recipients (message-recipients 'include-from)) + (let* ((recipients (ambrevar/message-recipients 'include-from)) (addresses-names (mapcar (lambda (s) (concat (cadr s) " " (car s)))