Subject: Re: bug#79356: 31.0.50; 'C-x p r' fails when there are .gpg files EPA can't decrypt

From: Sean Whitton <[email-masked]>
Date: Tue, 02 Sep 2025 13:42:50 +0100

Hello,

On Mon 01 Sep 2025 at 11:45am -04, Stefan Monnier wrote:

>>> How 'bout we just prompt for all `file-error`s?  After all, the same
>>> kind of reasoning applies to invalid .gz files, or files for which we
>>> don't have read access, ...
>> I realised after trying out my patch a bit that the prompting is a bit
>> annoying.  It's common to interrupt and then restart 'C-x p r'
>> operations but that means you get prompted over and over again for the
>> same files.
>> How about converting `file-error's into warnings?
>
> Fine by me (probably better if they're batched).

delay-warning seems to be sufficient to batch them up.
Let me know what you think of this.

-- 
Sean Whitton
>From 056938803a5502f8427c6e97a74fa5b29a1d60c9 Mon Sep 17 00:00:00 2001
From: Sean Whitton <[email-masked]>
Date: Tue, 2 Sep 2025 13:42:26 +0100
Subject: [PATCH] fileloop-next-file: Convert file-error to warnings

* lisp/fileloop.el (fileloop-next-file): Catch file-error and
convert to a delayed warning (bug#79356).
---
 lisp/fileloop.el | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lisp/fileloop.el b/lisp/fileloop.el
index d7d2aa7e0d5..903c5cca0a7 100644
--- a/lisp/fileloop.el
+++ b/lisp/fileloop.el
@@ -121,10 +121,16 @@ fileloop-next-file
         (kill-all-local-variables)
         (erase-buffer)
         (setq new next)
-        (condition-case nil
+        (condition-case err
             (insert-file-contents new nil)
           (file-missing
-           (fileloop-next-file novisit))))
+           (fileloop-next-file novisit))
+          (file-error
+           ;; See bug#79356 for discussion.
+           (let ((msg (error-message-string err)))
+             (unless (string-search new msg)
+               (setq msg (format "%s, %s" msg new)))
+             (delay-warning 'file-error msg :error)))))
       new)))
 
 (defun fileloop-continue ()
-- 
2.47.3