GNU bug report logs - #79236
30.1; file-directory-p in read-file-name prevents TRAMP protocol, user, and host completions

Previous Next

Package: emacs;

Reported by: "Timothy J. Miller" <tmiller <at> mitre.org>

Date: Thu, 14 Aug 2025 13:38:02 UTC

Severity: normal

Tags: patch

Found in version 30.1

Fixed in version 31.1

Done: Michael Albinus <michael.albinus <at> gmx.de>

Full log


Message #33 received at 79236 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: Dmitry Gutov <dmitry <at> gutov.dev>, Eli Zaretskii <eliz <at> gnu.org>,
 tmiller <at> mitre.org, 79236 <at> debbugs.gnu.org
Subject: Re: bug#79236: 30.1; file-directory-p in read-file-name prevents
 TRAMP protocol, user, and host completions
Date: Sun, 31 Aug 2025 00:31:45 -0400
>>> The appended patch seems to fix it. But I don't know whether this is the
>>> way to go. Stefan?
>>
>> That looks ugly since the completion code should be "above" the
>> `file-name-handler-alist` abstraction and thus shouldn't have
>> Tramp-specific code.
>
> We're speaking about completion of Tramp method, user and host
> names. Something like "/ssh: user@ host:" - I've shown the word
> boundaries as space.

AFAICT the patch changes `completion-file-name-table` which knows
nothing about Tramp, so I don't understand what you mean by "We're
speaking about completion of Tramp ...".

> `file-directory-p' does TRT in Tramp in this case. But it isn't called,
> because of the bypass in `completion-file-name-table', which simply
> looks for a trailing "/". `file-name-handler-alist' abstraction broken.

Ah... right, here the code assumes that the elements returned by
`file-name-all-completions` which are directories all end in `/`, and
indeed that's not guaranteed to hold when we go through
`file-name-handler-alist`.

How 'bout the patch below instead (which generalizes your patch to
all file name handlers)?


        Stefan


diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 122459be062..e2920d76d92 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -3437,7 +3437,9 @@ completion-file-name-table
               (unless (memq pred '(nil file-exists-p))
                 (let ((comp ())
                       (pred
-                       (if (eq pred 'file-directory-p)
+                       (if (and (eq pred 'file-directory-p)
+                                (not (find-file-name-handler
+                                      realdir 'file-name-all-completions)))
                            ;; Brute-force speed up for directory checking:
                            ;; Discard strings which don't end in a slash.
                            (lambda (s)





This bug report was last modified 8 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.