diff options
author | JSDurand <mmemmew@gmail.com> | 2021-12-24 17:20:59 +0800 |
---|---|---|
committer | JSDurand <mmemmew@gmail.com> | 2021-12-24 17:20:59 +0800 |
commit | f1eb4870f65c9272004c494c1a85558f3af292d9 (patch) | |
tree | 196e78ed720d31d18ba339659d3f090508dddbe0 | |
parent | 4903e67192bed09685963452dce3c77f208faa79 (diff) |
gnus: choose an identity
* gnus-conf.el (mml-secure-openpgp-encrypt-to-self): Encrypt to
myself.
(gnus-ignored-from-addresses): New mail address.
(gnus-parameters): Random change.
(durand-identities, durand-choose-identity, message-mode-map): I have
multiple identities now, so it is important to choose the correct
identity to use.
-rw-r--r-- | gnus-conf.el | 73 |
1 files changed, 70 insertions, 3 deletions
diff --git a/gnus-conf.el b/gnus-conf.el index 7d0fa23..e9d6d9a 100644 --- a/gnus-conf.el +++ b/gnus-conf.el @@ -66,7 +66,9 @@ ;;; To be able to see the encrypted mails sent by me. -(setq mml-secure-openpgp-encrypt-to-self t) +(setq mml-secure-openpgp-encrypt-to-self + (list "mmemmew@gmail.com" + "durand@jsdurand.xyz")) ;;; mail aliases @@ -89,7 +91,10 @@ ;;; user settings -(setq gnus-ignored-from-addresses "mmemmew@gmail.com") +(setq gnus-ignored-from-addresses + (list + "mmemmew@gmail.com" + "durand@jsdurand.xyz")) (setq send-mail-function #'smtpmail-send-it) (setq smtpmail-smtp-user "durand@jsdurand.xyz") @@ -109,7 +114,7 @@ (setq gnus-parameters `((".*" (posting-style - (gcc "nnmaildir+private:Sent"))))) + (gcc "nnmaildir+gmail:Sent"))))) (require 'gnus-msg) @@ -132,6 +137,8 @@ ;;; Multiple SMTP servers +;;;; Set the correct server on sending mails + (defvar durand-smtp-servers nil "The list of SMTP servers that I use. Each server is a list of the form: @@ -200,6 +207,66 @@ USERNAME is used to look up passwords in ~/.authinfo.gpg.") (define-key message-mode-map (vector 3 3) #'durand-set-smtp-server-message-send-and-exit) +;;;; Choose the correct identity when entering message buffers + +(defvar durand-identities + (list + (list "mmew" "Durand <mmemmew@gmail.com>" "nnmaildir+gmail:Sent") + (list "durand" + "Durand <durand@jsdurand.xyz>" + "nnmaildir+durand:sent" "Durand")) + "The list of identities to choose. +Each element is of the form + +NICK ADDR GCC [SIG] + +NICK: The name to type to choose this identity. + +ADDR: The string that appears as the FROM field of the message. + +GCC: The string that appears as the GCC field of the message. + +SIG: Optionally include a signature.") + +(defun durand-choose-identity (&optional arg) + "Choose an identity when entering `message-mode'. +If ARG is non-nil, ask which identity to use. Otherwise use the +identity named durand." + (interactive "P") + (let* (choice + (identity-to-use + (cond + (arg + (setq choice + (completing-read + "Choose an identity: " durand-identities nil t)) + (alist-get choice durand-identities nil nil #'string=)) + ((alist-get + (setq choice "durand") + durand-identities nil nil #'string=)) + ((user-error "No identity crisis!")))) + (from (car identity-to-use)) + (gcc (cadr identity-to-use)) + (sig (caddr identity-to-use))) + (message-remove-header "From") + (message-remove-header "Gcc") + (message-add-header (format "From: %s" from)) + (message-add-header (format "Gcc: %s" gcc)) + ;; deal with signature + (cond + (sig + (save-excursion + (goto-char (point-max)) + (cond + ((re-search-backward "^-- $") + ;; found a pre-existing signature; let me update this. + (forward-line 1) + (delete-region (point) (point-max)))) + (insert sig)))) + (message "Chose %s as the identity now!" choice))) + +(define-key message-mode-map (vector 3 ?i) #'durand-choose-identity) + ;;; Call me an expert. (setq gnus-expert-user t) |