diff options
author | Michael Albinus <michael.albinus@gmx.de> | 2018-06-20 12:13:56 +0200 |
---|---|---|
committer | Michael Albinus <michael.albinus@gmx.de> | 2018-06-20 12:13:56 +0200 |
commit | 6f649e77b8512f73b17f03fd795beea9965c4029 (patch) | |
tree | c52a6a8413dab1e9af36d975869f16019230ad53 /lisp/net | |
parent | 3a47f3921bdaaf7b7d80dc3be05a5f1b1f2501eb (diff) | |
download | emacs-6f649e77b8512f73b17f03fd795beea9965c4029.tar.gz emacs-6f649e77b8512f73b17f03fd795beea9965c4029.tar.bz2 emacs-6f649e77b8512f73b17f03fd795beea9965c4029.zip |
Implement command completion in remote shells. (Bug#31704)
* doc/lispref/files.texi (Locating Files): Describe optional
argument REMOTE of `executable-find'.
(Magic File Names): Add `exec-path'.
* doc/lispref/processes.texi (Subprocess Creation): Describe
function `exec-path'.
* doc/misc/tramp.texi (Remote programs): Explain refresh of search
paths by `tramp-cleanup-this-connection'.
* etc/NEWS: Mention 'exec-path' and 'executable-find'.
* lisp/files.el (exec-path): New defun.
(executable-find): Add optional argument REMOTE.
* lisp/shell.el (shell-completion-vars): Set `comint-file-name-prefix'.
(shell--command-completion-data): Use `(exec-path)'. (Bug#31704)
* lisp/net/ange-ftp.el (exec-path):
* lisp/net/tramp.el (tramp-file-name-for-operation):
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist):
* lisp/net/tramp-archive.el (tramp-archive-file-name-handler-alist):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist):
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist)
<exec-path>: Add handler.
* lisp/net/tramp-adb.el (tramp-adb-handle-exec-path): New defun.
(tramp-adb-maybe-open-connection): Do not set "remote-path"
connection property.
* lisp/net/tramp-compat.el (tramp-compat-exec-path): New defun.
* lisp/net/tramp-sh.el (tramp-sh-handle-exec-path): New defun.
* lisp/net/tramp.el (tramp-eshell-directory-change): Use it.
* test/lisp/net/tramp-archive-tests.el
(tramp-archive-test38-make-nearby-temp-file)
(tramp-archive-test41-file-system-info)
(tramp-archive-test43-auto-load)
(tramp-archive-test43-delay-load): Rename.
* test/lisp/net/tramp-tests.el (tramp-test34-exec-path): New test.
(tramp-test36-make-auto-save-file-name)
(tramp-test37-find-backup-file-name)
(tramp-test38-make-nearby-temp-file)
(tramp-test39-special-characters)
(tramp-test39-special-characters-with-stat)
(tramp-test39-special-characters-with-perl)
(tramp-test39-special-characters-with-ls, tramp-test40-utf8)
(tramp-test40-utf8-with-stat, tramp-test40-utf8-with-perl)
(tramp-test40-utf8-with-ls, tramp-test41-file-system-info)
(tramp-test42-asynchronous-requests, tramp-test43-auto-load)
(tramp-test43-delay-load, tramp-test43-recursive-load)
(tramp-test43-remote-load-path, tramp-test44-unload): Rename.
Diffstat (limited to 'lisp/net')
-rw-r--r-- | lisp/net/ange-ftp.el | 1 | ||||
-rw-r--r-- | lisp/net/tramp-adb.el | 28 | ||||
-rw-r--r-- | lisp/net/tramp-archive.el | 1 | ||||
-rw-r--r-- | lisp/net/tramp-compat.el | 11 | ||||
-rw-r--r-- | lisp/net/tramp-gvfs.el | 1 | ||||
-rw-r--r-- | lisp/net/tramp-sh.el | 8 | ||||
-rw-r--r-- | lisp/net/tramp-smb.el | 1 | ||||
-rw-r--r-- | lisp/net/tramp.el | 18 |
8 files changed, 44 insertions, 25 deletions
diff --git a/lisp/net/ange-ftp.el b/lisp/net/ange-ftp.el index cf9667ac628..2fc7ac251ec 100644 --- a/lisp/net/ange-ftp.el +++ b/lisp/net/ange-ftp.el @@ -4439,6 +4439,7 @@ NEWNAME should be the name to give the new compressed or uncompressed file.") (put 'process-file 'ange-ftp 'ange-ftp-process-file) (put 'start-file-process 'ange-ftp 'ignore) (put 'shell-command 'ange-ftp 'ange-ftp-shell-command) +(put 'exec-path 'ange-ftp 'ignore) ;;; Define ways of getting at unmodified Emacs primitives, ;;; turning off our handler. diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index df2160770b1..7cb61adde80 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el @@ -107,6 +107,7 @@ It is used for TCP/IP devices." . tramp-adb-handle-directory-files-and-attributes) (dired-compress-file . ignore) (dired-uncache . tramp-handle-dired-uncache) + (exec-path . tramp-adb-handle-exec-path) (expand-file-name . tramp-adb-handle-expand-file-name) (file-accessible-directory-p . tramp-handle-file-accessible-directory-p) (file-acl . ignore) @@ -1116,6 +1117,21 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." (tramp-flush-connection-property v "process-name") (tramp-flush-connection-property v "process-buffer")))))) +(defun tramp-adb-handle-exec-path () + "Like `exec-path' for Tramp files." + (append + (with-parsed-tramp-file-name default-directory nil + (with-tramp-connection-property v "remote-path" + (tramp-adb-send-command v "echo \\\"$PATH\\\"") + (split-string + (with-current-buffer (tramp-get-connection-buffer v) + ;; Read the expression. + (goto-char (point-min)) + (read (current-buffer))) + ":" 'omit))) + ;; The equivalent to `exec-directory'. + `(,(file-local-name default-directory)))) + (defun tramp-adb-get-device (vec) "Return full host name from VEC to be used in shell execution. E.g. a host name \"192.168.1.1#5555\" returns \"192.168.1.1:5555\" @@ -1340,18 +1356,6 @@ connection if a previous connection has died for some reason." (tramp-error vec 'file-error "Cannot switch to user `%s'" user))) - ;; Set "remote-path" connection property. This is needed - ;; for eshell. - (tramp-adb-send-command vec "echo \\\"$PATH\\\"") - (tramp-set-connection-property - vec "remote-path" - (split-string - (with-current-buffer (tramp-get-connection-buffer vec) - ;; Read the expression. - (goto-char (point-min)) - (read (current-buffer))) - ":" 'omit)) - ;; Set connection-local variables. (tramp-set-connection-local-variables vec) diff --git a/lisp/net/tramp-archive.el b/lisp/net/tramp-archive.el index 42c3d40c1bb..5d7562f707e 100644 --- a/lisp/net/tramp-archive.el +++ b/lisp/net/tramp-archive.el @@ -220,6 +220,7 @@ It must be supported by libarchive(3).") . tramp-handle-directory-files-and-attributes) (dired-compress-file . tramp-archive-handle-not-implemented) (dired-uncache . tramp-archive-handle-dired-uncache) + (exec-path . ignore) ;; `expand-file-name' performed by default handler. (file-accessible-directory-p . tramp-handle-file-accessible-directory-p) (file-acl . ignore) diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el index aa0c99bf9cf..9af57fb0755 100644 --- a/lisp/net/tramp-compat.el +++ b/lisp/net/tramp-compat.el @@ -236,6 +236,17 @@ If NAME is a remote file name, the local part of NAME is unquoted." (defconst tramp-compat-use-url-tramp-p (fboundp 'temporary-file-directory) "Whether to use url-tramp.el.") +;; `exec-path' is new in Emacs 27.1. +(eval-and-compile + (if (fboundp 'exec-path) + (defalias 'tramp-compat-exec-path 'exec-path) + (defun tramp-compat-exec-path () + "List of directories to search programs to run in remote subprocesses." + (let ((handler (find-file-name-handler default-directory 'exec-path))) + (if handler + (funcall handler 'exec-path) + exec-path))))) + (add-hook 'tramp-unload-hook (lambda () (unload-feature 'tramp-loaddefs 'force) diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el index 87c0c796b69..a30d7ef7138 100644 --- a/lisp/net/tramp-gvfs.el +++ b/lisp/net/tramp-gvfs.el @@ -536,6 +536,7 @@ It has been changed in GVFS 1.14.") . tramp-handle-directory-files-and-attributes) (dired-compress-file . ignore) (dired-uncache . tramp-handle-dired-uncache) + (exec-path . ignore) (expand-file-name . tramp-gvfs-handle-expand-file-name) (file-accessible-directory-p . tramp-handle-file-accessible-directory-p) (file-acl . ignore) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 76dae9cea5e..0b3c12333f2 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -990,6 +990,7 @@ of command line.") . tramp-sh-handle-directory-files-and-attributes) (dired-compress-file . tramp-sh-handle-dired-compress-file) (dired-uncache . tramp-handle-dired-uncache) + (exec-path . tramp-sh-handle-exec-path) (expand-file-name . tramp-sh-handle-expand-file-name) (file-accessible-directory-p . tramp-handle-file-accessible-directory-p) (file-acl . tramp-sh-handle-file-acl) @@ -3083,6 +3084,13 @@ the result will be a local, non-Tramp, file name." (keyboard-quit) ret)))) +(defun tramp-sh-handle-exec-path () + "Like `exec-path' for Tramp files." + (append + (tramp-get-remote-path (tramp-dissect-file-name default-directory)) + ;; The equivalent to `exec-directory'. + `(,(file-local-name default-directory)))) + (defun tramp-sh-handle-file-local-copy (filename) "Like `file-local-copy' for Tramp files." (with-parsed-tramp-file-name filename nil diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el index 0334f052a07..335f05cfce0 100644 --- a/lisp/net/tramp-smb.el +++ b/lisp/net/tramp-smb.el @@ -229,6 +229,7 @@ See `tramp-actions-before-shell' for more info.") . tramp-handle-directory-files-and-attributes) (dired-compress-file . ignore) (dired-uncache . tramp-handle-dired-uncache) + (exec-path . ignore) (expand-file-name . tramp-smb-handle-expand-file-name) (file-accessible-directory-p . tramp-handle-file-accessible-directory-p) (file-acl . tramp-smb-handle-file-acl) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 1d6e0146c4d..d56b09a604d 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -2163,7 +2163,9 @@ ARGS are the arguments OPERATION has been called with." ((member operation '(process-file shell-command start-file-process ;; Emacs 26+ only. - make-nearby-temp-file temporary-file-directory)) + make-nearby-temp-file temporary-file-directory + ;; Emacs 27+ only. + exec-path)) default-directory) ;; PROC. ((member operation @@ -4616,19 +4618,9 @@ Only works for Bourne-like shells." ;; when `default-directory' points to another host. (defun tramp-eshell-directory-change () "Set `eshell-path-env' to $PATH of the host related to `default-directory'." + ;; Remove last element of `(exec-path)', which is `exec-directory'. (setq eshell-path-env - (if (tramp-tramp-file-p default-directory) - (with-parsed-tramp-file-name default-directory nil - (mapconcat - 'identity - (or - ;; When `tramp-own-remote-path' is in `tramp-remote-path', - ;; the remote path is only set in the session cache. - (tramp-get-connection-property - (tramp-get-connection-process v) "remote-path" nil) - (tramp-get-connection-property v "remote-path" nil)) - ":")) - (getenv "PATH")))) + (mapconcat 'identity (butlast (tramp-compat-exec-path)) ":"))) (eval-after-load "esh-util" '(progn |