[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 26ca3e84e16: Enable remote file name completion in eshell dependi
From: |
Michael Albinus |
Subject: |
master 26ca3e84e16: Enable remote file name completion in eshell depending on command (bug#65356) |
Date: |
Wed, 23 Aug 2023 03:54:06 -0400 (EDT) |
branch: master
commit 26ca3e84e167f975afb4e9e9a838935bfe4a19a7
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>
Enable remote file name completion in eshell depending on command
(bug#65356)
* lisp/eshell/em-cmpl.el (eshell-cmpl-remote-file-ignore):
New user option.
(eshell-cmpl-initialize): Use it.
(eshell-external-command-p): New defun.
(eshell-complete-parse-arguments):
Set `pcomplete-remote-file-ignore' depending on the command.
---
lisp/eshell/em-cmpl.el | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
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 @@ to writing a completion function."
(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 @@ to writing a completion function."
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 @@ to writing a completion function."
"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 @@ to writing a completion function."
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)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 26ca3e84e16: Enable remote file name completion in eshell depending on command (bug#65356),
Michael Albinus <=