unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: michael.albinus@gmx.de, 42431@debbugs.gnu.org
Subject: bug#42431: 28.0.50; browse-url-of-dired-file confusing messaging
Date: Sun, 09 Aug 2020 11:35:25 +0200	[thread overview]
Message-ID: <87pn80w49u.fsf@gnus.org> (raw)
In-Reply-To: <83y2mp5te0.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 08 Aug 2020 13:22:47 +0300")

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Lars Ingebrigtsen <larsi@gnus.org>
>> Cc: michael.albinus@gmx.de,  42431@debbugs.gnu.org
>> Date: Sat, 08 Aug 2020 12:05:04 +0200
>> 
>> >> 	  (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)))
>> >
>> > Is this because file-readable-p returns nil for file:// URLs?
>> 
>> That's the direct cause of the message, but the underlying reason is
>> that insert-file-contents-literally signalled a file-error here (after
>> inserting the contents).  I haven't yet chased down why.

My analysis here was kinda wrong -- the code above isn't what gives the
warning, because all those functions up there do the right thing, since
file-name-handler-alist is set:

  (let ((file-name-handler-alist
         (cons (cons url-handler-regexp 'url-file-handler)
               file-name-handler-alist)))
    (list (file-exists-p "file:///tmp/a.txt")
	  (file-readable-p "file:///tmp/a.txt")))
=> (t t)

The problem is that insert-file-contents signals a file-error, and the
error string is "Success".  This makes things confused, because it knows
that it has an error, but when it tests for all things that could go
wrong, it doesn't find anything, and ends up here:

(defun after-find-file (&optional error warn noauto
				  _after-find-file-from-revert-buffer
				  nomodes)
[...]
	     ((and error (file-attributes buffer-file-name))
	      (setq buffer-read-only t)
	      (if (and (file-symlink-p buffer-file-name)
		       (not (file-exists-p
			     (file-chase-links buffer-file-name))))
		  "Symbolic link that points to nonexistent file"
		"File exists, but cannot be read"))

Which is where the message itself comes from.

> So one solution would be to convert file:// URLs into local file names
> in the above snippet, before calling insert-file-contents-literally.

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

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





  reply	other threads:[~2020-08-09  9:35 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-19 19:34 bug#42431: 28.0.50; browse-url-of-dired-file confusing messaging Lars Ingebrigtsen
2020-07-19 19:37 ` Lars Ingebrigtsen
2020-07-27 22:24 ` Lars Ingebrigtsen
2020-08-08  7:46   ` Eli Zaretskii
2020-08-08 10:05     ` Lars Ingebrigtsen
2020-08-08 10:22       ` Eli Zaretskii
2020-08-09  9:35         ` Lars Ingebrigtsen [this message]
2020-08-09  9:45           ` Lars Ingebrigtsen
2020-08-09 14:05             ` Eli Zaretskii
2020-08-09 14:08               ` Lars Ingebrigtsen
2022-10-13  7:00             ` Lars Ingebrigtsen
2022-10-13  8:51               ` Paul Eggert
2022-10-13 10:35                 ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pn80w49u.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=42431@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=michael.albinus@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).