From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.bugs Subject: bug#54542: 29.0.50; dired can't visit a local directory if another buffer visits an unreachable remote (TRAMP) directory Date: Fri, 25 Mar 2022 17:23:45 +0100 Message-ID: <875yo2huge.fsf@gmx.de> References: <87r16rstxd.fsf@secretsauce.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30412"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 54542@debbugs.gnu.org To: Dima Kogan Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Mar 25 17:24:16 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nXmjX-0007gY-98 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 25 Mar 2022 17:24:15 +0100 Original-Received: from localhost ([::1]:57592 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nXmjW-0006hq-7c for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 25 Mar 2022 12:24:14 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:55248) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nXmjK-0006hg-9S for bug-gnu-emacs@gnu.org; Fri, 25 Mar 2022 12:24:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58389) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nXmjK-0000yL-0v for bug-gnu-emacs@gnu.org; Fri, 25 Mar 2022 12:24:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nXmjJ-0006mQ-Tm for bug-gnu-emacs@gnu.org; Fri, 25 Mar 2022 12:24:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Albinus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 25 Mar 2022 16:24:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54542 X-GNU-PR-Package: emacs Original-Received: via spool by 54542-submit@debbugs.gnu.org id=B54542.164822543826052 (code B ref 54542); Fri, 25 Mar 2022 16:24:01 +0000 Original-Received: (at 54542) by debbugs.gnu.org; 25 Mar 2022 16:23:58 +0000 Original-Received: from localhost ([127.0.0.1]:52286 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nXmjF-0006m8-NK for submit@debbugs.gnu.org; Fri, 25 Mar 2022 12:23:58 -0400 Original-Received: from mout.gmx.net ([212.227.17.20]:33515) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nXmjD-0006lu-Iy for 54542@debbugs.gnu.org; Fri, 25 Mar 2022 12:23:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1648225427; bh=Ci7YHCFfQuAgIUSuLXxLDU+L/g9HIk8Q6Xt5ygARVa4=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=aHKMp/lJOwLH5AVj60GJx3RHUWmNWsnbqfGdeqAU2fcEhLFsA9c0B842qsOeXeJOI C+q4f0cwBNz7ii/8aIelyn8M/HSiX1O/pxZmteC8zJphCwDLs1TKo0Eh5NqALUOwhP ruRKZToLDxIy4bYqdxMZuxF0nIyIQHjX4fq+fedA= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from gandalf.gmx.de ([79.140.118.40]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MSKy8-1neH063R4S-00SbHk; Fri, 25 Mar 2022 17:23:46 +0100 In-Reply-To: <87r16rstxd.fsf@secretsauce.net> (Dima Kogan's message of "Thu, 24 Mar 2022 00:15:10 -0700") X-Provags-ID: V03:K1:T95BYNo3XRa8SVYbkcrb8j7BDvw/MyDTCr4Jl7Vfi6jjh3ZjllL 5Z6DNCPGPYNFqDQflgIk2IPIp8qyq2zFFiUrm4YR7GFPqXRRaVMVomxqMebCl2erBsrrVs1 ikSSyUdmfL6Z5YQBvRnnYH9LZLdcZotV9dpiIJ+Lp4IOZaYsKnWh43D+9Vriv1oXPRa2Y/G JYArbnejvTd1YJhfypv5Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:VeJweMqPEBw=:7VjFVbMYUp3bb20efS1I02 GnuDF4ht5CJrJiarDPXc6Fyx4DQr+deEQK77VmFNBq2pK+jEv1sKeZvs97dS4iHMYi2jIKpIZ k6t70ZNKfzY8OWE38bb7k7J+4px+5FfpodqMYJ8qUcFqwRD6l293/x6iRYdEJajMJ23g3rM9f lYzduTLX6KI876wK2a51PpMhpJRXpYW/ftRFweH2WvoDHCTUqjb1yr19YYgg6iPM6WzXD5pT3 6WuF/bdWFapuvGCMQZjPQMfJHrgjsvi5gHm+vtGbJKmVY+f6fWZP+B5ODfeSoOEssvMkRm+AH 5+vzkcHKVrpmM6PGueUnOm9hRcKlmaryJ4hK9Bp4Boad9kqfh6qZCpME9unGMmtSv0bdHNhLv 4rwu3KB7H2BLd2PdOMeAO7u7NsPrVJ4ZTd2Y1WHmad6KuO+0g2HU1+FwiBv+P5MobHEfhTord 4ZJilaX76XrPFZf5oQUaDLtO27l+qM6h6kQu92h4xiEiiFwI2nXXJ7FUu10rVUQ3QKeJcxZ+m SgLtcpDfx8ckSjvFFumZcynM1Se52INlJNMZFXVVzyYuDSRcFLYMJZkCfYodfUsqRp4dMbk6k JowPkihYpcTOireK4o8WEzWWYRE4Qv/PmuucZdL95Hfh0LWXnrE9wV32uF/rIrTwD1WBX5KEZ QN8udooVNcQibXhmmyoQ5tfee0uLbY3YwTKpeCKyKdMURw2fUqVjE4UXJdGogcF9EeE9vzW9q B+S/JKvGD9IeKZDkiIgpa0qkCoEqqivv0Yl9y0dJKTaeYqlU0R84HvRB0X2ADBznbiY+/Zka X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:228951 Archived-At: --=-=-= Content-Type: text/plain Dima Kogan writes: Hi Dima, > 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? We have already variable non-essential, which shall help for non-existing / broken connections. While I could reproduce your initial recipe locally, the attached patch cures it for me. Could you, please, test? > Thanks! Best regards, Michael. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment Content-Transfer-Encoding: quoted-printable diff --git a/lisp/dired.el b/lisp/dired.el index 3790197f66..a97604c4a0 100644 =2D-- a/lisp/dired.el +++ b/lisp/dired.el @@ -1272,6 +1272,7 @@ dired-find-buffer-nocreate ;; This differs from dired-buffers-for-dir in that it does not consider ;; subdirs of default-directory and searches for the first match only. ;; Also, the major mode must be MODE. + (let ((non-essential t)) (if (and (featurep 'dired-x) dired-find-subdir ;; Don't try to find a wildcard as a subdirectory. @@ -1304,7 +1305,7 @@ dired-find-buffer-nocreate (setq found (cdr (car blist)) blist nil) (setq blist (cdr blist)))))) - found))) + found)))) =0C ;;; Read in a new dired buffer diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index fd18b3f05c..805be8270a 100644 =2D-- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -4957,6 +4957,7 @@ tramp-maybe-open-connection ;; If Tramp opens the same connection within a short time frame, ;; there is a problem. We shall signal this. (unless (or (process-live-p p) + (and (processp p) (not non-essential)) (not (tramp-file-name-equal-p vec (car tramp-current-connection))) (time-less-p --=-=-=--