From 38a716559183f5eb8b20ea58275cacf90d8b7ab2 Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Sat, 12 Feb 2011 16:45:42 -0500 Subject: [PATCH] Make rmail-default-dont-reply-to-names nil (Bug#7888); rename rmail-dont-reply-*. * lisp/mail/mail-utils.el (mail-dont-reply-to-names): New variable, from rmail-dont-reply-to-names. Callers changed. (mail-dont-reply-to): Rename from mail-dont-reply-to. (rmail-dont-reply-to): Make it an obsolete alias. * lisp/mail/rmail.el (rmail-default-dont-reply-to-names): Default to nil, and make obsolete. (rmail-dont-reply-to-names): Alias to mail-dont-reply-to-names. * lisp/mail/rmailsum.el (rmail-summary-sort-by-correspondent): Doc fix. * lisp/mail/rmailsort.el (rmail-sort-by-correspondent) (rmail-select-correspondent): Doc fix. Use mail-dont-reply-to. * lisp/mail/rmail.el (rmail-reply): Use mail-dont-reply-to. --- lisp/ChangeLog | 18 ++++++++++++ lisp/mail/mail-utils.el | 61 +++++++++++++++++++++++------------------ lisp/mail/rmail.el | 41 ++++++++++----------------- lisp/mail/rmailsort.el | 7 ++--- lisp/mail/rmailsum.el | 2 +- 5 files changed, 72 insertions(+), 57 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e80de4e9175..7cd39ae6d4b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,21 @@ +2011-02-12 Chong Yidong + + * mail/mail-utils.el (mail-dont-reply-to-names): New variable, + from rmail-dont-reply-to-names. Callers changed. + (mail-dont-reply-to): Rename from mail-dont-reply-to. + (rmail-dont-reply-to): Make it an obsolete alias. + + * mail/rmail.el (rmail-default-dont-reply-to-names): Default to + nil, and make obsolete (Bug#7888). + (rmail-dont-reply-to-names): Alias to mail-dont-reply-to-names. + + * mail/rmailsum.el (rmail-summary-sort-by-correspondent): Doc fix. + + * mail/rmailsort.el (rmail-sort-by-correspondent) + (rmail-select-correspondent): Doc fix. Use mail-dont-reply-to. + + * mail/rmail.el (rmail-reply): Use mail-dont-reply-to. + 2011-02-12 Thierry Volpiatto * files.el (copy-directory): New argument COPY-CONTENTS for diff --git a/lisp/mail/mail-utils.el b/lisp/mail/mail-utils.el index cb9ee7e0317..328a5d50d34 100644 --- a/lisp/mail/mail-utils.el +++ b/lisp/mail/mail-utils.el @@ -35,6 +35,17 @@ often correct parser." :type 'boolean :group 'mail) +;;;###autoload +(defcustom mail-dont-reply-to-names nil + "Regexp specifying addresses to prune from a reply message. +If this is nil, it is set the first time you compose a reply, to +a value which excludes your own email address. + +Matching addresses are excluded from the CC field in replies, and +also the To field, unless this would leave an empty To field." + :type '(choice regexp (const :tag "Your Name" nil)) + :group 'mail) + ;; Returns t if file FILE is an Rmail file. ;;;###autoload (defun mail-file-babyl-p (file) @@ -213,36 +224,31 @@ Return a modified address list." nil 'literal address 2))) address)))) -;; The following piece of ugliness is legacy code. The name was an -;; unfortunate choice --- a flagrant violation of the Emacs Lisp -;; coding conventions. `mail-dont-reply-to' would have been -;; infinitely better. Also, `rmail-dont-reply-to-names' might have -;; been better named `mail-dont-reply-to-names' and sourced from this -;; file instead of in rmail.el. Yuck. -pmr -(defun rmail-dont-reply-to (destinations) +(defun mail-dont-reply-to (destinations) "Prune addresses from DESTINATIONS, a list of recipient addresses. -All addresses matching `rmail-dont-reply-to-names' are removed from -the comma-separated list. The pruned list is returned." +Remove all addresses matching `mail-dont-reply-to-names' from the +comma-separated list, and return the pruned list." ;; FIXME this (setting a user option the first time a command is used) ;; is somewhat strange. Normally one would never set the option, ;; but instead fall back to the default so long as it was nil. ;; Or just set the default directly in the defcustom. - (if (null rmail-dont-reply-to-names) - (setq rmail-dont-reply-to-names - (concat (if rmail-default-dont-reply-to-names - (concat rmail-default-dont-reply-to-names "\\|") - "") - (if (and user-mail-address - (not (equal user-mail-address user-login-name))) - ;; Anchor the login name and email address so - ;; that we don't match substrings: if the - ;; login name is "foo", we shouldn't match - ;; "barfoo@baz.com". - (concat "\\`" - (regexp-quote user-mail-address) - "\\'\\|") - "") - (concat "\\`" (regexp-quote user-login-name) "@")))) + (if (null mail-dont-reply-to-names) + (setq mail-dont-reply-to-names + (concat + ;; `rmail-default-dont-reply-to-names' is obsolete. + (if rmail-default-dont-reply-to-names + (concat rmail-default-dont-reply-to-names "\\|") + "") + (if (and user-mail-address + (not (equal user-mail-address user-login-name))) + ;; Anchor the login name and email address so that we + ;; don't match substrings: if the login name is + ;; "foo", we shouldn't match "barfoo@baz.com". + (concat "\\`" + (regexp-quote user-mail-address) + "\\'\\|") + "") + (concat "\\`" (regexp-quote user-login-name) "@")))) ;; Split up DESTINATIONS and match each element separately. (let ((start-pos 0) (cur-pos 0) (case-fold-search t)) @@ -262,7 +268,7 @@ the comma-separated list. The pruned list is returned." (setq cur-pos start-pos))) (let* ((address (substring destinations start-pos cur-pos)) (naked-address (mail-strip-quoted-names address))) - (if (string-match rmail-dont-reply-to-names naked-address) + (if (string-match mail-dont-reply-to-names naked-address) (setq destinations (concat (substring destinations 0 start-pos) (and cur-pos (substring destinations (1+ cur-pos)))) @@ -278,6 +284,9 @@ the comma-separated list. The pruned list is returned." (substring destinations (match-end 0)) destinations)) +;; Legacy name +(define-obsolete-function-alias 'rmail-dont-reply-to 'mail-dont-reply-to "24.1") + ;;;###autoload (defun mail-fetch-field (field-name &optional last all list) diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el index 7e44ae22e1e..07f6920a128 100644 --- a/lisp/mail/rmail.el +++ b/lisp/mail/rmail.el @@ -191,7 +191,7 @@ please report it with \\[report-emacs-bug].") :group 'rmail-retrieve :type '(repeat (directory))) -(declare-function rmail-dont-reply-to "mail-utils" (destinations)) +(declare-function mail-dont-reply-to "mail-utils" (destinations)) (declare-function rmail-update-summary "rmailsum" (&rest ignore)) (defun rmail-probe (prog) @@ -283,26 +283,16 @@ Setting this variable has an effect only before reading a mail." :version "21.1") ;;;###autoload -(defcustom rmail-dont-reply-to-names nil - "A regexp specifying addresses to prune from a reply message. -If this is nil, it is set the first time you compose a reply, to -a value which excludes your own email address, plus whatever is -specified by `rmail-default-dont-reply-to-names'. - -Matching addresses are excluded from the CC field in replies, and -also the To field, unless this would leave an empty To field." - :type '(choice regexp (const :tag "Your Name" nil)) - :group 'rmail-reply) +(defvaralias 'rmail-dont-reply-to-names 'mail-dont-reply-to-names) ;;;###autoload -(defvar rmail-default-dont-reply-to-names (purecopy "\\`info-") - "Regexp specifying part of the default value of `rmail-dont-reply-to-names'. -This is used when the user does not set `rmail-dont-reply-to-names' -explicitly. (The other part of the default value is the user's -email address and name.) It is useful to set this variable in -the site customization file. The default value is conventionally -used for large mailing lists to broadcast announcements.") -;; Is it really useful to set this site-wide? +(defvar rmail-default-dont-reply-to-names nil + "Regexp specifying part of the default value of `mail-dont-reply-to-names'. +This is used when the user does not set `mail-dont-reply-to-names' +explicitly.") +;;;###autoload +(make-obsolete-variable 'rmail-default-dont-reply-to-names + 'mail-dont-reply-to-names "24.1") ;;;###autoload (defcustom rmail-ignored-headers @@ -3578,15 +3568,14 @@ use \\[mail-yank-original] to yank the original message into it." ;; Remove unwanted names from reply-to, since Mail-Followup-To ;; header causes all the names in it to wind up in reply-to, not ;; in cc. But if what's left is an empty list, use the original. - (let* ((reply-to-list (rmail-dont-reply-to reply-to))) + (let* ((reply-to-list (mail-dont-reply-to reply-to))) (if (string= reply-to-list "") reply-to reply-to-list)) subject (rmail-make-in-reply-to-field from date message-id) (if just-sender nil - ;; mail-strip-quoted-names is NOT necessary for rmail-dont-reply-to - ;; to do its job. - (let* ((cc-list (rmail-dont-reply-to + ;; `mail-dont-reply-to' doesn't need `mail-strip-quoted-names'. + (let* ((cc-list (mail-dont-reply-to (mail-strip-quoted-names (if (null cc) to (concat to ", " cc)))))) (if (string= cc-list "") nil cc-list))) @@ -4359,7 +4348,7 @@ This applies only to the current session. ;;;### (autoloads (rmail-sort-by-labels rmail-sort-by-lines rmail-sort-by-correspondent ;;;;;; rmail-sort-by-recipient rmail-sort-by-author rmail-sort-by-subject -;;;;;; rmail-sort-by-date) "rmailsort" "rmailsort.el" "f297fd33c8f7fa74baf16d2da99acb35") +;;;;;; rmail-sort-by-date) "rmailsort" "rmailsort.el" "ad1c98fe868c0e5804cf945d6c980d0b") ;;; Generated autoloads from rmailsort.el (autoload 'rmail-sort-by-date "rmailsort" "\ @@ -4393,7 +4382,7 @@ If prefix argument REVERSE is non-nil, sorts in reverse order. Sort messages of current Rmail buffer by other correspondent. This uses either the \"From\", \"Sender\", \"To\", or \"Apparently-To\" header, downcased. Uses the first header not -excluded by `rmail-dont-reply-to-names'. If prefix argument +excluded by `mail-dont-reply-to-names'. If prefix argument REVERSE is non-nil, sorts in reverse order. \(fn REVERSE)" t nil) @@ -4418,7 +4407,7 @@ If prefix argument REVERSE is non-nil, sorts in reverse order. ;;;### (autoloads (rmail-summary-by-senders rmail-summary-by-topic ;;;;;; rmail-summary-by-regexp rmail-summary-by-recipients rmail-summary-by-labels -;;;;;; rmail-summary) "rmailsum" "rmailsum.el" "adad96c9eb13cae4bae0769f731d8784") +;;;;;; rmail-summary) "rmailsum" "rmailsum.el" "3817e21639db697abe5832d3223ecfc2") ;;; Generated autoloads from rmailsum.el (autoload 'rmail-summary "rmailsum" "\ diff --git a/lisp/mail/rmailsort.el b/lisp/mail/rmailsort.el index c9942f9c2f9..d8b85ad688a 100644 --- a/lisp/mail/rmailsort.el +++ b/lisp/mail/rmailsort.el @@ -87,7 +87,7 @@ If prefix argument REVERSE is non-nil, sorts in reverse order." "Sort messages of current Rmail buffer by other correspondent. This uses either the \"From\", \"Sender\", \"To\", or \"Apparently-To\" header, downcased. Uses the first header not -excluded by `rmail-dont-reply-to-names'. If prefix argument +excluded by `mail-dont-reply-to-names'. If prefix argument REVERSE is non-nil, sorts in reverse order." (interactive "P") (rmail-sort-messages reverse @@ -98,13 +98,12 @@ REVERSE is non-nil, sorts in reverse order." '("From" "Sender" "To" "Apparently-To")))))) (defun rmail-select-correspondent (msg fields) - "Find the first header not excluded by `rmail-dont-reply-to-names'. + "Find the first header not excluded by `mail-dont-reply-to-names'. MSG is a message number. FIELDS is a list of header names." (let ((ans "")) (while (and fields (string= ans "")) (setq ans - ;; NB despite the name, this lives in mail-utils.el. - (rmail-dont-reply-to + (mail-dont-reply-to (mail-strip-quoted-names (or (rmail-get-header (car fields) msg) "")))) (setq fields (cdr fields))) diff --git a/lisp/mail/rmailsum.el b/lisp/mail/rmailsum.el index 1d5e062fe27..8e28201e31f 100644 --- a/lisp/mail/rmailsum.el +++ b/lisp/mail/rmailsum.el @@ -1796,7 +1796,7 @@ If prefix argument REVERSE is non-nil, sorts in reverse order." "Sort messages of current Rmail summary by other correspondent. This uses either the \"From\", \"Sender\", \"To\", or \"Apparently-To\" header, downcased. Uses the first header not -excluded by `rmail-dont-reply-to-names'. If prefix argument +excluded by `mail-dont-reply-to-names'. If prefix argument REVERSE is non-nil, sorts in reverse order." (interactive "P") (rmail-sort-from-summary (function rmail-sort-by-correspondent) reverse)) -- 2.39.5