unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#41414: 28.0.50; `find-file-noselect' + `file-truename' gotcha
@ 2020-05-20  0:34 Michael Heerdegen
  2022-06-06 13:50 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Heerdegen @ 2020-05-20  0:34 UTC (permalink / raw)
  To: 41414


Hello,

`find-file-noselect' tries to reuse buffers already visiting the file
under a different name, e.g. via a symlink, but it doesn't check if that
name is still valid (which is not the case when the symlink has been
deleted after the file has been visited using this name).  The behavior
makes it hard to visit the file under its valid name because Emacs
tries to revert the existing buffer which fails.

Here is a recipe, I start with a directory like this:

  /home/micha/Treasure/today/test:
  total used in directory 29 available 123.8 GiB
  drwxrwxr-x  2 micha micha     4k 05-20 02:20 .
  drwxr-xr-x 69 micha micha    24k 05-20 02:19 ..
  -rw-rw-r--  1 micha micha      5 05-20 02:20 a
S lrwxrwxrwx  1 micha micha      1 05-20 02:21 b -> a

I visit b (I did that from dired), then, without killing the b visiting
buffer, I delete the b -> a symlink, then I try to visit "a" and get:

Debugger entered--Lisp error: (error "File /home/micha/today/test/b no longer exists!")
  signal(error ("File /home/micha/today/test/b no longer exists!"))
  error("File %s no longer exists!" "/home/micha/today/test/b")
  revert-buffer-insert-file-contents--default-function("/home/micha/today/test/b" nil)
  revert-buffer--default(t t)
  revert-buffer(t t)
  find-file-noselect("/home/micha/today/test/a")
  view-file("/home/micha/today/test/a")
  dired-view-file()
  funcall-interactively(dired-view-file)
  call-interactively(dired-view-file nil nil)
  command-execute(dired-view-file)

Depending on `revert-without-query' you are asked whether to revert the
"b" buffer.  That will fail.  That "b" buffer should better be ignored
by Emacs to avoid confusion.

Thanks,

Michael.








^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#41414: 28.0.50; `find-file-noselect' + `file-truename' gotcha
  2020-05-20  0:34 bug#41414: 28.0.50; `find-file-noselect' + `file-truename' gotcha Michael Heerdegen
@ 2022-06-06 13:50 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-06 13:50 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: 41414

Michael Heerdegen <michael_heerdegen@web.de> writes:

> Here is a recipe, I start with a directory like this:
>
>   /home/micha/Treasure/today/test:
>   total used in directory 29 available 123.8 GiB
>   drwxrwxr-x  2 micha micha     4k 05-20 02:20 .
>   drwxr-xr-x 69 micha micha    24k 05-20 02:19 ..
>   -rw-rw-r--  1 micha micha      5 05-20 02:20 a
> S lrwxrwxrwx  1 micha micha      1 05-20 02:21 b -> a
>
> I visit b (I did that from dired), then, without killing the b visiting
> buffer, I delete the b -> a symlink, then I try to visit "a" and get:
>
> Debugger entered--Lisp error: (error "File /home/micha/today/test/b no
> longer exists!")
>   signal(error ("File /home/micha/today/test/b no longer exists!"))
>   error("File %s no longer exists!" "/home/micha/today/test/b")

This no longer happens in Emacs 29, but the subsequent problems are
still present.  That is, trying to revert the buffer etc will lead to
errors.

So I've now changed find-file-noselect to ignore buffers with file names
that no longer exist in Emacs 29.

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





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-06-06 13:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-20  0:34 bug#41414: 28.0.50; `find-file-noselect' + `file-truename' gotcha Michael Heerdegen
2022-06-06 13:50 ` Lars Ingebrigtsen

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).