diff options
| author | Robert Pluim | 2024-08-22 18:49:12 +0200 |
|---|---|---|
| committer | Robert Pluim | 2025-02-13 14:20:28 +0100 |
| commit | 315519fa7c8e5e142b6abca7b78a47ad3c0cbe37 (patch) | |
| tree | bf17655d2fdaf6c67a0f7f83364c0063271bfe89 | |
| parent | 2f8c2e64e03d85e2093b47e15aa35497054f922f (diff) | |
| download | emacs-315519fa7c8e5e142b6abca7b78a47ad3c0cbe37.tar.gz emacs-315519fa7c8e5e142b6abca7b78a47ad3c0cbe37.zip | |
Teach gnus/message about international Re: variants
* lisp/mail/mail-utils.el (mail-re-regexps): New defcustom,
contains the components used to construct 'rmail-re-abbrevs' and
'message-subject-re-regexp'.
* lisp/gnus/message.el (message-subject-re-regexp): Derive from
'mail-re-regexps'.
(message-strip-subject-re): Make the match case-insensitive.
* lisp/mail/rmail.el (rmail-re-abbrevs): Derive from
'mail-re-regexps'. Update 'rmail-reply-regexp' when it changes.
(rmail-reply-regexp): Set to nil, 'rmail-re-abbrevs' will set
it.
* doc/emacs/rmail.texi (Rmail Reply): Describe
'mail-re-regexps'.
* doc/misc/message.texi (Message Headers): Describe
'mail-re-regexps'.
(Bug#72442)
| -rw-r--r-- | doc/emacs/rmail.texi | 8 | ||||
| -rw-r--r-- | doc/misc/message.texi | 13 | ||||
| -rw-r--r-- | etc/NEWS | 26 | ||||
| -rw-r--r-- | lisp/gnus/message.el | 25 | ||||
| -rw-r--r-- | lisp/mail/mail-utils.el | 31 | ||||
| -rw-r--r-- | lisp/mail/rmail.el | 27 |
6 files changed, 111 insertions, 19 deletions
diff --git a/doc/emacs/rmail.texi b/doc/emacs/rmail.texi index 402386684ae..7a2ef9be16e 100644 --- a/doc/emacs/rmail.texi +++ b/doc/emacs/rmail.texi | |||
| @@ -776,6 +776,14 @@ to. The @samp{To} field starts out as the address of the person who | |||
| 776 | sent the message you received, and the @samp{CC} field starts out with | 776 | sent the message you received, and the @samp{CC} field starts out with |
| 777 | all the other recipients of that message. | 777 | all the other recipients of that message. |
| 778 | 778 | ||
| 779 | @vindex rmail-re-abbrevs | ||
| 780 | @vindex rmail-reply-prefix | ||
| 781 | @vindex mail-re-regexps | ||
| 782 | The @samp{Subject} header field may contain one or more instances of | ||
| 783 | @samp{Re:} or localized variants thereof. These are removed if they | ||
| 784 | match @code{rmail-re-abbrevs} (which is initialized from | ||
| 785 | @code{mail-re-regexps}), and @code{rmail-reply-prefix} is prepended. | ||
| 786 | |||
| 779 | @vindex mail-dont-reply-to-names | 787 | @vindex mail-dont-reply-to-names |
| 780 | You can exclude certain recipients from being included automatically | 788 | You can exclude certain recipients from being included automatically |
| 781 | in replies, using the variable @code{mail-dont-reply-to-names}. Its | 789 | in replies, using the variable @code{mail-dont-reply-to-names}. Its |
diff --git a/doc/misc/message.texi b/doc/misc/message.texi index 48ac487088e..418eb14e042 100644 --- a/doc/misc/message.texi +++ b/doc/misc/message.texi | |||
| @@ -1688,13 +1688,14 @@ result is inserted. | |||
| 1688 | 1688 | ||
| 1689 | @item message-subject-re-regexp | 1689 | @item message-subject-re-regexp |
| 1690 | @vindex message-subject-re-regexp | 1690 | @vindex message-subject-re-regexp |
| 1691 | @vindex mail-re-regexps | ||
| 1691 | @cindex Aw | 1692 | @cindex Aw |
| 1692 | @cindex Sv | 1693 | @cindex Sv |
| 1693 | @cindex Re | 1694 | @cindex Re |
| 1694 | Responses to messages have subjects that start with @samp{Re: }. This | 1695 | Responses to messages have subjects that start with @samp{Re: }. This |
| 1695 | is @emph{not} an abbreviation of the English word ``response'', but it | 1696 | is @emph{not} an abbreviation of the English word ``response'', but it |
| 1696 | comes from the Latin ``res'', and means ``in the matter of''. Some | 1697 | comes from the Latin ``res'', and means ``in the matter of''. Some |
| 1697 | illiterate nincompoops have failed to grasp this fact, and have | 1698 | standards-challenged companies have failed to grasp this fact, and have |
| 1698 | ``internationalized'' their software to use abominations like | 1699 | ``internationalized'' their software to use abominations like |
| 1699 | @samp{Aw: } (``antwort'') or @samp{Sv: } (``svar'') instead, which is | 1700 | @samp{Aw: } (``antwort'') or @samp{Sv: } (``svar'') instead, which is |
| 1700 | meaningless and evil. However, you may have to deal with users that | 1701 | meaningless and evil. However, you may have to deal with users that |
| @@ -1726,6 +1727,16 @@ responding to a message: | |||
| 1726 | )) | 1727 | )) |
| 1727 | @end lisp | 1728 | @end lisp |
| 1728 | 1729 | ||
| 1730 | You shouldn't need to do this, since the default value of | ||
| 1731 | @code{message-subject-re-regexp} is initialized based on | ||
| 1732 | @code{mail-re-regexps}, which covers most known cases of such | ||
| 1733 | internationalization, and is a lot easier to customize. Customizing | ||
| 1734 | @code{mail-re-regexps} updates @code{message-subject-re-regexp} to | ||
| 1735 | match. | ||
| 1736 | |||
| 1737 | Note that the regexp is matched case-insensitively against the | ||
| 1738 | @samp{Subject} header contents. | ||
| 1739 | |||
| 1729 | @item message-subject-trailing-was-query | 1740 | @item message-subject-trailing-was-query |
| 1730 | @vindex message-subject-trailing-was-query | 1741 | @vindex message-subject-trailing-was-query |
| 1731 | @vindex message-subject-trailing-was-ask-regexp | 1742 | @vindex message-subject-trailing-was-ask-regexp |
| @@ -660,6 +660,32 @@ only search in input history. If you customize it to the symbol 'dwim', | |||
| 660 | those commands search in input history only when the point is after the | 660 | those commands search in input history only when the point is after the |
| 661 | last prompt. | 661 | last prompt. |
| 662 | 662 | ||
| 663 | +++ | ||
| 664 | ** Mail-util | ||
| 665 | |||
| 666 | *** New user option 'mail-re-regexps'. | ||
| 667 | This contains the list of regular expressions used to match "Re:" and | ||
| 668 | international variants of it when modifying the Subject field in | ||
| 669 | replies. | ||
| 670 | |||
| 671 | +++ | ||
| 672 | ** Rmail | ||
| 673 | |||
| 674 | *** 'rmail-re-abbrevs' default value is now derived from 'mail-re-regexps'. | ||
| 675 | 'mail-re-regexps' is a new user option that is easier to customize than | ||
| 676 | 'rmail-re-abbrevs'. 'rmail-re-abbrevs' is still honored if it was | ||
| 677 | already set. | ||
| 678 | |||
| 679 | +++ | ||
| 680 | ** Message | ||
| 681 | |||
| 682 | *** 'message-subject-re-regexp' default value is now derived from 'mail-re-regexps'. | ||
| 683 | 'mail-re-regexps' is a new user option that is easier to customize than | ||
| 684 | 'message-subject-re-regexp'. 'message-subject-re-regexp' is still | ||
| 685 | honored if it was already set. | ||
| 686 | |||
| 687 | *** 'message-strip-subject-re' now matches case-insensitively. | ||
| 688 | |||
| 663 | ** SHR | 689 | ** SHR |
| 664 | 690 | ||
| 665 | +++ | 691 | +++ |
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index 1d035220bba..dede5520d66 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el | |||
| @@ -312,11 +312,20 @@ any confusion." | |||
| 312 | regexp)) | 312 | regexp)) |
| 313 | 313 | ||
| 314 | (defcustom message-subject-re-regexp | 314 | (defcustom message-subject-re-regexp |
| 315 | "^[ \t]*\\([Rr][Ee]\\(\\[[0-9]*\\]\\)* ?:[ \t]*\\)*[ \t]*" | 315 | (mail--wrap-re-regexp |
| 316 | "Regexp matching \"Re: \" in the subject line." | 316 | (concat |
| 317 | "\\(" | ||
| 318 | (string-join mail-re-regexps "\\|") | ||
| 319 | "\\)")) | ||
| 320 | "Regexp matching \"Re: \" in the subject line. | ||
| 321 | Matching is done case-insensitively. | ||
| 322 | Initialized from the value of `mail-re-regexps', which is easier to | ||
| 323 | customize." | ||
| 317 | :group 'message-various | 324 | :group 'message-various |
| 318 | :link '(custom-manual "(message)Message Headers") | 325 | :link '(custom-manual "(message)Message Headers") |
| 319 | :type 'regexp) | 326 | :type 'regexp |
| 327 | :set-after '(mail-re-regexps) | ||
| 328 | :version "31.1") | ||
| 320 | 329 | ||
| 321 | (defcustom message-screenshot-command '("import" "png:-") | 330 | (defcustom message-screenshot-command '("import" "png:-") |
| 322 | "Command to take a screenshot. | 331 | "Command to take a screenshot. |
| @@ -2264,10 +2273,12 @@ see `message-narrow-to-headers-or-head'." | |||
| 2264 | subject))) | 2273 | subject))) |
| 2265 | 2274 | ||
| 2266 | (defun message-strip-subject-re (subject) | 2275 | (defun message-strip-subject-re (subject) |
| 2267 | "Remove \"Re:\" from subject lines in string SUBJECT." | 2276 | "Remove \"Re:\" from subject lines in string SUBJECT. |
| 2268 | (if (string-match message-subject-re-regexp subject) | 2277 | This uses `mail-re-regexps', matching is done case-insensitively." |
| 2269 | (substring subject (match-end 0)) | 2278 | (let ((case-fold-search t)) |
| 2270 | subject)) | 2279 | (if (string-match message-subject-re-regexp subject) |
| 2280 | (substring subject (match-end 0)) | ||
| 2281 | subject))) | ||
| 2271 | 2282 | ||
| 2272 | (defcustom message-replacement-char "." | 2283 | (defcustom message-replacement-char "." |
| 2273 | "Replacement character used instead of unprintable or not decodable chars." | 2284 | "Replacement character used instead of unprintable or not decodable chars." |
diff --git a/lisp/mail/mail-utils.el b/lisp/mail/mail-utils.el index f8474da8f6d..5ddcb4b7686 100644 --- a/lisp/mail/mail-utils.el +++ b/lisp/mail/mail-utils.el | |||
| @@ -46,6 +46,37 @@ also the To field, unless this would leave an empty To field." | |||
| 46 | :type '(choice regexp (const :tag "Your Name" nil)) | 46 | :type '(choice regexp (const :tag "Your Name" nil)) |
| 47 | :group 'mail) | 47 | :group 'mail) |
| 48 | 48 | ||
| 49 | (defun mail--wrap-re-regexp (re) | ||
| 50 | (concat "\\`[ \t]*" | ||
| 51 | "\\(" | ||
| 52 | re | ||
| 53 | ; Re(1) or Re[1] or Re^1 | ||
| 54 | "\\(([0-9]+)\\|\\[[0-9]+\\]\\|\\^[0-9]+\\)?" | ||
| 55 | ; SPC/NBSP followed by colon and TAB/SPC | ||
| 56 | " ?\u00a0*[::][ \t]*" | ||
| 57 | ; Handle repetition, eg "Re[1]: Re[2]:" | ||
| 58 | "\\)*" | ||
| 59 | "[ \t]*")) | ||
| 60 | |||
| 61 | ;;;###autoload | ||
| 62 | (defcustom mail-re-regexps | ||
| 63 | '("RE" "R\u00c9\\.?" "FWD?" "رد" "回复" "回覆" "SV" "Antw\\.?" | ||
| 64 | "VS" "REF" "AW" "ΑΠ" "ΣΧΕΤ" "השב" "Vá" "R" "RIF" "BLS" "RES" | ||
| 65 | "Odp" "YNT" "ATB") | ||
| 66 | "List of localized \"Re:\" abbreviations in various languages. | ||
| 67 | Each component can be a regular expression or a simple string. Matching | ||
| 68 | is done case-insensitively. Used to initialize the legacy | ||
| 69 | `rmail-re-abbrevs' and `message-subject-re-regexp' user options." | ||
| 70 | :type '(repeat regexp) | ||
| 71 | :set (lambda (sym val) | ||
| 72 | (custom-set-default sym val) | ||
| 73 | (dolist (sym '(rmail-re-abbrevs | ||
| 74 | message-subject-re-regexp)) | ||
| 75 | (when (get sym 'standard-value) | ||
| 76 | (custom-reevaluate-setting sym)))) | ||
| 77 | :group 'mail | ||
| 78 | :version "31.1") | ||
| 79 | |||
| 49 | (defvar epa-inhibit) | 80 | (defvar epa-inhibit) |
| 50 | ;; Returns t if file FILE is an Rmail file. | 81 | ;; Returns t if file FILE is an Rmail file. |
| 51 | ;;;###autoload | 82 | ;;;###autoload |
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el index 44b49293d08..4b93f379c72 100644 --- a/lisp/mail/rmail.el +++ b/lisp/mail/rmail.el | |||
| @@ -525,22 +525,27 @@ Examples: | |||
| 525 | (defvar rmail-reply-prefix "Re: " | 525 | (defvar rmail-reply-prefix "Re: " |
| 526 | "String to prepend to Subject line when replying to a message.") | 526 | "String to prepend to Subject line when replying to a message.") |
| 527 | 527 | ||
| 528 | ;; Note: this is matched with case-fold-search bound to t. | 528 | (defvar rmail-reply-regexp nil ;; set by `rmail-re-abbrevs |
| 529 | (defcustom rmail-re-abbrevs | 529 | "Regexp to delete from Subject line before inserting `rmail-reply-prefix'.") |
| 530 | "\\(RE\\|رد\\|回复\\|回覆\\|SV\\|Antw\\|VS\\|REF\\|AW\\|ΑΠ\\|ΣΧΕΤ\\|השב\\|Vá\\|R\\|RIF\\|BLS\\|RES\\|Odp\\|YNT\\|ATB\\)" | ||
| 531 | "Regexp with localized \"Re:\" abbreviations in various languages." | ||
| 532 | :version "28.1" | ||
| 533 | :type 'regexp) | ||
| 534 | 530 | ||
| 535 | ;; Some mailers use "Re(2):" or "Re^2:" or "Re: Re:" or "Re[2]:". | 531 | ;; Some mailers use "Re(2):" or "Re^2:" or "Re: Re:" or "Re[2]:". |
| 536 | ;; This pattern should catch all the common variants. | 532 | ;; This pattern should catch all the common variants. |
| 537 | ;; rms: I deleted the change to delete tags in square brackets | 533 | ;; rms: I deleted the change to delete tags in square brackets |
| 538 | ;; because they mess up RT tags. | 534 | ;; because they mess up RT tags. |
| 539 | (defvar rmail-reply-regexp | 535 | ;; Note: this is matched with case-fold-search bound to t. |
| 540 | (concat "\\`\\(" | 536 | (defcustom rmail-re-abbrevs |
| 541 | rmail-re-abbrevs | 537 | (concat "\\(" |
| 542 | "\\(([0-9]+)\\|\\[[0-9]+\\]\\|\\^[0-9]+\\)?\u00a0*[::] *\\)*") | 538 | (string-join mail-re-regexps "\\|") |
| 543 | "Regexp to delete from Subject line before inserting `rmail-reply-prefix'.") | 539 | "\\)") |
| 540 | "Regexp with localized \"Re:\" abbreviations in various languages. | ||
| 541 | Matching is done case-insensitively. | ||
| 542 | Initialized from `mail-re-regexps', which is easier to customize." | ||
| 543 | :set-after '(mail-re-regexps) | ||
| 544 | :set (lambda (sym val) | ||
| 545 | (custom-set-default sym val) | ||
| 546 | (setq rmail-reply-regexp (mail--wrap-re-regexp val))) | ||
| 547 | :type 'regexp | ||
| 548 | :version "31.1") | ||
| 544 | 549 | ||
| 545 | (defcustom rmail-display-summary nil | 550 | (defcustom rmail-display-summary nil |
| 546 | "If non-nil, Rmail always displays the summary buffer." | 551 | "If non-nil, Rmail always displays the summary buffer." |