message: Fix message-recipients and file structure
parent
3645d66093
commit
01fcdc89b2
|
@ -15,14 +15,8 @@
|
||||||
;; Might not be necessary.
|
;; Might not be necessary.
|
||||||
;; message-alternative-emails
|
;; message-alternative-emails
|
||||||
|
|
||||||
;; Sign messages by default. TODO: Which method?
|
|
||||||
(add-hook 'message-setup-hook 'mml-secure-sign-pgpmime)
|
(defun message-recipients (&optional include-from)
|
||||||
;; (add-hook 'message-setup-hook 'mml-secure-message-sign-pgpmime)
|
|
||||||
|
|
||||||
;; Also crypt to self so that we can read sent e-mails.
|
|
||||||
(setq mml-secure-openpgp-encrypt-to-self t)
|
|
||||||
|
|
||||||
(defun message-recipients ()
|
|
||||||
"Return a list of all recipients in the message, looking at TO, CC and BCC.
|
"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'."
|
Each recipient is in the format of `mail-extract-address-components'."
|
||||||
|
@ -31,7 +25,15 @@ Each recipient is in the format of `mail-extract-address-components'."
|
||||||
(and
|
(and
|
||||||
header-value
|
header-value
|
||||||
(mail-extract-address-components header-value t))))
|
(mail-extract-address-components header-value t))))
|
||||||
'("To" "Cc" "Bcc")))
|
`(,@(when include-from '("From")) "To" "Cc" "Bcc")))
|
||||||
|
|
||||||
|
|
||||||
|
;; Sign messages by default. TODO: Which method?
|
||||||
|
(add-hook 'message-setup-hook 'mml-secure-sign-pgpmime)
|
||||||
|
;; (add-hook 'message-setup-hook 'mml-secure-message-sign-pgpmime)
|
||||||
|
|
||||||
|
;; Also crypt to self so that we can read sent e-mails.
|
||||||
|
(setq mml-secure-openpgp-encrypt-to-self t)
|
||||||
|
|
||||||
(defvar ambrevar/trust-threshold '(marignal full ultimate))
|
(defvar ambrevar/trust-threshold '(marignal full ultimate))
|
||||||
(defun ambrevar/trusted-addresses ()
|
(defun ambrevar/trusted-addresses ()
|
||||||
|
@ -51,13 +53,15 @@ Consider adding this function to `message-send-hook' to
|
||||||
systematically send encrypted emails when possible."
|
systematically send encrypted emails when possible."
|
||||||
(let* ((recipients (message-recipients))
|
(let* ((recipients (message-recipients))
|
||||||
(untrusted-recipients (seq-difference recipients (ambrevar/trusted-addresses))))
|
(untrusted-recipients (seq-difference recipients (ambrevar/trusted-addresses))))
|
||||||
(if untrusted-recipients
|
(unless untrusted-recipients
|
||||||
(warn "Not encrypting because of untrusted %s" untrusted-recipients)
|
(mml-secure-message-sign-encrypt)
|
||||||
(mml-secure-message-sign-encrypt))))
|
;; (warn "Not encrypting because of untrusted %s" untrusted-recipients)
|
||||||
|
)))
|
||||||
|
|
||||||
;; TODO: Test and report upstream (Emacs + Notmuch).
|
;; TODO: Test and report upstream (Emacs + Notmuch).
|
||||||
(add-hook 'message-send-hook #'message-sign-encrypt-if-all-keys-trusted)
|
(add-hook 'message-send-hook #'message-sign-encrypt-if-all-keys-trusted)
|
||||||
|
|
||||||
|
|
||||||
;; Fix replying to GitHub. TODO: Test!
|
;; Fix replying to GitHub. TODO: Test!
|
||||||
(defun ambrevar/message-alter-bogus-github-recipients (addrcell)
|
(defun ambrevar/message-alter-bogus-github-recipients (addrcell)
|
||||||
"Discard @reply.github.com mail addresses.
|
"Discard @reply.github.com mail addresses.
|
||||||
|
@ -68,22 +72,26 @@ cdr is the complete address (full name and mail address)."
|
||||||
addrcell))
|
addrcell))
|
||||||
(setq message-alter-recipients-function 'ambrevar/message-alter-bogus-github-recipients)
|
(setq message-alter-recipients-function 'ambrevar/message-alter-bogus-github-recipients)
|
||||||
|
|
||||||
(defvar ambrevar/mu4e-compose-fortune-p nil
|
|
||||||
|
(defvar ambrevar/message-compose-fortune-p nil
|
||||||
"Whether or not to include a fortune in the signature.")
|
"Whether or not to include a fortune in the signature.")
|
||||||
(defun ambrevar/mu4e-add-signature-and-maybe-fortune ()
|
(defun ambrevar/message-add-signature-and-maybe-fortune ()
|
||||||
"Insert signature using `user-full-name'.
|
"Insert signature using `user-full-name'.
|
||||||
A fortune is appended if `ambrevar/mu4e-compose-fortune-p' is non-nil."
|
A fortune is appended if `ambrevar/message-compose-fortune-p' is non-nil."
|
||||||
(require 'functions) ; For `call-process-to-string'.
|
(require 'functions) ; For `call-process-to-string'.
|
||||||
|
;; Return the signature and set it for mu4e.
|
||||||
(setq mu4e-compose-signature
|
(setq mu4e-compose-signature
|
||||||
(concat
|
(concat
|
||||||
user-full-name "\n"
|
user-full-name "\n"
|
||||||
"https://ambrevar.xyz/"
|
"https://ambrevar.xyz/"
|
||||||
(when (and ambrevar/mu4e-compose-fortune-p
|
(when (and ambrevar/message-compose-fortune-p
|
||||||
(executable-find "fortune"))
|
(executable-find "fortune"))
|
||||||
(concat "\n\n"
|
(concat "\n\n"
|
||||||
(ambrevar/call-process-to-string "fortune" "-s"))))))
|
(ambrevar/call-process-to-string "fortune" "-s"))))))
|
||||||
(add-hook 'message-setup-hook 'ambrevar/mu4e-add-signature-and-maybe-fortune)
|
;; (add-hook 'message-setup-hook 'ambrevar/message-add-signature-and-maybe-fortune)
|
||||||
|
(setq message-signature 'ambrevar/message-add-signature-and-maybe-fortune)
|
||||||
|
|
||||||
|
|
||||||
(defun ambrevar/mu4e-select-dictionary ()
|
(defun ambrevar/mu4e-select-dictionary ()
|
||||||
"Set dictionary according to the LANGUAGE property of the first
|
"Set dictionary according to the LANGUAGE property of the first
|
||||||
\"To:\" recipient found in the Org contacts file."
|
\"To:\" recipient found in the Org contacts file."
|
||||||
|
|
Loading…
Reference in New Issue