Subject: bug#42431: 28.0.50; browse-url-of-dired-file confusing messaging

From: Lars Ingebrigtsen <[email-masked]>
Date: Sun, 09 Aug 2020 11:45:05 +0200

Lars Ingebrigtsen <[email-masked]> writes:

> It would be, but I think this points to an error in insert-file-contents
> itself.  I'll poke around some more...

Yup.  The error signalling comes from Finsert_file_contents.  If I make
this change, then the confusing messaging goes away:

diff --git a/src/fileio.c b/src/fileio.c
index 37072d9b6b..05e262b201 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -4826,7 +4826,6 @@ because (1) it preserves some marker positions and (2) it puts less data
   if (!NILP (visit) && current_buffer->modtime.tv_nsec < 0)
     {
       /* Signal an error if visiting a file that could not be opened.  */
-      report_file_errno ("Opening input file", orig_filename, save_errno);
     }
 
   /* We made a lot of deletions and insertions above, so invalidate

This was apparently introduced/changed in 2019 by this patch:

commit 3a1e7624ed234bb434cdafed59515cadd037cafa
Author:     Paul Eggert <[email-masked]>
AuthorDate: Thu Oct 31 23:31:17 2019 -0700
Commit:     Paul Eggert <[email-masked]>
CommitDate: Thu Oct 31 23:32:05 2019 -0700

    Fix insert-file-contents file error regression
    
    Problem reported for dired-view-file (Bug#37950).
    * src/fileio.c (Finsert_file_contents): When visiting,
    signal an error if the file could not be opened for any reason,
    rather than signaling an error only for nonexistent files, fixing
    a bug introduced in 2019-09-16T03:17:[email-masked].

I've Cc'd Paul on this.  Paul, the test case is:

(browse-url-of-file "/tmp/a.txt")

This will open the file correctly (via the url-file-handler file name
handler), but Emacs will then message "File exists, but cannot be read"
because Finsert_file_contents signals an error with the error message
"Success".

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no