master dcdd76f89e7: Use default exec-suffixes when needed (bug#81280)

Michael Albinus via Mailing list for Emacs changes <[email protected]>
Newsgroups gmane.emacs.diffs
Message-ID <[email protected]>
branch: master
commit dcdd76f89e77421bf8be4ae0c2324b3029a23f1a
Author: Michael Albinus <[email protected]>
Commit: Michael Albinus <[email protected]>

    Use default exec-suffixes when needed (bug#81280)
    
    * lisp/files.el (executable-find): Use (default-value 'exec-suffixes).
    
    * src/callproc.c (Qexec_suffixes): Declare.
    (call_process):
    * src/process.c (Fmake_process): Use Fdefault_value (Qexec_suffixes).
    
    * test/lisp/files-x-tests.el (files-x-test--variables6):
    New defconst.
    (files-x-test-connection-local-special-variables): New test.
---
 lisp/files.el              |  2 +-
 src/callproc.c             |  3 ++-
 src/process.c              |  2 +-
 test/lisp/files-x-tests.el | 37 +++++++++++++++++++++++++++++++++++++
 4 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/lisp/files.el b/lisp/files.el
index 5aaa0d44a04..97144fef78f 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -1331,7 +1331,7 @@ remote, otherwise search locally."
     ;; Use 1 rather than file-executable-p to better match the
     ;; behavior of call-process.
     (let ((default-directory (file-name-quote default-directory 'top)))
-      (locate-file command exec-path exec-suffixes 1))))
+      (locate-file command exec-path (default-value 'exec-suffixes) 1))))
 
 (declare-function read-library-name "find-func" nil)
 
diff --git a/src/callproc.c b/src/callproc.c
index 52977b29f30..7eb245f915c 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -520,7 +520,7 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd,
   {
     int ok;
 
-    ok = openp (Vexec_path, args[0], Vexec_suffixes, &path,
+    ok = openp (Vexec_path, args[0], Fdefault_value (Qexec_suffixes), &path,
 		make_fixnum (X_OK), false, false, NULL);
     if (ok < 0)
       report_file_error ("Searching for program", args[0]);
@@ -2258,4 +2258,5 @@ multiple times on subsequent partitions of the list of arguments.
   DEFSYM (Qafter_insert_file_set_buffer_file_coding_system,
 	  "after-insert-file-set-buffer-file-coding-system");
   DEFSYM (Qcoding_system_for_write, "coding-system-for-write");
+  DEFSYM (Qexec_suffixes, "exec-suffixes");
 }
diff --git a/src/process.c b/src/process.c
index 1ad9cb5fc04..67b39f6586c 100644
--- a/src/process.c
+++ b/src/process.c
@@ -2073,7 +2073,7 @@ usage: (make-process &rest ARGS)  */)
 	       && IS_DEVICE_SEP (SREF (program, 1))))
 	{
 	  tem = Qnil;
-	  openp (Vexec_path, program, Vexec_suffixes, &tem,
+	  openp (Vexec_path, program, Fdefault_value (Qexec_suffixes), &tem,
 		 make_fixnum (X_OK), false, false, NULL);
 	  if (NILP (tem))
 	    report_file_error ("Searching for program", program);
diff --git a/test/lisp/files-x-tests.el b/test/lisp/files-x-tests.el
index 88e02ba143c..31633df073e 100644
--- a/test/lisp/files-x-tests.el
+++ b/test/lisp/files-x-tests.el
@@ -39,6 +39,9 @@
 (defconst files-x-test--variables5
   '((remote-lazy-var . nil)
     (remote-null-device . "/dev/null")))
+(defconst files-x-test--variables6
+  '((exec-suffixes . ("foo"))
+    (path-separator . "foo")))
 (defvar remote-shell-file-name)
 (defvar remote-null-device)
 (defvar remote-lazy-var nil)
@@ -601,5 +604,39 @@ If it's not initialized yet, initialize it."
      `(connection-local-profile-alist ',clpa now)
      `(connection-local-criteria-alist ',clca now))))
 
+(ert-deftest files-x-test-connection-local-special-variables ()
+  "Test special local variables.
+The connection-local variables `exec-suffixes' and `path-separator' are
+used for remote processes.  When calling `call-process', `make-process'
+or `executable-find', their default value must be used nonetheless."
+
+  (let ((clpa connection-local-profile-alist)
+	(clca connection-local-criteria-alist)
+        (program (file-name-sans-extension
+                  (file-name-concat invocation-directory invocation-name)))
+        proc)
+    (connection-local-set-profile-variables
+     'special-variables files-x-test--variables6)
+    (connection-local-set-profiles
+     nil 'special-variables)
+
+    (unwind-protect
+        (with-temp-buffer
+          (let ((enable-connection-local-variables t))
+            (hack-connection-local-variables-apply nil)
+            (should (zerop (call-process program nil nil nil "--help")))
+            (should
+             (processp
+              (setq proc
+                    (make-process
+                     :name invocation-name :command `(,program "--help")))))
+            (should (executable-find program))))
+
+      ;; Cleanup.
+      (when (processp proc) (kill-process proc))
+      (custom-set-variables
+       `(connection-local-profile-alist ',clpa now)
+       `(connection-local-criteria-alist ',clca now)))))
+
 (provide 'files-x-tests)
 ;;; files-x-tests.el ends here
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.