Received: (at 81274) by debbugs.gnu.org; 22 Jun 2026 16:03:26 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 22 12:03:25 2026 Received: from localhost ([127.0.0.1]:57731 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1wbh7L-0004H1-OZ for submit <at> debbugs.gnu.org; Mon, 22 Jun 2026 12:03:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36558) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1wbh7F-0004GJ-Uk for 81274 <at> debbugs.gnu.org; Mon, 22 Jun 2026 12:03:20 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1wbh7A-0004a1-Cp; Mon, 22 Jun 2026 12:03:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=gmbya/jR/mykyxOc6M5DJzsZ85TAct8+BAZQShdBZHM=; b=ZNTAmpQxlRiI gC2BIvPFlWMSECwIwYEPge3Fl8EI2e0ZzeErnRP7y5MCE1oj2qhrRMGjQoFL84YWn4626tidkQnq3 nbRVfa1/3P0MbX7IQIMlR67jvw7ADDO7PRiwG1e3s7SUdVbGhRkUpAsp1xSYyjtX46W5G0XBDeoiM 8bQ+0DkeKwPZXIbP+WmNVdday+382dqoyGNNNnv+XjsT30esutaFvpBNm2m5zaaSweWqYmu6O+htK ZaWcfNOjtyeIX5vxweVEEEbe+f1jDHzfBkbMszUvftlkDRpMz2+7xkHV0RnnG8WxMxa4L0Lr8gW8e tgE5+hmgHa3Xekiigg91kw==; Date: Mon, 22 Jun 2026 19:03:09 +0300 Message-Id: <868q86bm0y.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> To: "Paul D. Nelson" <ultrono@HIDDEN> In-Reply-To: <uxsg7tldc6vb7o.fsf@HIDDEN> (ultrono@HIDDEN) Subject: Re: bug#81274: [PATCH] Avoid Rmail auto-save coding prompts References: <uxsg7tldc6vb7o.fsf@HIDDEN> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 81274 Cc: 81274 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > From: "Paul D. Nelson" <ultrono@HIDDEN> > Cc: 81274 <at> debbugs.gnu.org > Date: Mon, 22 Jun 2026 17:36:27 +0200 > > >> Another possible fix would be to make find-file + rmail-mode track > >> `rmail` more closely: before the first swap, make the buffer containing > >> the mbox data unibyte. The invariant would then be "the buffer > >> containing the mbox data is always unibyte". Does that sound better? > > > If the mbox buffer is unibyte, does rmail-output work correctly > > without any changes? > > Yes. I can look into making the find-file+rmail-mode path preserve that > invariant, if you agree. Yes, I think that's the right way. I see a couple of set-buffer-multibyte calls in rmail.el, and I tend to think that, if this is done in the rmail-view-buffer (where the original mbox file is kept), it's a remnant from older Rmail days, when we used BABYL format. Nowadays the Rmail file is always in mbox format and should always be kept in its original unibyte form. Thanks.
bug-gnu-emacs@HIDDEN:bug#81274; Package emacs.
Full text available.Received: (at 81274) by debbugs.gnu.org; 22 Jun 2026 15:36:43 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 22 11:36:43 2026 Received: from localhost ([127.0.0.1]:57646 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1wbghU-0001hl-IS for submit <at> debbugs.gnu.org; Mon, 22 Jun 2026 11:36:42 -0400 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]:55738) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <ultrono@HIDDEN>) id 1wbghP-0001gv-Qj for 81274 <at> debbugs.gnu.org; Mon, 22 Jun 2026 11:36:38 -0400 Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-c0be5e548a4so375894066b.3 for <81274 <at> debbugs.gnu.org>; Mon, 22 Jun 2026 08:36:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782142589; x=1782747389; darn=debbugs.gnu.org; h=mime-version:message-id:date:in-reply-to:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=NVql+IufWOzCnCvaFU/CmZk392hf5Gt4Rb9sgqJWKhg=; b=Rvj9lgU0Kjqh/6V9c68zmFQLcZMC4Uq0XWcg32jJeXx89/eJvgiuNGf52kyDe+f2Qu BZuAYG9Y6sjAZ4zatfC0hUUmdyGVIbS9W1kOajpC0km3zgw2nnAjof7Prko15M08V5Ex Ba5Z9hhgxf/SU+aYNZHpP88zHOm+iCyCuOGzmWF5ibnBGHrQMvb9MzFPHj5lB1nqNl7w eqFAhDzI/CXAZvDE7kbScXqc2s97fXE0kMhge6rbQo9BEZNIT8ErvYeeTFqSAYY71Ybv YxtWMiAuZIWdgkxVyQzZkXQ0ZL10gldLJ143S2J9O86Fct4fUecHCVAX/GEqbq1/cENx 8qnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782142589; x=1782747389; h=mime-version:message-id:date:in-reply-to:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NVql+IufWOzCnCvaFU/CmZk392hf5Gt4Rb9sgqJWKhg=; b=MVDRt4kx1WAlX0+FNnkdriGdeBLWmwEi9boWzCO4OL/NWuQ+ULKmGfFxvWTdMfShS2 vB8r1jJawJ/6FpWmdnm+NVS8Pn63xRZYH/GNnAO4ePDYbO5yHLYeNjR7wWycMh9ZadB1 QZhyjMSBldl0uG0QeGqJUAOGRbYOKKjM8ub6RZ/9USJmqZ52iIRElyfBvXkCkyiRndsk AxVGRYcymYdwoVafR+yv5aE3ho5d3/T6f9huK2Et74bwH6ry8ZN/KEgZQZXrwP1OrgbS UVsQjukvyYK3CLRnLCCs3GxJFqcPiAUhh2CvjPCAcRjCLM9YMsIRyvIFSf8iQIiXIyt8 kcEQ== X-Gm-Message-State: AOJu0Yy3WnWJOcdnkhB8VvMCuzJ66sJsqOC7U9xyT56MSVqfG3fNkl8r isL+PqqnzMRyL25HRFCujN3QAD9hD/4WFrADqYkDerdJcFmLUzwn7xN2 X-Gm-Gg: AfdE7ckPF6z32VnFbd9kVjkC7Ozb+MEE70zNLHr5LIaHK8Jm6QnKN1qx+uFNe4JvO6t 3cPrzXdjEQ30iGQ8zzv1QHlED2N2ZfS88/4t+dCBIMY25mGWL9DhS8hT98IumC+JVfRTi1C4lWn nXmci19kT4Kpj8o4u13JPJLn+PVpm/eTQmqtWBd9kVfW11JcNkJW9sbGVRTFRT7RBf3GwNoyjLV h8WBh/5HyYGNHzA8Q/25eXrr0wGVsnMvMkqfaXPo1JXKpcG+ZBJyFM5SzLiU/QmailIWYg/QW5n Nmn6e91nAQR0nuBFziob6sKnPM1yuu4fGYWyds98bpJ/0kDGMpD00YCQbBQTB/VSYfmjHxmhRQR p7dIC5kqzly4cwfGfleFmXbEbM/RRMnh9nSWjzgisQO0n6ym8g3c1W5W0cQfub4JOWDizkfM9dA 2NrdcWFre6Tv3YoAFH4TVstkEMeYdaPiS7E44V8OGkDf0= X-Received: by 2002:a17:906:ef09:b0:bd3:1a18:cc64 with SMTP id a640c23a62f3a-c097c1be89dmr765693466b.31.1782142588798; Mon, 22 Jun 2026 08:36:28 -0700 (PDT) Received: from localhost (users-1190.st.net.au.dk. [130.225.0.251]) by smtp.gmail.com with UTF8SMTPSA id a640c23a62f3a-c0c5ef8acaesm378788566b.27.2026.06.22.08.36.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2026 08:36:28 -0700 (PDT) From: "Paul D. Nelson" <ultrono@HIDDEN> To: Eli Zaretskii <eliz@HIDDEN> Subject: Re: bug#81274: [PATCH] Avoid Rmail auto-save coding prompts In-Reply-To: <86pl1ibxti.fsf@HIDDEN> (message from Eli Zaretskii on Mon, 22 Jun 2026 14:48:25 +0300) Date: Mon, 22 Jun 2026 17:36:27 +0200 Message-ID: <uxsg7tldc6vb7o.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 81274 Cc: 81274 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: 0.0 (/) Eli Zaretskii <eliz@HIDDEN> writes: > This is wrong IMO, but how is it relevant to our scenario? Why would > you do find-file+rmail-mode in the first place? For example: - bookmarks + auto-mode-alist (quick access to specific mboxes) - Dired (browsing a directory of mboxes) >> Another possible fix would be to make find-file + rmail-mode track >> `rmail` more closely: before the first swap, make the buffer containing >> the mbox data unibyte. The invariant would then be "the buffer >> containing the mbox data is always unibyte". Does that sound better? > If the mbox buffer is unibyte, does rmail-output work correctly > without any changes? Yes. I can look into making the find-file+rmail-mode path preserve that invariant, if you agree.
bug-gnu-emacs@HIDDEN:bug#81274; Package emacs.
Full text available.Received: (at 81274) by debbugs.gnu.org; 22 Jun 2026 11:48:36 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 22 07:48:36 2026 Received: from localhost ([127.0.0.1]:54280 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1wbd8l-00045s-S5 for submit <at> debbugs.gnu.org; Mon, 22 Jun 2026 07:48:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53242) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1wbd8j-00045a-Gx for 81274 <at> debbugs.gnu.org; Mon, 22 Jun 2026 07:48:34 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1wbd8e-0000kQ-2A; Mon, 22 Jun 2026 07:48:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=FApc8AqZgBV/Ug67QpneY8nNpze2S9RW8nUX/mFn0C4=; b=aXtKhT2MuCWn aigbzwiOxK9V+qmeDYouMxAnt6s0ebJippXGscIw5Mp6JuqhTn6edF6N3D9cXzMComesYBKuzGv2W kwBKUXxO8Ew6FmHvK8GPL4vpnTwVVPX29WDL56M4uoVtjmI3cWZFYuQxrv/p+OBk/gSePg50ehRC0 BdiI6932J/0QD0A9nIsVOHykkJ/Cyh6TAJDgXYS0yj/YrXaN5RusbXp6IO2Iej3yyv1yc/sxFzbg+ hFhANgVTIEvARDOjSH7IQlaW8aYSFJnFuRg8d7DBBKcoh5ghPpyD+7LbMRUqzjWG1E2GGvS/74hpE 8acdDhXAADLwtoaWYUrf8w==; Date: Mon, 22 Jun 2026 14:48:25 +0300 Message-Id: <86pl1ibxti.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> To: "Paul D. Nelson" <ultrono@HIDDEN> In-Reply-To: <uxsg7tmrwnbxmp.fsf@HIDDEN> (ultrono@HIDDEN) Subject: Re: bug#81274: [PATCH] Avoid Rmail auto-save coding prompts References: <uxsg7tmrwnbxmp.fsf@HIDDEN> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 81274 Cc: 81274 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > From: "Paul D. Nelson" <ultrono@HIDDEN> > Cc: 81274 <at> debbugs.gnu.org > Date: Sun, 21 Jun 2026 19:40:14 +0200 > > Eli Zaretskii <eliz@HIDDEN> writes: > > > You say that "during auto-save, 'rmail-write-region-annotate' switches > > to the view buffer and 'write-region' chooses a coding system from > > that buffer's 'buffer-file-coding-system'". But doesn't that switch > > happen during any auto-save of an Rmail buffer? If so, why don't we > > see the prompt every time an Rmail buffer is auto-saved? IOW, what > > are the special conditions that trigger this problem? I initially > > thought it only happened when the user types RET on the MIME's > > attachment heading, which then prompts for the file in the minibuffer, > > but I cannot figure out how that situation causes something different > > in terms of swapping the Rmail buffers so as to cause this problem. > > What am I missing? > > We need something like the conditions in my repro: > > (1) an Rmail buffer src whose view buffer (in the "contains mbox data" > state) is unibyte, and AFAIK, this is always the case, at least as long as we show some message. > If src contains raw bytes, then calling (rmail-output dst) from src > appends those bytes from src to dst, which leads to the problem. So AFAIU you need 2 Rmail buffers, and then invoke rmail-output so that it appends to the Rmail buffer visiting the file DST. If that is correct, let's find a way to do that correctly. If this is what's needed to create the problem, we should either make sure SRC and DST are both unibyte, or fix rmail-output so that it doesn't mix raw bytes with decoded text. > To achieve (2), we do find-file + rmail-mode, which inherits a non-raw > coding system and does something like: > > (when (and finding-rmail-file (null coding-system-for-read)) > ;; ... > (set-buffer-multibyte t)) > ;; ... > (rmail-swap-buffers) ;; via rmail-show-message, rmail-show-message-1 > > This yields (2). This is wrong IMO, but how is it relevant to our scenario? Why would you do find-file+rmail-mode in the first place? > Another possible fix would be to make find-file + rmail-mode track > `rmail` more closely: before the first swap, make the buffer containing > the mbox data unibyte. The invariant would then be "the buffer > containing the mbox data is always unibyte". Does that sound better? Yes. If the mbox buffer is unibyte, does rmail-output work correctly without any changes? If not, I think the fix should be in rmail-output-to-rmail-buffer, which is where this appending happens.
bug-gnu-emacs@HIDDEN:bug#81274; Package emacs.
Full text available.
Received: (at 81274) by debbugs.gnu.org; 21 Jun 2026 17:40:42 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jun 21 13:40:41 2026
Received: from localhost ([127.0.0.1]:46883 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
id 1wbM9p-0003Eh-Ui
for submit <at> debbugs.gnu.org; Sun, 21 Jun 2026 13:40:40 -0400
Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:46369)
by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
(Exim 4.84_2) (envelope-from <ultrono@HIDDEN>) id 1wbM9f-0003Dx-Qb
for 81274 <at> debbugs.gnu.org; Sun, 21 Jun 2026 13:40:29 -0400
Received: by mail-wm1-x333.google.com with SMTP id
5b1f17b1804b1-490cf3000f0so38598185e9.1
for <81274 <at> debbugs.gnu.org>; Sun, 21 Jun 2026 10:40:23 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20251104; t=1782063617; x=1782668417; darn=debbugs.gnu.org;
h=mime-version:message-id:date:in-reply-to:subject:cc:to:from:from:to
:cc:subject:date:message-id:reply-to;
bh=1Njy2CTH4FYd835mguvvatcTljp93j+WSkdNDY55OuA=;
b=KCj4nW0fIBaHNXKialgXgC3+c1b29bKd1GoLczXb8lMzLdqRODpDCqhKbZTplzRlm2
Kv40yDxqh7nnNUuZo0/eFdWz92S5wQ9GcpPrqtk7gI1JE2le96S0iyk+S8p4w2q5fBW2
1812EO+mhqTcIh6L0y2skQLoqqClsbIoAWXSmXKMtMxv+PslRFiTRY08BvS2VV+63JBQ
Xkz8LOdxEiNT3oZuL2lsQ8J+5KaIY5akQPf2RghVnBiwZym7A38yXsGjAzRbLqG1haNQ
PJWEglYB+LxxktjkuwvTS+aeLZZyQZ67UQ76IPSZpPQR5UZSZeXmlAxIiP5dm5YNgSI2
Db6g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20251104; t=1782063617; x=1782668417;
h=mime-version:message-id:date:in-reply-to:subject:cc:to:from:x-gm-gg
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=1Njy2CTH4FYd835mguvvatcTljp93j+WSkdNDY55OuA=;
b=OFI4nbYjIrmptliR0M9mAbeszsfKddxKFhyRXKOV0LyusL6BfseNWjoYyEjJP0aHl0
XlFRtxM6Fx050I/TpUtmYLK/lZLcZ9OTlez/QkmpY4EA3uyXDKcrwXySjv7xAgGiSwbf
Qu6qcEq1P1AfB0/A/SDg7L3Mi7eRO/SR+bZq1y+xKeX9S/rHorcwOtyWonU0xbdCfIy8
yeB3i2FOJ1SMsNZpxemuGsn7EbS2TqaKEfqq88ZodW7B/3dueZKJZqifcoR99VULaASA
eypSCYjqauUvW6k5rUGCei62zWDQr5OiwivnMLNksEhvHwsv/6GoKzqUsu1HwlTqJl45
6LZg==
X-Gm-Message-State: AOJu0YxtA9J0SCehLFZpcBAve1H9TcgwYAYpnF5LsvKeOAdw1iDAGbJP
QX+RIIg53Anct7Wud+uCkrDyPaZlVukLmwSmHVBdDHoe5GsiANtlm8hvorExU0gt
X-Gm-Gg: AfdE7clznBOxLNQgCGuDjgJ6T80PuFW14zQEbiBrUQsNMoHVXmPQ+A5MMYTeewNwcHd
bXiCytLlvDze1YNhFypcL4viulqusoshRWZd0w3AwyMWyDlQdz2VbGaLB0VLGwO19miFHGDAOna
InNkoIAbqQjbByuP15r+gM4odBku/taOA63uwBqo9m6Zq1bsEmHSRXnJHpu7RBk39RwZ0YPPkJ/
500JIDv5SLMVaglcBAuBS/wLDNC0FwrSVIYD0TsbmCxgO+o15loCCb/NMFq4r5K8F0mtC0yk498
+lT+OYpGHmA/Bmwd3rUpKRomNdcfH6SEHu1UBz75akp83MmG+DvM1At0FiO//hdhGyMFwXF2rrV
YBIyGz3nx/ylagvjCvzFIiMEXOHjgyVOKe4OtdNredXWMJOKmZD9ISi5btsMPzGg3MkqMorg0Pa
/BAh381TNNAN+MLxNAesiWSweWnw8aFXzzOhjbh0y6j8gZ31N/IpuG4JO0apS8U5bTEsPZ
X-Received: by 2002:a05:600c:4755:b0:492:25a1:e2f9 with SMTP id
5b1f17b1804b1-4924257c2bcmr152081465e9.26.1782063617138;
Sun, 21 Jun 2026 10:40:17 -0700 (PDT)
Received: from localhost (0x573d6737.static.cust.fastspeed.dk. [87.61.103.55])
by smtp.gmail.com with UTF8SMTPSA id
ffacd0b85a97d-466648c698dsm20387044f8f.16.2026.06.21.10.40.15
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Sun, 21 Jun 2026 10:40:15 -0700 (PDT)
From: "Paul D. Nelson" <ultrono@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#81274: [PATCH] Avoid Rmail auto-save coding prompts
In-Reply-To: <86y0g9cnnd.fsf@HIDDEN> (message from Eli Zaretskii on Sat, 20
Jun 2026 17:05:58 +0300)
Date: Sun, 21 Jun 2026 19:40:14 +0200
Message-ID: <uxsg7tmrwnbxmp.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 81274
Cc: 81274 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.0 (/)
Eli Zaretskii <eliz@HIDDEN> writes:
>> From: "Paul D. Nelson" <ultrono@HIDDEN>
>> Date: Sat, 20 Jun 2026 14:05:42 +0200
>>
>> Then type M-x do-auto-save.
>>
>> Expected: Auto-save completes silently, as usual.
>> Observed: A prompt "Select coding system (default raw-text):".
>>
>> If auto-save fires while the minibuffer is in use (e.g., while saving an
>> attachment), we get "Command attempted to use minibuffer while in
>> minibuffer". With recursive minibuffers enabled, it can trigger a loop
>> and exceed the Lisp nesting limit.
>>
>> The issue is that during auto-save, 'rmail-write-region-annotate'
>> switches to the view buffer and 'write-region' chooses a coding system
>> from that buffer's 'buffer-file-coding-system', rather than the
>> 'no-conversion' coding that Rmail uses for normal saves.
>>
>> The attached patch copies 'save-buffer-coding-system' to the view buffer
>> in 'rmail-write-region-annotate', so auto-save encodes the collection
>> the same way normal saves do.
>
> Thanks, but this solution is too heavy-handed IMO. It basically
> changes the buffer-file-coding-system of rmail-view-buffer to a value
> that is not suitable for that buffer, with the only purpose of fixing
> auto-save in AFAIU a very specific situation, and then leaves
> buffer-file-coding-system of that buffer at this value. I'd like to
> try to find a solution that doesn't have such significant effect on
> Rmail's view buffer.
Thanks, I'll suggest another possible direction below.
> You say that "during auto-save, 'rmail-write-region-annotate' switches
> to the view buffer and 'write-region' chooses a coding system from
> that buffer's 'buffer-file-coding-system'". But doesn't that switch
> happen during any auto-save of an Rmail buffer? If so, why don't we
> see the prompt every time an Rmail buffer is auto-saved? IOW, what
> are the special conditions that trigger this problem? I initially
> thought it only happened when the user types RET on the MIME's
> attachment heading, which then prompts for the file in the minibuffer,
> but I cannot figure out how that situation causes something different
> in terms of swapping the Rmail buffers so as to cause this problem.
> What am I missing?
We need something like the conditions in my repro:
(1) an Rmail buffer src whose view buffer (in the "contains mbox data"
state) is unibyte, and
(2) an Rmail buffer dst whose view buffer is multibyte and has a non-raw
`buffer-file-coding-system` (e.g., undecided-unix).
Rmail normally disables auto-save, but enables it after rmail-output.
If src contains raw bytes, then calling (rmail-output dst) from src
appends those bytes from src to dst, which leads to the problem.
To achieve (1), we do M-x rmail, which does something like:
(let ((coding-system-for-read
(or coding-system-for-read 'no-conversion)))
(find-file-noselect file-name))
;; ...
(set-buffer-multibyte nil) ;; via rmail-mode-2, rmail-perm-variables
;; ...
(rmail-swap-buffers) ;; via rmail-mode, rmail-show-message, rmail-show-message-1
`rmail-swap-buffers` swaps the contents (and multibytedness) and the
`buffer-file-coding-system` with those of the view buffer, yielding (1).
(In particular, the view buffer's `buffer-file-coding-system` is
'no-conversion unless we do e.g. `C-x RET c utf-8 RET M-x rmail`.)
To achieve (2), we do find-file + rmail-mode, which inherits a non-raw
coding system and does something like:
(when (and finding-rmail-file (null coding-system-for-read))
;; ...
(set-buffer-multibyte t))
;; ...
(rmail-swap-buffers) ;; via rmail-show-message, rmail-show-message-1
This yields (2).
Another possible fix would be to make find-file + rmail-mode track
`rmail` more closely: before the first swap, make the buffer containing
the mbox data unibyte. The invariant would then be "the buffer
containing the mbox data is always unibyte". Does that sound better?
bug-gnu-emacs@HIDDEN:bug#81274; Package emacs.
Full text available.Received: (at 81274) by debbugs.gnu.org; 20 Jun 2026 14:06:12 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jun 20 10:06:12 2026 Received: from localhost ([127.0.0.1]:34845 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1wawKp-0003OO-Gn for submit <at> debbugs.gnu.org; Sat, 20 Jun 2026 10:06:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57874) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1wawKl-0003Nj-Q4 for 81274 <at> debbugs.gnu.org; Sat, 20 Jun 2026 10:06:09 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1wawKg-0007R1-1n; Sat, 20 Jun 2026 10:06:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=kaIxnvglB+0cVLff2lole0iJ/FTs+8mbOsH3H8w9x3w=; b=kLov8DPmDzIh Ky3stOrbc6CK+N8/MteHdSBrSExclzBDpqLKt2N3ZgePDusvecWGjbc/I8bpZqB13NbfMI3BW6aAG bcyINQcRT2Ba4q69Y1VoDWkrPp8jP1LiU4BTXrANQgZmEUiLyRgrZVzm/W10dd16PLWtv/KHXSHKf b5vcHkohnbYyXgAEjybyYpUSbB0bSgsB5F8eq5s1TeUSzWyuZnM4LYkpELlRiGyV1QQfjGbal3egi X22d8RM/CjHkl/+h7tkyb+48csC8M2T7tINnC/O8un61LmiZTQxl9BhrDe9J4eIBtv+VEPEN3wn78 iuZbXGBWl4l9Ar140lTOHQ==; Date: Sat, 20 Jun 2026 17:05:58 +0300 Message-Id: <86y0g9cnnd.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> To: "Paul D. Nelson" <ultrono@HIDDEN> In-Reply-To: <uxsg7t4iixquw9.fsf@HIDDEN> (ultrono@HIDDEN) Subject: Re: bug#81274: [PATCH] Avoid Rmail auto-save coding prompts References: <uxsg7t4iixquw9.fsf@HIDDEN> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 81274 Cc: 81274 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > From: "Paul D. Nelson" <ultrono@HIDDEN> > Date: Sat, 20 Jun 2026 14:05:42 +0200 > > Then type M-x do-auto-save. > > Expected: Auto-save completes silently, as usual. > Observed: A prompt "Select coding system (default raw-text):". > > If auto-save fires while the minibuffer is in use (e.g., while saving an > attachment), we get "Command attempted to use minibuffer while in > minibuffer". With recursive minibuffers enabled, it can trigger a loop > and exceed the Lisp nesting limit. > > The issue is that during auto-save, 'rmail-write-region-annotate' > switches to the view buffer and 'write-region' chooses a coding system > from that buffer's 'buffer-file-coding-system', rather than the > 'no-conversion' coding that Rmail uses for normal saves. > > The attached patch copies 'save-buffer-coding-system' to the view buffer > in 'rmail-write-region-annotate', so auto-save encodes the collection > the same way normal saves do. Thanks, but this solution is too heavy-handed IMO. It basically changes the buffer-file-coding-system of rmail-view-buffer to a value that is not suitable for that buffer, with the only purpose of fixing auto-save in AFAIU a very specific situation, and then leaves buffer-file-coding-system of that buffer at this value. I'd like to try to find a solution that doesn't have such significant effect on Rmail's view buffer. You say that "during auto-save, 'rmail-write-region-annotate' switches to the view buffer and 'write-region' chooses a coding system from that buffer's 'buffer-file-coding-system'". But doesn't that switch happen during any auto-save of an Rmail buffer? If so, why don't we see the prompt every time an Rmail buffer is auto-saved? IOW, what are the special conditions that trigger this problem? I initially thought it only happened when the user types RET on the MIME's attachment heading, which then prompts for the file in the minibuffer, but I cannot figure out how that situation causes something different in terms of swapping the Rmail buffers so as to cause this problem. What am I missing?
bug-gnu-emacs@HIDDEN:bug#81274; Package emacs.
Full text available.
Received: (at submit) by debbugs.gnu.org; 20 Jun 2026 12:06:13 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jun 20 08:06:12 2026
Received: from localhost ([127.0.0.1]:60339 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
id 1wauSc-0000Ga-K0
for submit <at> debbugs.gnu.org; Sat, 20 Jun 2026 08:06:12 -0400
Received: from lists1p.gnu.org ([2001:470:142::17]:35816)
by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.84_2) (envelope-from <ultrono@HIDDEN>) id 1wauST-0000F8-Mv
for submit <at> debbugs.gnu.org; Sat, 20 Jun 2026 08:06:03 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.90_1) (envelope-from <ultrono@HIDDEN>) id 1wauSN-0001rP-0H
for bug-gnu-emacs@HIDDEN; Sat, 20 Jun 2026 08:05:52 -0400
Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530])
by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
(Exim 4.90_1) (envelope-from <ultrono@HIDDEN>) id 1wauSK-0000Zn-VR
for bug-gnu-emacs@HIDDEN; Sat, 20 Jun 2026 08:05:50 -0400
Received: by mail-ed1-x530.google.com with SMTP id
4fb4d7f45d1cf-693c51a8a19so4306984a12.3
for <bug-gnu-emacs@HIDDEN>; Sat, 20 Jun 2026 05:05:48 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20251104; t=1781957147; x=1782561947; darn=gnu.org;
h=mime-version:message-id:date:subject:to:from:from:to:cc:subject
:date:message-id:reply-to;
bh=KvRKJillqZa9lePuG6skSq5CuIbR7xiBsK2/2YvBePw=;
b=P9schS8OabrrAvpxW6ajebQnoDJP43qq//SqGZeg0HoUjIyjCmSp1uPsFJCipc2WZ+
/j/JcU3u39hej8u1c14dl91EnYYDEnJT5MKPPB6VxMWyMjvZUaxxdexsxE8DV7IoCPBu
fItUm2ZhIjtB6HWNmwYLasZt86poVJBqANNaUYaB9gIdy2IpKKxXFD5xxwIULAiedkzK
XdAaP5oXD22/85SlJgQcHTFmnBnxTmkIvbF2oXdQ6jVHd+6402TbAmMsowruznJKg40x
rGuCrMTs45046kvc+a3JQZV+S/PdQJV+I5NRzENldEH3uy0AdHQrcM/RMiZM3pnHAU1l
ICeg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20251104; t=1781957147; x=1782561947;
h=mime-version:message-id:date:subject:to:from:x-gm-gg
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=KvRKJillqZa9lePuG6skSq5CuIbR7xiBsK2/2YvBePw=;
b=OVP8YfBjBnHOvtKH9Qa4dk1P8DkWW8FLiinrHlHJhVGi4PWvAxzTN34XqU1CwdJ4b6
3PRuOFrsCCSxINs+LGjtT/dGqTyq5hguGCoqISCg1luLyErjwDrNeQSN0EoKtn/3Fcmv
FySA2tFjtmSnizef5cogUshfZ77bCeUKZp0CsHQEMBgHJuWaEC0jMc0a/+H2c2FNhiaY
v15hqNabOmMiyeA647keFv9EGe1HRKX9u/LW1ERAylDAx6Sug6LL1Hgc4JcnsVf7nIAA
LVwfGwYxTufhno90JPb8JTWNUL5vRbvEZGvdfhmO0kfRapjnXAJeidBeDo8unLtc6Q6M
k/CA==
X-Gm-Message-State: AOJu0YzyKV0U+WMEZ+R/rVQbwjnkeJBGgxwJDZxw6UoLpuPDv35B/Wou
Nw+IvnLaKk+065XB53ojiQKmDcbWlpo+LvOmRe/AhvQ4l7VpAhrTCMygTIyj7ylv
X-Gm-Gg: AfdE7cn800Xp6BQ1TrfgPdnPvHdw1lW7qQGrerKlphH+UZ9ZC9nNR0PRsg88wvYPAlm
Imc3NYz34aw6vmsx6nOu/TAb+vT761o+0uVbcJK9am5TD/eFg1wWRCKc+5Y5LLypVtsa5rNm0H1
36G3tnZk1SKTjIGF8Zw7Bqzmn1+ybi1j5avW2BHdS8KsDm97nI80LbLs7oep4jhhpK6y54ccWK9
19v0iqgYAOUzZoSA2GFTMJvbE13TymlNXygejMd3qAStSbPLJnKY1EGPmpOxNU8Tzvr5/aupfzX
lNZ7IR1ZFa92nLfvDhkOiAncpj/L2o/X9asg4OjMFwhsK2ogBSXvy7gWalFVb4lRTSnxeWKtlIf
6Lo6jGOjEAAwzMBUTFQW6ex6RQqlWvMDLwjuNyfAYtxroM8hKQOMTGUkvjaIc6DMkEsu+tMlnHP
E4o9dVcVNoUyFxFYm9mdq2x+NnhUD4khTNo7En0doVBQEE+iDNBsj7uUZS0A==
X-Received: by 2002:a05:6402:5204:b0:697:7644:ea1a with SMTP id
4fb4d7f45d1cf-6977644ec14mr1169409a12.7.1781957146879;
Sat, 20 Jun 2026 05:05:46 -0700 (PDT)
Received: from localhost (0x573d6737.static.cust.fastspeed.dk. [87.61.103.55])
by smtp.gmail.com with UTF8SMTPSA id
4fb4d7f45d1cf-6977be498e4sm677480a12.20.2026.06.20.05.05.44
for <bug-gnu-emacs@HIDDEN>
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Sat, 20 Jun 2026 05:05:45 -0700 (PDT)
From: "Paul D. Nelson" <ultrono@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: [PATCH] Avoid Rmail auto-save coding prompts
Date: Sat, 20 Jun 2026 14:05:42 +0200
Message-ID: <uxsg7t4iixquw9.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Received-SPF: pass client-ip=2a00:1450:4864:20::530;
envelope-from=ultrono@HIDDEN; helo=mail-ed1-x530.google.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 2.0 (++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
has NOT identified this incoming email as spam. The original
message has been attached to this so you can view it or label
similar future email. If you have any questions, see
the administrator of that system for details.
Content preview: With emacs -Q (recent master), evaluate the following. It
creates two mbox files, visits one via find-file + rmail-mode (as happens
with an auto-mode-alist entry, or a bookmark), visits the other with [...]
Content analysis details: (2.0 points, 10.0 required)
pts rule name description
---- ---------------------- --------------------------------------------------
-0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/,
no trust [2001:470:142:0:0:0:0:17 listed in] [list.dnswl.org]
1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail)
0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail
provider (ultrono[at]gmail.com)
-0.0 SPF_HELO_PASS SPF: HELO matches SPF record
1.0 FORGED_GMAIL_RCVD 'From' gmail.com does not match 'Received'
headers
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)
--=-=-=
Content-Type: text/plain
With emacs -Q (recent master), evaluate the following. It creates two
mbox files, visits one via find-file + rmail-mode (as happens with an
auto-mode-alist entry, or a bookmark), visits the other with M-x rmail,
and uses M-x rmail-output to file a message from the second to the
first:
--8<---------------cut here---------------start------------->8---
(let* ((dir (make-temp-file "rmail-coding-repro" t))
(src (expand-file-name "src.mbox" dir))
(dst (expand-file-name "dst.mbox" dir)))
(let ((coding-system-for-write 'no-conversion))
(with-temp-file src
(set-buffer-multibyte nil)
(insert "From sender@HIDDEN Tue Jun 9 12:00:00 2026\n"
"From: sender@HIDDEN\n"
"To: recipient@HIDDEN\n"
"Subject: lunch\n"
"Date: Tue, 09 Jun 2026 12:00:00 +0000\n"
"\n"
"Caf\xe9\n"
"\n"))
(with-temp-file dst
(insert "From other@HIDDEN Tue Jun 9 11:00:00 2026\n"
"From: other@HIDDEN\n"
"To: recipient@HIDDEN\n"
"Subject: hello\n"
"Date: Tue, 09 Jun 2026 11:00:00 +0000\n"
"\n"
"Cafeteria\n"
"\n")))
(find-file dst)
(unless (derived-mode-p 'rmail-mode)
(rmail-mode))
(rmail src)
(rmail-output dst))
--8<---------------cut here---------------end--------------->8---
Then type M-x do-auto-save.
Expected: Auto-save completes silently, as usual.
Observed: A prompt "Select coding system (default raw-text):".
If auto-save fires while the minibuffer is in use (e.g., while saving an
attachment), we get "Command attempted to use minibuffer while in
minibuffer". With recursive minibuffers enabled, it can trigger a loop
and exceed the Lisp nesting limit.
The issue is that during auto-save, 'rmail-write-region-annotate'
switches to the view buffer and 'write-region' chooses a coding system
from that buffer's 'buffer-file-coding-system', rather than the
'no-conversion' coding that Rmail uses for normal saves.
The attached patch copies 'save-buffer-coding-system' to the view buffer
in 'rmail-write-region-annotate', so auto-save encodes the collection
the same way normal saves do.
Thanks, best,
Paul
--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
filename=0001-Avoid-Rmail-auto-save-coding-prompts.patch
From e3c2fe105f822a272d67889e7c7cceb8c313daed Mon Sep 17 00:00:00 2001
From: Paul Nelson <ultrono@HIDDEN>
Date: Fri, 5 Jun 2026 13:28:48 +0200
Subject: [PATCH] Avoid Rmail auto-save coding prompts
* lisp/mail/rmail.el (rmail-write-region-annotate): Copy
save-buffer-coding-system to the view buffer, so auto-save
encodes the same way normal saves do.
* test/lisp/mail/rmail-tests.el: Require cl-lib.
(rmail-autosave-does-not-query-coding-system): New test.
---
lisp/mail/rmail.el | 14 ++++++++---
test/lisp/mail/rmail-tests.el | 44 +++++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+), 3 deletions(-)
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index d51a90d1e63..a128cbe85ee 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -4915,9 +4915,17 @@ rmail-write-region-annotate
(error "Buffer `%s' with real text of `%s' has disappeared"
(buffer-name rmail-view-buffer)
(buffer-name (current-buffer))))
- (setq rmail-message-encoding buffer-file-coding-system)
- (set-buffer rmail-view-buffer)
- (widen)
+ (let ((coding-system save-buffer-coding-system))
+ (setq rmail-message-encoding buffer-file-coding-system)
+ (set-buffer rmail-view-buffer)
+ ;; `write-region' chooses a coding system after calling this
+ ;; hook. Normal saves dynamically bind `coding-system-for-write'
+ ;; from `save-buffer-coding-system', but auto-save calls
+ ;; `write-region' directly, so make the buffer being written use
+ ;; Rmail's save coding too.
+ (when coding-system
+ (setq buffer-file-coding-system coding-system))
+ (widen))
nil))
;; Used to restore the encoding of the buffer where we show the
diff --git a/test/lisp/mail/rmail-tests.el b/test/lisp/mail/rmail-tests.el
index 5877c562001..d1303a88d9a 100644
--- a/test/lisp/mail/rmail-tests.el
+++ b/test/lisp/mail/rmail-tests.el
@@ -18,6 +18,7 @@
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Code:
+(require 'cl-lib)
(require 'ert)
(require 'rmail)
@@ -31,5 +32,48 @@ rmail-autoload
(symbol-function
'rmail-edit-current-message))))
+(ert-deftest rmail-autosave-does-not-query-coding-system ()
+ "Auto-save of an Rmail buffer should not prompt for a coding system."
+ (let* ((dir (make-temp-file "rmail-test" t))
+ (src (expand-file-name "src.mbox" dir))
+ (dst (expand-file-name "dst.mbox" dir))
+ (coding-query nil))
+ (unwind-protect
+ (progn
+ (let ((coding-system-for-write 'no-conversion))
+ (with-temp-file src
+ (set-buffer-multibyte nil)
+ (insert "From sender@HIDDEN Tue Jun 9 12:00:00 2026\n"
+ "From: sender@HIDDEN\n"
+ "To: recipient@HIDDEN\n"
+ "Subject: lunch\n"
+ "Date: Tue, 09 Jun 2026 12:00:00 +0000\n"
+ "\n"
+ "Caf\xe9\n"
+ "\n"))
+ (with-temp-file dst
+ (insert "From other@HIDDEN Tue Jun 9 11:00:00 2026\n"
+ "From: other@HIDDEN\n"
+ "To: recipient@HIDDEN\n"
+ "Subject: hello\n"
+ "Date: Tue, 09 Jun 2026 11:00:00 +0000\n"
+ "\n"
+ "Cafeteria\n"
+ "\n")))
+ (find-file dst)
+ (unless (derived-mode-p 'rmail-mode)
+ (rmail-mode))
+ (rmail src)
+ (rmail-output dst)
+ (cl-letf (((symbol-function 'rmail-test--select-coding)
+ (lambda (&rest _)
+ (setq coding-query t)
+ 'no-conversion)))
+ (let ((select-safe-coding-system-function
+ 'rmail-test--select-coding))
+ (do-auto-save)))
+ (should-not coding-query))
+ (delete-directory dir t))))
+
(provide 'rmail-tests)
;;; rmail-tests.el ends here
--
2.50.1 (Apple Git-155)
--=-=-=--
"Paul D. Nelson" <ultrono@HIDDEN>:bug-gnu-emacs@HIDDEN.
Full text available.bug-gnu-emacs@HIDDEN:bug#81274; Package emacs.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.