From: Dima Kogan <dima@secretsauce.net>
To: 54542@debbugs.gnu.org
Subject: bug#54542: 29.0.50; dired can't visit a local directory if another buffer visits an unreachable remote (TRAMP) directory
Date: Thu, 24 Mar 2022 00:15:10 -0700 [thread overview]
Message-ID: <87r16rstxd.fsf@secretsauce.net> (raw)
Hi. This sounds convoluted, but it's a real-life bug I hit repeatedly.
Recipe:
1. emacs -Q
2. C-x C-f /ssh:host:directory
Visit some remote directory via TRAMP. This opens a dired buffer
3. Unplug the network cable. Or walk away from wifi. Or turn off the
remote host. Optionally, do other stuff with emacs. The bug is hit if
the buffer in step 2 is open somewhere; doesn't have to be visible
4. C-x C-f /some/local/directory
One would expect step 4 to work just fine because it's a local
directory, so no TRAMP business should affect it, but it does. Step 4
will try to connect to the host in step 2. But that host is gone, so
it'll fail, and step 4 will fail too.
The problem is here:
(defun dired-find-buffer-nocreate (dirname &optional mode)
....
(let (found (blist dired-buffers))
...
(while blist
...
(with-current-buffer (cdr (car blist))
....
(expand-file-name
(if (consp dired-directory)
(car dired-directory)
dired-directory))))
Here dired is trying to figure out if we're already visiting the
requested directory. In doing so, it loops through all extant dired
buffers, and runs (expand-file-name) on each one. Running
(expand-file-name) on a remote directory will try to contact the host.
I'm not attaching a patch because I'm not 100% sure what's appropriate.
I guess we want to replace
(expand-file-name dired-directory)
with something like this pseudo-code
(concat (tramp-host dired-directory)
(expand-file-name (tramp-filename dired-directory)))
Except, thinking about edge cases: making sure this works with/without
TRAMP, making sure relative directories work right, etc, etc.
Do we already have a function that does this?
Thanks!
next reply other threads:[~2022-03-24 7:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-24 7:15 Dima Kogan [this message]
2022-03-25 16:23 ` bug#54542: 29.0.50; dired can't visit a local directory if another buffer visits an unreachable remote (TRAMP) directory Michael Albinus
2022-03-25 23:15 ` Dima Kogan
2022-03-26 10:57 ` Michael Albinus
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=87r16rstxd.fsf@secretsauce.net \
--to=dima@secretsauce.net \
--cc=54542@debbugs.gnu.org \
/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).