From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.bugs Subject: bug#72442: 31.0.50; Gnus or message.el doesn't handle international message reply subject prefixes and insults users Date: Tue, 27 Aug 2024 17:50:41 +0200 Message-ID: <875xrmvub2.fsf@gmail.com> References: <868qxdvchc.fsf@gnu.org> <861q35v80b.fsf@gnu.org> <87o75nv85p.fsf@gmail.com> <86ed6jwfkp.fsf@gnu.org> <87bk1nuwl3.fsf@gmail.com> <87jzg8u6tw.fsf@gmail.com> <86zfp4sqig.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36660"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 72442@debbugs.gnu.org, bjorn.bidar@thaodan.de To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Aug 27 17:52:28 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1siyUd-0009Fn-SV for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 27 Aug 2024 17:52:28 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1siyUO-0004qM-2H; Tue, 27 Aug 2024 11:52:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1siyUL-0004gw-OA for bug-gnu-emacs@gnu.org; Tue, 27 Aug 2024 11:52:09 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1siyUL-0005BJ-Dt for bug-gnu-emacs@gnu.org; Tue, 27 Aug 2024 11:52:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=y4BlHbw7Fa+RFJqYD1p6LhdBeNbazybPhYYdNAFk+/I=; b=u4bGZq7cCVrU8RygEQ5r6eh6hhHGlyRYzFp9Cv787jXRUv9cN3Bb2dQzD8ffcRDVisFXDzcCVp8D/FmZx2znuReDuW4Whb6KOVNU7A/MceymOdjVRAv25dnMcjCtX+7HgYwLqFm28G8LzTpP1Rn0DKWMCySV1hcxKQBwlV39fm9R2CTQYm+dGH4qIeCXU5Nj2WQUNdTRoNyhOVskDucgcQSV+uq1cHxPNzxeSLg0gjaMMJbMjjoAfIfDTgRQZr8NliPBqHfgYsu8Xsvq41ZD89P47eJ26a8oNUnrbOshFIHHVi6wqLLLHibnFJvyYURm/jmESavk65Qanr+5XPtiUA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1siyVC-0000FF-5A for bug-gnu-emacs@gnu.org; Tue, 27 Aug 2024 11:53:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Robert Pluim Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 27 Aug 2024 15:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72442 X-GNU-PR-Package: emacs Original-Received: via spool by 72442-submit@debbugs.gnu.org id=B72442.1724773966882 (code B ref 72442); Tue, 27 Aug 2024 15:53:02 +0000 Original-Received: (at 72442) by debbugs.gnu.org; 27 Aug 2024 15:52:46 +0000 Original-Received: from localhost ([127.0.0.1]:47224 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1siyUv-0000EA-Km for submit@debbugs.gnu.org; Tue, 27 Aug 2024 11:52:46 -0400 Original-Received: from mail-wr1-f47.google.com ([209.85.221.47]:47524) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1siyUt-0000De-Bn for 72442@debbugs.gnu.org; Tue, 27 Aug 2024 11:52:44 -0400 Original-Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-3718acbc87fso3166314f8f.3 for <72442@debbugs.gnu.org>; Tue, 27 Aug 2024 08:51:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724773844; x=1725378644; darn=debbugs.gnu.org; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=y4BlHbw7Fa+RFJqYD1p6LhdBeNbazybPhYYdNAFk+/I=; b=PanUtRUJivyMVtJ7RU0AfJ2Uk8xXmtgY6hmAzSV5rwXwSLOfc+zsm8ELcBlPaln1o+ UK0snTLhirZyDaeKUwGATePFMRGH7drxAlzYUPjntzWAhhpyZh2aOwjzn4XrH+ijpYfl QH5eieYbxJtLmX5alrnShop2qdRDgiYMV/NEOPuNrJUY9M2ODQ2QibtR/fwoq6DxG1eK 0JpHGff6c5llUSZuJKiKwec6Tc5ZjFxkpx2Gbq2uQaMF8XAXmCJK/z8uUk64UEG6pAa7 2kwwDe3zuOGzbRmHe2W1iwM7BWiTJSEBsRClKJDZ7K/OzzyktismblQdC1d/otZoLqcI MZXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724773844; x=1725378644; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=y4BlHbw7Fa+RFJqYD1p6LhdBeNbazybPhYYdNAFk+/I=; b=lBX6F7FlRNw+6wOGIM+LU3sW7JF6ku0EG/chp1617u//UhgC8im+0CFgX261ByVahK mt7XDa9YsFPjg1nLrg8k4nxwih7CamgCkgM2gFmpwOxsD2miEE9PX6rxQ6mDtOJUTrlv x0BxG7seTVuCCDQpWQ/MgvSlXpAiGxdcU+RVVmK4wAIxO8hUyMB0ywDosC66tor8+G03 Wsc0qSMdN8mDYQn3rbwizucDZFV/3ESdKz3qiTx+aA1c5sWi0rV+rAun9fzjwbD3Fan5 1XbUk7MnIRVgoRmUdgmMvdcwcwwXFjvhkdUjftmniy0HubSH9COuZuQ54P2axkEmMREm LmnA== X-Forwarded-Encrypted: i=1; AJvYcCUk7zD2+xU3mPyBXeFx+tEgtfE/HBSnLeVMlCciT8rmLK2bvwLMDhdRb+zw60fep3FHEv4T8A==@debbugs.gnu.org X-Gm-Message-State: AOJu0YzpfixeK2F84i+Pf1m3rOsVz2bbHgsH4gGadmNoLpns7E3ttsm3 q+LERM9x91svvM06OoYblzt2LOl/pLpL81BdgPzIyRhQnLNrLplop2+OBg== X-Google-Smtp-Source: AGHT+IEhDtQGDHnb31wpyWqkAPMXKFcTjBR2zEJ6T1pN7GI5C8CIrm7Hbm3lqmyDQNQDwhID6q51ow== X-Received: by 2002:adf:a351:0:b0:371:7e46:68cb with SMTP id ffacd0b85a97d-373118c6b95mr7775209f8f.50.1724773844023; Tue, 27 Aug 2024 08:50:44 -0700 (PDT) Original-Received: from rltb ([2a01:e0a:3f3:fb51:702d:b85:b5c9:fe6f]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3730826b10bsm13297199f8f.114.2024.08.27.08.50.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 08:50:42 -0700 (PDT) In-Reply-To: <86zfp4sqig.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 22 Aug 2024 15:15:03 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:290829 Archived-At: --=-=-= Content-Type: text/plain >>>>> On Thu, 22 Aug 2024 15:15:03 +0300, Eli Zaretskii said: Eli> For backward compatibility, let's leave rmail-re-abbrevs in place, and Eli> just initialize it from that new defcustom. Patch attached. Works for gnus for me, and manual testing of the rmail regexp works. Did you want me to obsolote the rmail and message variables as well? Robert -- --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0001-Teach-gnus-message-about-international-Re-variants.patch Content-Transfer-Encoding: quoted-printable >From ae84c547234ab28cc50ae2bb288bd401978ec293 Mon Sep 17 00:00:00 2001 From: Robert Pluim Date: Thu, 22 Aug 2024 18:49:12 +0200 Subject: [PATCH] Teach gnus/message about international Re: variants To: emacs-devel@gnu.org Bug#72442 * 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'. --- doc/emacs/rmail.texi | 8 ++++++++ doc/misc/message.texi | 13 ++++++++++++- etc/NEWS | 26 ++++++++++++++++++++++++++ lisp/gnus/message.el | 29 ++++++++++++++++++++++------- lisp/mail/mail-utils.el | 19 +++++++++++++++++++ lisp/mail/rmail.el | 31 ++++++++++++++++++++----------- 6 files changed, 107 insertions(+), 19 deletions(-) diff --git a/doc/emacs/rmail.texi b/doc/emacs/rmail.texi index 9c20d30c442..e090ec6fe76 100644 --- a/doc/emacs/rmail.texi +++ b/doc/emacs/rmail.texi @@ -776,6 +776,14 @@ Rmail Reply sent the message you received, and the @samp{CC} field starts out with all the other recipients of that message. =20 +@vindex rmail-re-abbrevs +@vindex rmail-reply-prefix +@vindex mail-re-regexps +The @samp{Subject} header field may contain one or more instances of +@samp{Re:} or localized variants thereof. These are removed if they +match @code{rmail-re-abbrevs} (which is initialized from +@code{mail-re-regexps}), and @code{rmail-reply-prefix} is prepended. + @vindex mail-dont-reply-to-names You can exclude certain recipients from being included automatically 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 468bf81599d..f5399aecee1 100644 --- a/doc/misc/message.texi +++ b/doc/misc/message.texi @@ -1693,13 +1693,14 @@ Message Headers =20 @item message-subject-re-regexp @vindex message-subject-re-regexp +@vindex mail-re-regexps @cindex Aw @cindex Sv @cindex Re Responses to messages have subjects that start with @samp{Re: }. This is @emph{not} an abbreviation of the English word ``response'', but it comes from the Latin ``res'', and means ``in the matter of''. Some -illiterate nincompoops have failed to grasp this fact, and have +standards-challenged companies have failed to grasp this fact, and have ``internationalized'' their software to use abominations like @samp{Aw: } (``antwort'') or @samp{Sv: } (``svar'') instead, which is meaningless and evil. However, you may have to deal with users that @@ -1731,6 +1732,16 @@ Message Headers )) @end lisp =20 +You shouldn't need to do this, since the default value of +@code{message-subject-re-regexp} is initialized based on +@code{mail-re-regexps}, which covers most known cases of such +internationalization, and is a lot easier to customize. Customizing +@code{mail-re-regexps} updates @code{message-subject-re-regexp} to +match. + +Note that the regexp is matched case-insensitively against the +@samp{Subject} header contents. + @item message-subject-trailing-was-query @vindex message-subject-trailing-was-query @vindex message-subject-trailing-was-ask-regexp diff --git a/etc/NEWS b/etc/NEWS index 07d1cce0966..82c0eac4e5c 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -162,6 +162,32 @@ By passing '-t' or '--timeout', you can specify a maxi= mum time to wait for the processes to exit. Additionally, you can now wait for external processes by passing their PIDs. =20 ++++ +** Mail-util + +*** New user option 'mail-re-regexps'. +This contains the list of regular expressions used to match "Re:" and +international variants of it when modifying the Subject field in +replies. + ++++ +** Rmail + +*** 'rmail-re-abbrevs' default value is now derived from 'mail-re-regexps'. +'mail-re-regexps' is a new user option that is easier to customize than +'rmail-re-abbrevs'. 'rmail-re-abbrevs' is still honored if it was +already set. + ++++ +** Message + +*** 'message-subject-re-regexp' default value is now derived from 'mail-re= -regexps'. +'mail-re-regexps' is a new user option that is easier to customize than +'message-subject-re-regexp'. 'message-subject-re-regexp' is still +honored if it was already set. + +*** 'message-strip-subject-re' now matches case-insensitively. + ** SHR =20 +++ diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index 98f63571389..081c6986a66 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el @@ -305,11 +305,24 @@ message-ignored-supersedes-headers regexp)) =20 (defcustom message-subject-re-regexp - "^[ \t]*\\([Rr][Ee]\\(\\[[0-9]*\\]\\)* ?:[ \t]*\\)*[ \t]*" - "Regexp matching \"Re: \" in the subject line." + (concat "^[ \t]*" + "\\(" + "\\(" + (string-join mail-re-regexps "\\|") + "\\)" + "\\(\\[[0-9]*\\]\\)*" + " ?\u00a0*[:=EF=BC=9A][ \t]*" + "\\)" + "*[ \t]*") + "Regexp matching \"Re: \" in the subject line. +Matching is done case-insensitively. +Initialized from the value of `mail-re-regexps', which is easier to +customize." :group 'message-various :link '(custom-manual "(message)Message Headers") - :type 'regexp) + :type 'regexp + :set-after '(mail-re-regexps) + :version "31.1") =20 (defcustom message-screenshot-command '("import" "png:-") "Command to take a screenshot. @@ -2257,10 +2270,12 @@ message-strip-list-identifiers subject))) =20 (defun message-strip-subject-re (subject) - "Remove \"Re:\" from subject lines in string SUBJECT." - (if (string-match message-subject-re-regexp subject) - (substring subject (match-end 0)) - subject)) + "Remove \"Re:\" from subject lines in string SUBJECT. +This uses `mail-re-regexps, matching is done case-insensitively." + (let ((case-fold-search t)) + (if (string-match message-subject-re-regexp subject) + (substring subject (match-end 0)) + subject))) =20 (defcustom message-replacement-char "." "Replacement character used instead of unprintable or not decodable char= s." diff --git a/lisp/mail/mail-utils.el b/lisp/mail/mail-utils.el index c9e4d0b3812..a04092b5727 100644 --- a/lisp/mail/mail-utils.el +++ b/lisp/mail/mail-utils.el @@ -46,6 +46,25 @@ mail-dont-reply-to-names :type '(choice regexp (const :tag "Your Name" nil)) :group 'mail) =20 +;;;###autoload +(defcustom mail-re-regexps + '("RE" "R\u00c9\\.?" "FWD?" "=D8=B1=D8=AF" "=E5=9B=9E=E5=A4=8D" "=E5=9B= =9E=E8=A6=86" "SV" "Antw\\.?" + "VS" "REF" "AW" "=CE=91=CE=A0" "=CE=A3=CE=A7=CE=95=CE=A4" "=D7=94=D7=A9= =D7=91" "V=C3=A1" "R" "RIF" "BLS" "RES" + "Odp" "YNT" "ATB") + "List of localized \"Re:\" abbreviations in various languages. +Each component can be a regular expression or a simple string. Matching +is done case-insensitively. Used to initialize the legacy +`rmail-re-abbrevs' and `message-subject-re-regexp' user options." + :type '(repeat regexp) + :set (lambda (sym val) + (custom-set-default sym val) + (dolist (sym '(rmail-re-abbrevs + message-subject-re-regexp)) + (when (get sym 'standard-value) + (custom-reevaluate-setting sym)))) + :group 'mail + :version "31.1") + (defvar epa-inhibit) ;; Returns t if file FILE is an Rmail file. ;;;###autoload diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el index e38ab12fae6..4965907916c 100644 --- a/lisp/mail/rmail.el +++ b/lisp/mail/rmail.el @@ -527,23 +527,32 @@ rmail-automatic-folder-directives (defvar rmail-reply-prefix "Re: " "String to prepend to Subject line when replying to a message.") =20 -;; Note: this is matched with case-fold-search bound to t. -(defcustom rmail-re-abbrevs - "\\(RE\\|=D8=B1=D8=AF\\|=E5=9B=9E=E5=A4=8D\\|=E5=9B=9E=E8=A6=86\\|SV\\|A= ntw\\|VS\\|REF\\|AW\\|=CE=91=CE=A0\\|=CE=A3=CE=A7=CE=95=CE=A4\\|=D7=94=D7= =A9=D7=91\\|V=C3=A1\\|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 - (concat "\\`\\(" - rmail-re-abbrevs - "\\(([0-9]+)\\|\\[[0-9]+\\]\\|\\^[0-9]+\\)?\u00a0*[:=EF=BC=9A] *= \\)*") +(defvar rmail-reply-regexp nil ;; set by `rmail-re-abbrevs "Regexp to delete from Subject line before inserting `rmail-reply-prefix= '.") =20 +;; Note: this is matched with case-fold-search bound to t. +(defcustom rmail-re-abbrevs + (concat "\\(" + (string-join mail-re-regexps "\\|") + "\\)") + "Regexp with localized \"Re:\" abbreviations in various languages. +Matching is done case-insensitively. +Initialized from `mail-re-regexps', which is easier to customize." + :set-after '(mail-re-regexps) + :set (lambda (sym val) + (custom-set-default sym val) + (setq rmail-reply-regexp + (concat "\\`[ \t]*\\(" + val + "\\(([0-9]+)\\|\\[[0-9]+\\]\\|\\^[0-9]+\\)?" + " ?\u00a0*[:=EF=BC=9A][ \t]*\\)*[ \t]*"))) + :type 'regexp + :version "31.1") + (defcustom rmail-display-summary nil "If non-nil, Rmail always displays the summary buffer." :group 'rmail-summary --=20 2.39.2 --=-=-=--