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#65356: 30.0.50; [wishlist] Support Tramp method, user name and host name completion in eshell Date: Sat, 19 Aug 2023 19:48:17 +0200 Message-ID: <87zg2m9b4u.fsf@gmx.de> References: <87r0o1r1io.fsf@gmx.de> <4b4a64de-846a-ed2a-f409-80ea75e9cb57@gmail.com> <87il9crgqh.fsf@gmx.de> <87bkf4r2xd.fsf@gmx.de> <875y5cqt9a.fsf@gmx.de> 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="23884"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 65356@debbugs.gnu.org, Stefan Monnier To: Jim Porter Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Aug 19 19:49:25 2023 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 1qXQ4i-0005yv-L1 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 19 Aug 2023 19:49:24 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qXQ4M-00080o-Qf; Sat, 19 Aug 2023 13:49:02 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qXQ4L-00080g-4n for bug-gnu-emacs@gnu.org; Sat, 19 Aug 2023 13:49:01 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qXQ4K-0006zC-T6 for bug-gnu-emacs@gnu.org; Sat, 19 Aug 2023 13:49:00 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qXQ4L-00065M-Vy for bug-gnu-emacs@gnu.org; Sat, 19 Aug 2023 13:49:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Albinus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 19 Aug 2023 17:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65356 X-GNU-PR-Package: emacs Original-Received: via spool by 65356-submit@debbugs.gnu.org id=B65356.169246731523329 (code B ref 65356); Sat, 19 Aug 2023 17:49:01 +0000 Original-Received: (at 65356) by debbugs.gnu.org; 19 Aug 2023 17:48:35 +0000 Original-Received: from localhost ([127.0.0.1]:52235 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qXQ3v-00064B-0f for submit@debbugs.gnu.org; Sat, 19 Aug 2023 13:48:35 -0400 Original-Received: from mout.gmx.net ([212.227.15.18]:54445) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qXQ3q-000632-5f for 65356@debbugs.gnu.org; Sat, 19 Aug 2023 13:48:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1692467299; x=1693072099; i=michael.albinus@gmx.de; bh=HJKunOCVkzIArcrdRK7hBTM+ZRA1YudWYgDE4oiXdQ4=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date; b=OJ5kIiWnWh5Tcock980vl74F4EqfbtfIOP+pOCwusVSP7zhW01djrtwJIsnBcu6mGMF9Bf4 rQkTiGd11iL4O5NFu9OiITwMumcM2wrqVr7FJezjtdpuAOoryiKZ9+B+SDflcoAZ/0FvSuwRW dYa0WrlBfqV0j+T7Kk3KlQfhhvhXFVQdzoZ2aGN0Ijit1a07swT/x+FF1bTu5asrooxn3l7wj IJh0/eSwuCRXDSsyhOwZJMZwmn5BfZKQItGuc6h2aYmfYDbN4NRkPo9YpnGEKUEG7jyAZKvPx DjFuj61xCvFY7b0ycXNBuigq7aFUGhuUzcK3BK18Rz4iR6ilejEQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from gandalf.gmx.de ([185.89.39.27]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MKbkM-1qJCYx0iVQ-00L1SE; Sat, 19 Aug 2023 19:48:19 +0200 In-Reply-To: (Jim Porter's message of "Fri, 18 Aug 2023 20:26:54 -0700") X-Provags-ID: V03:K1:26VMUvrtQDEmjTS2Lt3V922GIrtM/EQTEIXRHjFnb9OTjd4s1FP 28h0SsgKZ/wS/7k3T4xgn1PC5lWjskcQ3orE3hgRfdyLfgO4CetVdVygQCJS2KARDPjM8fV V9r7Qz286lkX+blHe8zDsZ2020BaUNRHRjRJuSLqZDljRaTgq7To2U+9GfqEUKdLrv3YOM/ gPU7XO4qs8kKEucopht6A== UI-OutboundReport: notjunk:1;M01:P0:AEkh5nOEHWc=;7vPgsT4Zvm01bOHItL7a2+pzfHO +BKXAnx1cKPbxLRDXkMYjeTCqvWeapKK4/oMDNFUPuW3LPDRmP6O2x6mcfjBESRXMOZ7npibj k4BNood6O76MCN2Iqpgds/BuokubpO6Ig6ExQWCbJWrK5jIddbfzgdZT40bXhtoIuxxUhD9gh n5UQxx6eSU/bzu0wmmE1Si/59inhdApaNV7F8mzMEciVn/WEerEs1wTbPIIkb0DBGQ4SYkiPQ BevEgBFrdUA8h2b5ccbxlm4R/IZL1My8fH80q1mn9MEORehBZ7I2PT9arf50z2fpxIsJu2Pxg mz8GUHszxrTDuju4J/6v8onAJo9IQHDtCHYqnGdAav63oO3xfpE2nS1eGX/YnadyN+npxYQRS AflGSlGtwnS0EzEakQABBXKd3CS28m06wfziXfyoEUCtEUfMCgdt8Wo+6h7vIEptJHFAtF/cl ItGI8KijepdWPzn1qrrco7EKVJmG0F61FLA2Jsb1Y9m0BJBgJjEj5JZ7+MzydW7nlSm/pb4GP EUKsELNveJWg4hU3JMLV3VzIKBJvsBliTBRn/dMwT7N49967XaHh9WGUZDXXjU2ZQwpMUCrgx wPA03JRXoeVQsBK4VTeUHMqwVUWRfJH8Fl+PSKLLBe3hBFOIsc0i7xS3jiJ4RuPUYFOWc52S6 4YI58zdbeYVZQC/EZOiOP/QdixAe55u+8BirBdpf36A9cvta+rr37S4Ab9dW3giBHCJKD+NnO f+4ZI10IBXdvXMG9i8TrXYOuc6CW25SPPy8BE4cY1sEyx8EmIpHVJs4phNWJAUhuCrfVWxUA 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:267897 Archived-At: --=-=-= Content-Type: text/plain Jim Porter writes: Hi Jim & Stefan, >>> Yes. However, there is already another problem in shell-mode. My patch >>> completes only incomplete Tramp file names, like "/ss". Complete Tramp >>> file names are handled by pcomplete-dirs already. So we see in a *shell* >>> buffer, w/o my patch: >> Good point. >> Still, we have the problem that `pcomplete/` should be used >> only >> for external commands (because they are independent from the language >> used to write the command, a.k.a the shell), but for things like `cd` we >> should be more precise to distinguish the completion rules for Eshell's >> `cd` from those of bash's `cd`. > > That should be possible by defining 'pcomplete/eshell-mode/CMD', but > that runs into two issues: 1) it's annoying to manually write all of > these, and 2) there may be other contexts in Eshell we want to > tab-complete remote directories that aren't covered by the > command-specific Pcomplete functions like that. > > (#1 should be fixable with a new version of > 'eshell-eval-using-options', but I haven't looked at that in much > detail yet.) I gave it another try. There is a new user option pcomplete-remote-ignore. When nil (the default), pcomplete expands remote file names, including method, user name and host name. The corresponding let-bindings in pcomplete--entries are short. In shell-completion-vars, I set it buffer-local to t. This prevents remote file name completion in *shell* buffers, fixing also the bug mentioned above. In eshell I haven't set anything, so by default remote file names are expanded. It should be easy to set pcomplete-remote-ignore, depending on whether the command is a built-in (keep it nil), or an external command (set it to t). The patch is appended. Please note, that this has effect only when Tramp is loaded, so you might need to test with "emacs -Q -l tramp". People, who never use Tramp, won't see a difference. For testing you need a recent checkout of Emacs master, because I have added another function to tramp.el. This is already pushed to master. Comments? Best regards, Michael. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment Content-Transfer-Encoding: quoted-printable diff --git a/lisp/pcomplete.el b/lisp/pcomplete.el index c7ec228c1db..e8bede9d605 100644 =2D-- a/lisp/pcomplete.el +++ b/lisp/pcomplete.el @@ -138,6 +138,11 @@ pcomplete-dir-ignore "A regexp of names to be disregarded during directory completion." :type '(choice regexp (const :tag "None" nil))) +(defcustom pcomplete-remote-ignore nil + "Whether to ignore remote file names." + :version "30.1" + :type 'boolean) + (define-obsolete-variable-alias 'pcomplete-ignore-case 'completion-ignore= -case "28.1") @@ -924,7 +929,10 @@ pcomplete--entries (sort comps pcomplete-compare-entry-function))= ) ,@(cdr (completion-file-name-table s p a))) (let ((completion-ignored-extensions nil) - (completion-ignore-case completion-ignore-case)) + (completion-ignore-case completion-ignore-case) + (tramp-mode (and tramp-mode (not pcomplete-remote-ignore))) + (non-essential (not (file-remote-p s))) + (minibuffer-completing-file-name (not (file-remote-p s)))) (completion-table-with-predicate #'comint-completion-file-name-table pred 'strict s p a)))))) diff --git a/lisp/shell.el b/lisp/shell.el index 7ea9d1c2ead..17ab12dda6d 100644 =2D-- a/lisp/shell.el +++ b/lisp/shell.el @@ -595,6 +595,8 @@ shell-completion-vars ;; Don't use pcomplete's defaulting mechanism, rely on ;; shell-dynamic-complete-functions instead. (setq-local pcomplete-default-completion-function #'ignore) + ;; Do not expand remote file names. + (setq-local pcomplete-remote-ignore t) (setq-local comint-input-autoexpand shell-input-autoexpand) ;; Not needed in shell-mode because it's inherited from comint-mode, bu= t ;; placed here for read-shell-command. --=-=-=--