diff options
| author | Michael Albinus | 2023-08-23 09:53:40 +0200 |
|---|---|---|
| committer | Michael Albinus | 2023-08-23 09:53:40 +0200 |
| commit | 26ca3e84e167f975afb4e9e9a838935bfe4a19a7 (patch) | |
| tree | 504bce4c3f89524bc25f990635fa4520db01c0f2 | |
| parent | 81fc5d83fe71ef218f59d65040474bf4b5d2228e (diff) | |
| download | emacs-26ca3e84e167f975afb4e9e9a838935bfe4a19a7.tar.gz emacs-26ca3e84e167f975afb4e9e9a838935bfe4a19a7.zip | |
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.
| -rw-r--r-- | lisp/eshell/em-cmpl.el | 23 |
1 files changed, 23 insertions, 0 deletions
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." | |||
| 148 | (eshell-cmpl--custom-variable-docstring 'pcomplete-dir-ignore) | 148 | (eshell-cmpl--custom-variable-docstring 'pcomplete-dir-ignore) |
| 149 | :type (get 'pcomplete-dir-ignore 'custom-type)) | 149 | :type (get 'pcomplete-dir-ignore 'custom-type)) |
| 150 | 150 | ||
| 151 | (defcustom eshell-cmpl-remote-file-ignore nil | ||
| 152 | (eshell-cmpl--custom-variable-docstring 'pcomplete-remote-file-ignore) | ||
| 153 | :type (get 'pcomplete-remote-file-ignore 'custom-type)) | ||
| 154 | |||
| 151 | (defcustom eshell-cmpl-ignore-case (eshell-under-windows-p) | 155 | (defcustom eshell-cmpl-ignore-case (eshell-under-windows-p) |
| 152 | (eshell-cmpl--custom-variable-docstring 'completion-ignore-case) | 156 | (eshell-cmpl--custom-variable-docstring 'completion-ignore-case) |
| 153 | :type (get 'completion-ignore-case 'custom-type)) | 157 | :type (get 'completion-ignore-case 'custom-type)) |
| @@ -248,6 +252,8 @@ to writing a completion function." | |||
| 248 | eshell-cmpl-file-ignore) | 252 | eshell-cmpl-file-ignore) |
| 249 | (setq-local pcomplete-dir-ignore | 253 | (setq-local pcomplete-dir-ignore |
| 250 | eshell-cmpl-dir-ignore) | 254 | eshell-cmpl-dir-ignore) |
| 255 | (setq-local pcomplete-remote-file-ignore | ||
| 256 | eshell-cmpl-remote-file-ignore) | ||
| 251 | (setq-local completion-ignore-case | 257 | (setq-local completion-ignore-case |
| 252 | eshell-cmpl-ignore-case) | 258 | eshell-cmpl-ignore-case) |
| 253 | (setq-local pcomplete-autolist | 259 | (setq-local pcomplete-autolist |
| @@ -325,6 +331,15 @@ to writing a completion function." | |||
| 325 | "Failed to evaluate argument form during completion: %S" arg) | 331 | "Failed to evaluate argument form during completion: %S" arg) |
| 326 | (propertize "\0" 'eshell-argument-stub 'error)))) | 332 | (propertize "\0" 'eshell-argument-stub 'error)))) |
| 327 | 333 | ||
| 334 | ;; Code stolen from `eshell-plain-command'. | ||
| 335 | (defun eshell-external-command-p (command) | ||
| 336 | "Whether an external command shall be called." | ||
| 337 | (let* ((esym (eshell-find-alias-function command)) | ||
| 338 | (sym (or esym (intern-soft command)))) | ||
| 339 | (not (and sym (fboundp sym) | ||
| 340 | (or esym eshell-prefer-lisp-functions | ||
| 341 | (not (eshell-search-path command))))))) | ||
| 342 | |||
| 328 | (defun eshell-complete-parse-arguments () | 343 | (defun eshell-complete-parse-arguments () |
| 329 | "Parse the command line arguments for `pcomplete-argument'." | 344 | "Parse the command line arguments for `pcomplete-argument'." |
| 330 | (when (and eshell-no-completion-during-jobs | 345 | (when (and eshell-no-completion-during-jobs |
| @@ -406,6 +421,14 @@ to writing a completion function." | |||
| 406 | args posns) | 421 | args posns) |
| 407 | (setq args (nreverse evaled-args) | 422 | (setq args (nreverse evaled-args) |
| 408 | posns (nreverse evaled-posns))) | 423 | posns (nreverse evaled-posns))) |
| 424 | ;; Determine, whether remote file names shall be completed. They | ||
| 425 | ;; shouldn't for external commands, or when in a pipe. Respect | ||
| 426 | ;; also `eshell-cmpl-remote-file-ignore', which could be set by | ||
| 427 | ;; the user. | ||
| 428 | (setq-local pcomplete-remote-file-ignore | ||
| 429 | (or eshell-cmpl-remote-file-ignore | ||
| 430 | eshell-in-pipeline-p ; does not work | ||
| 431 | (eshell-external-command-p (car args)))) | ||
| 409 | ;; Convert arguments to forms that Pcomplete can understand. | 432 | ;; Convert arguments to forms that Pcomplete can understand. |
| 410 | (cons (mapcar | 433 | (cons (mapcar |
| 411 | (lambda (arg) | 434 | (lambda (arg) |