From 3ea89acac24149a06746740785906f56c89eaf1f Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Sun, 23 Dec 2018 09:48:05 +0100 Subject: [PATCH] Handle `make-process' in Tramp and ange-ftp * doc/lispref/processes.texi (Asynchronous Processes): Explain, that not all file name handlers support `make-process'. * lisp/net/ange-ftp.el: * 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-rclone.el (tramp-rclone-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): * lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist): * lisp/net/tramp.el (tramp-file-name-for-operation): Add `make-process'. * lisp/vc/ediff-util.el: * src/process.c: * test/src/process-tests.el: Use "file name handler" consequently. --- doc/lispref/processes.texi | 19 ++++++++++++++----- lisp/net/ange-ftp.el | 3 ++- lisp/net/tramp-adb.el | 1 + lisp/net/tramp-archive.el | 1 + lisp/net/tramp-gvfs.el | 1 + lisp/net/tramp-rclone.el | 1 + lisp/net/tramp-sh.el | 1 + lisp/net/tramp-smb.el | 1 + lisp/net/tramp-sudoedit.el | 1 + lisp/net/tramp.el | 2 +- lisp/vc/ediff-util.el | 6 +++--- src/process.c | 2 +- test/src/process-tests.el | 8 ++++---- 13 files changed, 32 insertions(+), 15 deletions(-) diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi index d72f5b880a2..c6ffb2815e0 100644 --- a/doc/lispref/processes.texi +++ b/doc/lispref/processes.texi @@ -700,8 +700,8 @@ output, and both are sent to @var{buffer} or @var{filter}. @item :file-handler @var{file-handler} If @var{file-handler} is non-@code{nil}, then look for a file name handler for the current buffer's @code{default-directory}, and invoke -that file handler to make the process. If there is no such handler, -proceed as if @var{file-handler} were @code{nil}. +that file name handler to make the process. If there is no such +handler, proceed as if @var{file-handler} were @code{nil}. @end table The original argument list, modified with the actual connection @@ -709,9 +709,18 @@ information, is available via the @code{process-contact} function. The current working directory of the subprocess is set to the current buffer's value of @code{default-directory} if that is local (as -determined by `unhandled-file-name-directory'), or "~" otherwise. If -you want to run a process in a remote directory, pass -@code{:file-handler t} to @code{make-process}. +determined by @code{unhandled-file-name-directory}), or @file{~} +otherwise. If you want to run a process in a remote directory, pass +@code{:file-handler t} to @code{make-process}. In that case, the +current working directory is the local name component of +@code{default-directory} (as determined by @code{file-local-name}). + +Depending on the implementation of the file name handler, it might not +be possible to apply @var{filter} or @var{sentinel} to the resulting +process object. @xref{Filter Functions}, and @ref{Sentinels}. + +Some file name handlers may not support @code{make-process}. In such +cases, this function does nothing and returns @code{nil}. @end defun @defun make-pipe-process &rest args diff --git a/lisp/net/ange-ftp.el b/lisp/net/ange-ftp.el index 37df7930469..8828010ab41 100644 --- a/lisp/net/ange-ftp.el +++ b/lisp/net/ange-ftp.el @@ -4441,10 +4441,11 @@ NEWNAME should be the name to give the new compressed or uncompressed file.") ;; We can handle process-file in a restricted way (just for chown). ;; Nothing possible for `start-file-process'. +(put 'exec-path 'ange-ftp 'ignore) +(put 'make-process 'ange-ftp 'ignore) (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 4d92ae91fa5..5f0b9dad31d 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el @@ -144,6 +144,7 @@ It is used for TCP/IP devices." (make-directory . tramp-adb-handle-make-directory) (make-directory-internal . ignore) (make-nearby-temp-file . tramp-handle-make-nearby-temp-file) + (make-process . ignore) (make-symbolic-link . tramp-handle-make-symbolic-link) (process-file . tramp-adb-handle-process-file) (rename-file . tramp-adb-handle-rename-file) diff --git a/lisp/net/tramp-archive.el b/lisp/net/tramp-archive.el index 02580359f73..03b1eed9704 100644 --- a/lisp/net/tramp-archive.el +++ b/lisp/net/tramp-archive.el @@ -261,6 +261,7 @@ It must be supported by libarchive(3).") (make-directory . tramp-archive-handle-not-implemented) (make-directory-internal . tramp-archive-handle-not-implemented) (make-nearby-temp-file . tramp-handle-make-nearby-temp-file) + (make-process . ignore) (make-symbolic-link . tramp-archive-handle-not-implemented) (process-file . ignore) (rename-file . tramp-archive-handle-not-implemented) diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el index 2321617b0ac..718db34f268 100644 --- a/lisp/net/tramp-gvfs.el +++ b/lisp/net/tramp-gvfs.el @@ -578,6 +578,7 @@ It has been changed in GVFS 1.14.") (make-directory . tramp-gvfs-handle-make-directory) (make-directory-internal . ignore) (make-nearby-temp-file . tramp-handle-make-nearby-temp-file) + (make-process . ignore) (make-symbolic-link . tramp-handle-make-symbolic-link) (process-file . ignore) (rename-file . tramp-gvfs-handle-rename-file) diff --git a/lisp/net/tramp-rclone.el b/lisp/net/tramp-rclone.el index f1a2cd81c67..d5e268eb20c 100644 --- a/lisp/net/tramp-rclone.el +++ b/lisp/net/tramp-rclone.el @@ -122,6 +122,7 @@ (make-directory . tramp-rclone-handle-make-directory) (make-directory-internal . ignore) (make-nearby-temp-file . tramp-handle-make-nearby-temp-file) + (make-process . ignore) (make-symbolic-link . tramp-handle-make-symbolic-link) (process-file . ignore) (rename-file . tramp-rclone-handle-rename-file) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index ba652bddd35..308f33896c6 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -995,6 +995,7 @@ of command line.") (make-directory . tramp-sh-handle-make-directory) ;; `make-directory-internal' performed by default handler. (make-nearby-temp-file . tramp-handle-make-nearby-temp-file) + (make-process . ignore) (make-symbolic-link . tramp-sh-handle-make-symbolic-link) (process-file . tramp-sh-handle-process-file) (rename-file . tramp-sh-handle-rename-file) diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el index ee19f9859f8..c9f23afeccf 100644 --- a/lisp/net/tramp-smb.el +++ b/lisp/net/tramp-smb.el @@ -268,6 +268,7 @@ See `tramp-actions-before-shell' for more info.") (make-directory . tramp-smb-handle-make-directory) (make-directory-internal . tramp-smb-handle-make-directory-internal) (make-nearby-temp-file . tramp-handle-make-nearby-temp-file) + (make-process . ignore) (make-symbolic-link . tramp-smb-handle-make-symbolic-link) (process-file . tramp-smb-handle-process-file) (rename-file . tramp-smb-handle-rename-file) diff --git a/lisp/net/tramp-sudoedit.el b/lisp/net/tramp-sudoedit.el index 3d25e13073d..f7a3b30ffcd 100644 --- a/lisp/net/tramp-sudoedit.el +++ b/lisp/net/tramp-sudoedit.el @@ -119,6 +119,7 @@ See `tramp-actions-before-shell' for more info.") (make-directory . tramp-sudoedit-handle-make-directory) (make-directory-internal . ignore) (make-nearby-temp-file . tramp-handle-make-nearby-temp-file) + (make-process . ignore) (make-symbolic-link . tramp-sudoedit-handle-make-symbolic-link) (process-file . ignore) (rename-file . tramp-sudoedit-handle-rename-file) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index cf7c51fec10..757f90061c5 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -2278,7 +2278,7 @@ ARGS are the arguments OPERATION has been called with." ;; Emacs 26+ only. make-nearby-temp-file temporary-file-directory ;; Emacs 27+ only. - exec-path)) + exec-path make-process)) default-directory) ;; PROC. ((member operation diff --git a/lisp/vc/ediff-util.el b/lisp/vc/ediff-util.el index b1652e7efd4..a70fd0a97ae 100644 --- a/lisp/vc/ediff-util.el +++ b/lisp/vc/ediff-util.el @@ -3221,9 +3221,9 @@ Hit \\[ediff-recenter] to reset the windows afterward." short-f (concat ediff-temp-file-prefix short-p) f (cond (given-file) ((find-file-name-handler f 'insert-file-contents) - ;; to thwart file handlers in write-region, e.g., if file - ;; name ends with .Z or .gz - ;; This is needed so that patches produced by ediff will + ;; to thwart file name handlers in write-region, + ;; e.g., if file name ends with .Z or .gz + ;; This is needed so that patches produced by ediff will ;; have more meaningful names (ediff-make-empty-tmp-file short-f)) (prefix diff --git a/src/process.c b/src/process.c index 5895f77446b..34045b4977a 100644 --- a/src/process.c +++ b/src/process.c @@ -1663,7 +1663,7 @@ is mixed with standard output and sent to BUFFER or FILTER. :file-handler FILE-HANDLER -- If FILE-HANDLER is non-nil, then look for a file name handler for the current buffer's `default-directory' -and invoke that file handler to make the process. If there is no +and invoke that file name handler to make the process. If there is no such handler, proceed as if FILE-HANDLER were nil. usage: (make-process &rest ARGS) */) diff --git a/test/src/process-tests.el b/test/src/process-tests.el index af5bc737574..35890af4822 100644 --- a/test/src/process-tests.el +++ b/test/src/process-tests.el @@ -217,7 +217,7 @@ (ert-deftest make-process/file-handler/found () "Check that the ‘:file-handler’ argument of ‘make-process’ -works as expected if a file handler is found." +works as expected if a file name handler is found." (let ((file-handler-calls 0)) (cl-flet ((file-handler (&rest args) @@ -238,7 +238,7 @@ works as expected if a file handler is found." (ert-deftest make-process/file-handler/not-found () "Check that the ‘:file-handler’ argument of ‘make-process’ -works as expected if no file handler is found." +works as expected if no file name handler is found." (let ((file-name-handler-alist ()) (default-directory invocation-directory) (program (expand-file-name invocation-name invocation-directory))) @@ -248,7 +248,7 @@ works as expected if no file handler is found." (ert-deftest make-process/file-handler/disable () "Check ‘make-process’ works as expected if it shouldn’t use the -file handler." +file name handler." (let ((file-name-handler-alist (list (cons (rx bos "test-handler:") #'process-tests--file-handler))) (default-directory "test-handler:/dir/") @@ -259,7 +259,7 @@ file handler." (defun process-tests--file-handler (operation &rest _args) (cl-ecase operation (unhandled-file-name-directory "/") - (make-process (ert-fail "file handler called unexpectedly")))) + (make-process (ert-fail "file name handler called unexpectedly")))) (put #'process-tests--file-handler 'operations '(unhandled-file-name-directory make-process)) -- 2.39.5