From 49f2811f7827142fd5dcd6c4a53fd7c0c700054f Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 13 Apr 2020 11:43:39 +0300 Subject: [PATCH] Improve support of "Re:" in Rmail * lisp/mail/rmail.el (rmail-simplified-subject) (rmail-reply-regexp): Recognize U+FF1A FULLWIDTH COLON as a colon after "Re:"-type prefixes. (rmail-re-abbrevs): New defcustom with localized abbreviations of "Re:". (rmail-reply-regexp): Use 'rmail-re-abbrevs'. Recognize U+FF1A in addition to the ASCII colon. * etc/NEWS: Call out the new defcustom 'rmail-re-abbrevs'. --- etc/NEWS | 7 +++++++ lisp/mail/rmail.el | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 7a7f11f5071..9f3e5b650b5 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -275,6 +275,13 @@ The new default value is 2000000 (2 megabytes). *** New customizable option 'texinfo-texi2dvi-options'. This is used when invoking 'texi2dvi' from 'texinfo-tex-buffer'. +** Rmail + +--- +*** New customizable option 'rmail-re-abbrevs'. +Its default value matches localized abbreviations of the "reply" +prefix on the Subject line in various languages. + * New Modes and Packages in Emacs 28.1 diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el index d79cea987e9..6c9847304fd 100644 --- a/lisp/mail/rmail.el +++ b/lisp/mail/rmail.el @@ -578,11 +578,21 @@ Examples: (defvar rmail-reply-prefix "Re: " "String to prepend to Subject line when replying to a message.") +;; Note: this is matched with case-fold-search bound to t. +(defcustom rmail-re-abbrevs + "\\(RE\\|رد\\|回复\\|回覆\\|SV\\|Antw\\|VS\\|REF\\|AW\\|ΑΠ\\|ΣΧΕΤ\\|השב\\|Vá\\|R\\|RIF\\|BLS\\|RES\\|Odp\\|YNT\\|ATB\\)" + "Regexp with localized 'Re:' abbreviations in various languages." + :version "28.1" + :type 'regexp) + ;; Some mailers use "Re(2):" or "Re^2:" or "Re: Re:" or "Re[2]:". ;; This pattern should catch all the common variants. ;; rms: I deleted the change to delete tags in square brackets ;; because they mess up RT tags. -(defvar rmail-reply-regexp "\\`\\(Re\\(([0-9]+)\\|\\[[0-9]+\\]\\|\\^[0-9]+\\)?: *\\)*" +(defvar rmail-reply-regexp + (concat "\\`\\(" + rmail-re-abbrevs + "\\(([0-9]+)\\|\\[[0-9]+\\]\\|\\^[0-9]+\\)?[::] *\\)*") "Regexp to delete from Subject line before inserting `rmail-reply-prefix'.") (defcustom rmail-display-summary nil @@ -3398,7 +3408,7 @@ whitespace, replacing whitespace runs with a single space and removing prefixes such as Re:, Fwd: and so on and mailing list tags such as [tag]." (let ((subject (or (rmail-get-header "Subject" msgnum) "")) - (regexp "\\`[ \t\n]*\\(\\(\\w\\{1,3\\}:\\|\\[[^]]+]\\)[ \t\n]+\\)*")) + (regexp "\\`[ \t\n]*\\(\\(\\w\\{1,3\\}[::]\\|\\[[^]]+]\\)[ \t\n]+\\)*")) (setq subject (rfc2047-decode-string subject)) (setq subject (replace-regexp-in-string regexp "" subject)) (replace-regexp-in-string "[ \t\n]+" " " subject))) -- 2.39.2