From 00191a3ec71d62d2537801f7dbebd8878552f4a5 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Sat, 28 Oct 2023 11:43:21 +0300 Subject: [PATCH] mu4e: improve mu4e-compose-dont-reply-to-self handling Use mu4e-personal-or-alternative-address to decide on whether an address belongs to "this user". Update docs. --- mu4e/mu4e-compose.el | 27 +++++++++------------------ mu4e/mu4e-contacts.el | 17 +++++++++++------ 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/mu4e/mu4e-compose.el b/mu4e/mu4e-compose.el index 1747f138..66f7a907 100644 --- a/mu4e/mu4e-compose.el +++ b/mu4e/mu4e-compose.el @@ -192,7 +192,11 @@ predicate function. A value of nil keeps all the addresses." (defcustom mu4e-compose-dont-reply-to-self nil "If non-nil, do not include self. -Selfness is decided by `mu4e-personal-address-p'" + +Whether a given address belongs to this user (the \"self\") is +determined by `mu4e-personal-or-alternative-address', which +overrides `message-dont-reply-to-names' when replying to +messages, if `mu4e-compose-dont-reply-to-self' is non-nil." :type 'boolean :group 'mu4e-compose) @@ -635,22 +639,6 @@ This function uses `message-cite-function', and its settings apply." (goto-char (point-min)) (buffer-string))) -(defun mu4e--address-blacklist () - "Get the list of addresses *not* to send mail to in wide-replies." - (let ((ignored mu4e-compose-reply-ignore-address) - (addrs (mu4e-personal-addresses)) - (is-rx (lambda (addr) (string-match-p "^/.*/" addr)))) - (when mu4e-compose-dont-reply-to-self - (setq ignored - (append ignored - (list - (regexp-opt - (seq-filter (lambda (addr) - (not (funcall is-rx addr))) addrs)) - (seq-filter (lambda (addr) - (funcall is-rx addr)) addrs))))) - (flatten-list ignored))) - (defvar mu4e-user-agent-string (format "mu4e %s; emacs %s" mu4e-mu-version emacs-version) "The User-Agent string for mu4e, or nil.") @@ -796,7 +784,10 @@ of message." (mu4e--compose-setup 'reply (lambda (parent) - (let ((message-dont-reply-to-names (mu4e--address-blacklist))) + (let ((message-dont-reply-to-names + (if mu4e-compose-dont-reply-to-self + message-dont-reply-to-names + #'mu4e-personal-or-alternative-address))) (message-reply nil wide) (insert (mu4e--compose-cite parent)))))) diff --git a/mu4e/mu4e-contacts.el b/mu4e/mu4e-contacts.el index 43562601..e8f957fe 100644 --- a/mu4e/mu4e-contacts.el +++ b/mu4e/mu4e-contacts.el @@ -124,9 +124,10 @@ predicate function. A value of nil keeps all the addresses." ;;; user mail address (defun mu4e-personal-addresses (&optional no-regexp) - "Get the list user's personal addresses, as passed to mu init. -The address are either plain e-mail address or /regular - expressions/. When NO-REGEXP is non-nil, do not include regexp + "Get the list user's personal addresses, as passed to \"mu init\". + +The address are either plain e-mail addresses or regexps (strings + wrapped / /). When NO-REGEXP is non-nil, do not include regexp address patterns (if any)." (seq-remove (lambda (addr) (and no-regexp (string-match-p "^/.*/" addr))) @@ -152,15 +153,19 @@ with both the plain addresses and /regular expressions/." "Return a function matching user's addresses. Function takes one parameter, an address. This glues mu4e's personal addresses together with gnus' -`message-alternative-emails'." - (let* ((alts message-alternative-emails)) +`message-alternative-emails'. + +Note that this expanded definition of user-addresses is only for the +message composition." + (let* ((alts message-alternative-emails)) (lambda (addr) (or (mu4e-personal-address-p addr) (cond ((functionp alts) (funcall alts addr)) - ((stringp alts) (string-match alts addr)) + ((stringp alts) (string-match alts addr)) (t nil)))))) + ;; Helpers