From: Michael Albinus Date: Tue, 22 Jul 2025 15:47:38 +0000 (+0200) Subject: Add function exec-suffixes X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ceb6f2299fc0ce6241985610d527e7cad1d9c8e7;p=emacs.git Add function exec-suffixes * doc/lispref/processes.texi (Subprocess Creation): Add function exec-suffixes. * etc/NEWS: New function 'exec-suffixes'. Presentational fixes and improvements. * lisp/files-x.el (exec-suffixes): New defun. (Bug#78886) * lisp/files.el (executable-find): Use function `exec-suffixes'. * lisp/net/tramp-integration.el (tramp-connection-local-default-system-variables): Add also `exec-suffixes'. * lisp/net/tramp-smb.el (tramp-smb-maybe-open-connection): Use default values of `path-separator', `null-device' and `exec-suffixes'. (tramp-smb-connection-local-default-system-variables): New defconst. Add it to connection-local profiles. (cherry picked from commit 5a7a12d7920a94edea175871235c5013f0c73e3c) --- diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi index 7fab68ad89c..1e10e67cd55 100644 --- a/doc/lispref/processes.texi +++ b/doc/lispref/processes.texi @@ -113,6 +113,11 @@ want the name to be tried exactly as specified. The default value is system-dependent. @end defopt +@defun exec-suffixes +This function returns the connection-local value of variable +@code{exec-suffixes}. +@end defun + @strong{Please note:} The argument @var{program} contains only the name of the program file; it may not contain any command-line arguments. You must use a separate argument, @var{args}, to provide @@ -183,6 +188,8 @@ This function is an extension of the variable @code{exec-path}. If returns a list of directories used for searching programs on the respective remote host. In case of a local @code{default-directory}, the function returns just the value of the variable @code{exec-path}. +If you use @code{exec-suffixes} together with this function, you must +also use the function @code{exec-suffixes} instead of the variable. @end defun @cindex programs distributed with Emacs, starting diff --git a/lisp/files-x.el b/lisp/files-x.el index f7c00884b70..3cb23a2f570 100644 --- a/lisp/files-x.el +++ b/lisp/files-x.el @@ -1003,6 +1003,11 @@ value is the default binding of the variable." "The connection-local value of `null-device'." (connection-local-value null-device)) +;;;###autoload +(defun exec-suffixes () + "The connection-local value of `exec-suffixes'." + (connection-local-value exec-suffixes)) + (provide 'files-x) diff --git a/lisp/files.el b/lisp/files.el index 83842aed116..a78f6694b61 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -1236,7 +1236,7 @@ remote, otherwise search locally." (mapcar (lambda (x) (concat (file-remote-p default-directory) x)) (exec-path)) - exec-suffixes 'file-executable-p))) + (exec-suffixes) 'file-executable-p))) (when (stringp res) (file-local-name res))) ;; Use 1 rather than file-executable-p to better match the ;; behavior of call-process. diff --git a/lisp/net/tramp-integration.el b/lisp/net/tramp-integration.el index 8569b1f30f4..fae550f5fbe 100644 --- a/lisp/net/tramp-integration.el +++ b/lisp/net/tramp-integration.el @@ -346,7 +346,8 @@ It's value must be a Tramp user option, indexed in the Tramp manual via (defconst tramp-connection-local-default-system-variables '((path-separator . ":") - (null-device . "/dev/null")) + (null-device . "/dev/null") + (exec-suffixes . (""))) "Default connection-local system variables for remote connections.") (connection-local-set-profile-variables diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el index 85b25d5ba10..b8c6dfd4482 100644 --- a/lisp/net/tramp-smb.el +++ b/lisp/net/tramp-smb.el @@ -2046,7 +2046,12 @@ If ARGUMENT is non-nil, use it as argument for tramp-compat-temporary-file-directory) (process-environment (cons (concat "TERM=" tramp-terminal-type) - process-environment))) + process-environment)) + ;; There might be some unfortune values of + ;; `tramp-smb-connection-local-default-system-variables'. + (path-separator (default-value 'path-separator)) + (null-device (default-value 'null-device)) + (exec-suffixes (default-value 'exec-suffixes))) (apply #'start-process (tramp-get-connection-name vec) (tramp-get-connection-buffer vec) @@ -2172,6 +2177,27 @@ Removes smb prompt. Returns nil if an error message has appeared." "Call `tramp-smb-shell-quote-argument' on localname of VEC." (tramp-smb-shell-quote-argument (tramp-smb-get-localname vec))) +;;; Default connection-local variables for Tramp. + +(defconst tramp-smb-connection-local-default-system-variables + '((path-separator . ";") + (null-device . "NUL") + ;; This the default value of %PATHEXT% in MS Windows 11, plus ".py" + ;; for Python. Once we have remote processes, we might set this + ;; host-specific using that remote environment variable. + (exec-suffixes + . (".com" ".exe" ".bat" ".cmd" ".vbs" ".vbe" + ".js" ".jse" ".wsf" ".wsh" ".msc" ".py"))) + "Default connection-local system variables for remote smb connections.") + +(connection-local-set-profile-variables + 'tramp-smb-connection-local-default-system-profile + tramp-smb-connection-local-default-system-variables) + +(connection-local-set-profiles + `(:application tramp :protocol ,tramp-smb-method) + 'tramp-smb-connection-local-default-system-profile) + (add-hook 'tramp-unload-hook (lambda () (unload-feature 'tramp-smb 'force)))