From: Michael Albinus <michael.albinus@gmx.de>
To: Jim Porter <jporterbugs@gmail.com>
Cc: 65356@debbugs.gnu.org, Stefan Monnier <monnier@iro.umontreal.ca>
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 [thread overview]
Message-ID: <87wmxq7zoq.fsf@gmx.de> (raw)
In-Reply-To: <c778b755-0206-8000-bb42-d91260fed8a4@gmail.com> (Jim Porter's message of "Sat, 19 Aug 2023 22:23:41 -0700")
[-- Attachment #1: Type: text/plain, Size: 649 bytes --]
Jim Porter <jporterbugs@gmail.com> 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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 2518 bytes --]
diff --git a/lisp/eshell/em-cmpl.el b/lisp/eshell/em-cmpl.el
index 732bbb3f1fa..25dccbd695c 100644
--- 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)
next prev parent reply other threads:[~2023-08-20 10:53 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-17 18:01 bug#65356: 30.0.50; [wishlist] Support Tramp method, user name and host name completion in eshell Michael Albinus
2023-08-18 3:31 ` Jim Porter
2023-08-18 6:45 ` Michael Albinus
2023-08-18 11:43 ` Michael Albinus
2023-08-18 13:25 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-18 15:12 ` Michael Albinus
2023-08-18 22:33 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-19 3:26 ` Jim Porter
2023-08-19 17:48 ` Michael Albinus
2023-08-19 18:37 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-19 19:14 ` Michael Albinus
2023-08-20 0:02 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-20 7:50 ` Michael Albinus
2023-08-20 5:23 ` Jim Porter
2023-08-20 10:53 ` Michael Albinus [this message]
2023-08-23 0:30 ` Jim Porter
2023-08-23 7:56 ` Michael Albinus
2023-08-18 17:50 ` 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=87wmxq7zoq.fsf@gmx.de \
--to=michael.albinus@gmx.de \
--cc=65356@debbugs.gnu.org \
--cc=jporterbugs@gmail.com \
--cc=monnier@iro.umontreal.ca \
/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).