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

From: Lars Ingebrigtsen <[email-masked]>
Date: Tue, 28 Jul 2020 00:24:23 +0200

Lars Ingebrigtsen <[email-masked]> writes:

> Create a file /tmp/a.txt, and visit /tmp.
> M-x browse-url-of-dired-file on the file.
>
> Emacs will say:
>
> File exists, but cannot be read
>
> and then display the file in a text-mode buffer.

Here's a simpler reproduction.  Ensure that /tmp/a.txt exists, and then
eval:

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

The message originates from here, sort of:

(defun find-file-noselect-1 (buf filename nowarn rawfile truename number)

[...]

	  (condition-case ()
	      (let ((inhibit-read-only t))
		(insert-file-contents-literally filename t))
	    (file-error
	     (when (and (file-exists-p filename)
			(not (file-readable-p filename)))
	       (kill-buffer buf)
	       (signal 'file-error (list "File is not readable"
					 filename)))

If we remove that condition-case, we get:

Debugger entered--Lisp error: (file-error "Opening input file" "Success")
  insert-file-contents("file:///tmp/a.txt" t)

So the insert-file-contents-literally signals a "Success" file-error
when using url-handler-mode.

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