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: Sun, 20 Aug 2023 12:53:09 +0200 Message-ID: <87wmxq7zoq.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> <87zg2m9b4u.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="25733"; 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 Sun Aug 20 12:54:22 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 1qXg4b-0006SB-Ur for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 20 Aug 2023 12:54:22 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qXg4I-0005cf-E2; Sun, 20 Aug 2023 06:54: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 1qXg4G-0005cX-Ji for bug-gnu-emacs@gnu.org; Sun, 20 Aug 2023 06:54:00 -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 1qXg4G-0004Id-C4 for bug-gnu-emacs@gnu.org; Sun, 20 Aug 2023 06:54:00 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qXg4H-0008Bm-TP for bug-gnu-emacs@gnu.org; Sun, 20 Aug 2023 06:54: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: Sun, 20 Aug 2023 10:54: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.169252880531432 (code B ref 65356); Sun, 20 Aug 2023 10:54:01 +0000 Original-Received: (at 65356) by debbugs.gnu.org; 20 Aug 2023 10:53:25 +0000 Original-Received: from localhost ([127.0.0.1]:53176 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qXg3h-0008Au-4C for submit@debbugs.gnu.org; Sun, 20 Aug 2023 06:53:25 -0400 Original-Received: from mout.gmx.net ([212.227.15.15]:60497) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qXg3e-0008Af-4u for 65356@debbugs.gnu.org; Sun, 20 Aug 2023 06:53:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1692528791; x=1693133591; i=michael.albinus@gmx.de; bh=msCkyaRYhnuORXu8vLzCSl3WbQv5kQ+Td/tnyddecI0=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date; b=plqatuG/sPZX2YyXx1tvbSDYukgrSjI6xKM11UzbHalEr+vw4G2PVEIMUZYao+ZKQDz/z7U UJUNsIXWXtGWOHJHTzKTr3qeEJNuLyvE4P6r1ky6jQNFFYta9zsx/2z1addF3pby6y5jEyQHf cSBCOYQKqmng33JcH6yb/rcIIU3JArLTp5FAsxDq+cjjtExnWdyhPhSKIrNwKKgMrgtSNETxi IpIG+HXO1TA8ea1UWQ3PD+YqgTgCfQSJBAdqwIOuWUez9mNf/oQ/D+LZBNM/ZD6YnGjluTSiI AnfAV54nEF7kjNHXP2TEE2SpKyminnB+wuRg4CcGY7UJCes4YZZA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from gandalf.gmx.de ([185.89.39.27]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Mi2Nv-1q2Ry200u1-00e82A; Sun, 20 Aug 2023 12:53:11 +0200 In-Reply-To: (Jim Porter's message of "Sat, 19 Aug 2023 22:23:41 -0700") X-Provags-ID: V03:K1:eB6d0EdVKp/WVuVxgHmO1N3E90bPDdEouGPcD9FfN8LG5/RvpY/ Oz4qVQv4W19rl+Atf9MVkFUsxxXDii3RApM3baC2EMjtpDXrCcSiF7+yyDwIYpkZo8KosEa t1zRjGXuD1TcUVXxVcz0N+BIHCei4Q04tsnp9waUkNvPVQ49u9viK62VpRnHh9to911Ifpz DSuAww4vSha+GzoxSDBTg== UI-OutboundReport: notjunk:1;M01:P0:lbExKHqaP/o=;UKeg6m8nMk9yISYOHCHfP/hyxJO Y5FFpwXBlt/gMIQ/qs81seCtrz85qxWDlU7FKnuWxDh4rfbp5d665iFEpcqsRwsnhuDQlZQ3c qr1m3/So5//VSTzpv1L5x4zZjTI2JIN61vZawUJpYEEF3aU+u8EVkjmO0Rr5GScGBMMzd9zIh jfUKbm9wGV4gm0nTDoC/bJ78+EjxG7+k082il9tiQ8bDKO6nS12CuNRTElTZQ35uM/CgCSsZN Wc6jDvzrJdPy+zLkHqlsfFBS+p494il8NCH9luB4I1dy1pzVmr8+adoz+Sa7Fn7OTeRydH5Mu zT3Hc8n6uPlq/HycF5Ongt8mB62QxCaaz4Ho2lCmXswmVCzgZngE7+5Cx0dqaoBtXy0IL75iW hcS7NI5p0vq4MArZYzBa7/oIpYdF6g86UBjtaqWjb4qIyIG969f8mn0dMYi8reyVzXStEKD10 RcvB4muVl/3MLY90J8Nm2vAz4YMS/R2sdfMq+pdiJkpWVJo7umeKDKYbqhqjHG4zhOkX4aH/C QMnNHC82kmwsE8LtuNx3gHyZYEaxB7OOHPow7um+rkRpIUYpjRmOgPWvTj2lD9oWnfJuN5H0n oC1BesQ744T/x2dkCVURJUliDIWMEh2vxU4+jqmNy3rV79VhXD9dVjGIhfCL2JXmr7tigZw2A 4FgYQI6+hinuPbxCavy4qpogyz92jBE5I9iBN/Z9HvsKGJANMBZeKJiroBvrAJx1n3cw0GvfD QrTt+uQbO7aRAZT/T6OoppG6o3hVECZOA0OTlsH8Xk7SAFTA1KRDJCLTWklV1xOsIvqsg+aG 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:267984 Archived-At: --=-=-= Content-Type: text/plain Jim Porter writes: Hi Jim, > This works for me, and I think it makes sense overall. It might be > nice to add the ability to ignore remote file names in Eshell when > completing an argument to an external command (which doesn't > understand Tramp syntax), but that would probably require a bunch of > work on the Eshell side, and we can worry about that later, I think. As POC, I've written the appended patch. It works for me in a simple case, but I'm pretty sure it needs to handle more cases. Since I'm not so familiar with Eshell, I let it to you :-) ... unless you say it is sufficient ATM. Best regards, Michael. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment Content-Transfer-Encoding: quoted-printable diff --git a/lisp/eshell/em-cmpl.el b/lisp/eshell/em-cmpl.el index 732bbb3f1fa..25dccbd695c 100644 =2D-- a/lisp/eshell/em-cmpl.el +++ b/lisp/eshell/em-cmpl.el @@ -148,6 +148,10 @@ eshell-cmpl-dir-ignore (eshell-cmpl--custom-variable-docstring 'pcomplete-dir-ignore) :type (get 'pcomplete-dir-ignore 'custom-type)) +(defcustom eshell-cmpl-remote-file-ignore nil + (eshell-cmpl--custom-variable-docstring 'pcomplete-remote-file-ignore) + :type (get 'pcomplete-remote-file-ignore 'custom-type)) + (defcustom eshell-cmpl-ignore-case (eshell-under-windows-p) (eshell-cmpl--custom-variable-docstring 'completion-ignore-case) :type (get 'completion-ignore-case 'custom-type)) @@ -248,6 +252,8 @@ eshell-cmpl-initialize eshell-cmpl-file-ignore) (setq-local pcomplete-dir-ignore eshell-cmpl-dir-ignore) + (setq-local pcomplete-remote-file-ignore + eshell-cmpl-remote-file-ignore) (setq-local completion-ignore-case eshell-cmpl-ignore-case) (setq-local pcomplete-autolist @@ -325,6 +331,15 @@ eshell-complete--eval-argument-form "Failed to evaluate argument form during completion: %S" arg) (propertize "\0" 'eshell-argument-stub 'error)))) +;; Code stolen from `eshell-plain-command'. +(defun eshell-external-command-p (command) + "Whether an external command shall be called." + (let* ((esym (eshell-find-alias-function command)) + (sym (or esym (intern-soft command)))) + (not (and sym (fboundp sym) + (or esym eshell-prefer-lisp-functions + (not (eshell-search-path command))))))) + (defun eshell-complete-parse-arguments () "Parse the command line arguments for `pcomplete-argument'." (when (and eshell-no-completion-during-jobs @@ -406,6 +421,14 @@ eshell-complete-parse-arguments args posns) (setq args (nreverse evaled-args) posns (nreverse evaled-posns))) + ;; Determine, whether remote file names shall be completed. They + ;; shouldn't for external commands, or when in a pipe. Respect + ;; also `eshell-cmpl-remote-file-ignore', which could be set by + ;; the user. + (setq-local pcomplete-remote-file-ignore + (or eshell-cmpl-remote-file-ignore + eshell-in-pipeline-p ; does not work + (eshell-external-command-p (car args)))) ;; Convert arguments to forms that Pcomplete can understand. (cons (mapcar (lambda (arg) --=-=-=--