aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2023-02-14 18:51:44 +0100
committerMichael Albinus2023-02-14 18:51:44 +0100
commit82133dea0d021eb2e395d9265f0cfe58822f2c57 (patch)
treeaa552684696351a89915fbc59d88796baafc2bf2
parent864bf5dda4a0f84041d30165a995f2160d1e92f9 (diff)
downloademacs-82133dea0d021eb2e395d9265f0cfe58822f2c57.tar.gz
emacs-82133dea0d021eb2e395d9265f0cfe58822f2c57.zip
Tramp cleanup
* lisp/net/tramp.el: * lisp/net/tramp-integration.el: * lisp/net/tramp-sh.el: Use `string-join'. * test/lisp/net/tramp-tests.el: Use `string-join'.
-rw-r--r--lisp/net/tramp-integration.el20
-rw-r--r--lisp/net/tramp-sh.el24
-rw-r--r--lisp/net/tramp.el10
-rw-r--r--test/lisp/net/tramp-tests.el10
4 files changed, 24 insertions, 40 deletions
diff --git a/lisp/net/tramp-integration.el b/lisp/net/tramp-integration.el
index c7877c9824d..3ef4b55acd3 100644
--- a/lisp/net/tramp-integration.el
+++ b/lisp/net/tramp-integration.el
@@ -133,7 +133,7 @@ been set up by `rfn-eshadow-setup-minibuffer'."
133 ;; Use `path-separator' as it does eshell. 133 ;; Use `path-separator' as it does eshell.
134 (setq eshell-path-env 134 (setq eshell-path-env
135 (if (file-remote-p default-directory) 135 (if (file-remote-p default-directory)
136 (mapconcat #'identity (butlast (exec-path)) path-separator) 136 (string-join (butlast (exec-path)) path-separator)
137 (getenv "PATH")))) 137 (getenv "PATH"))))
138 138
139(with-eval-after-load 'esh-util 139(with-eval-after-load 'esh-util
@@ -345,8 +345,7 @@ NAME must be equal to `tramp-current-connection'."
345(defconst tramp-bsd-process-attributes-ps-args 345(defconst tramp-bsd-process-attributes-ps-args
346 `("-acxww" 346 `("-acxww"
347 "-o" 347 "-o"
348 ,(mapconcat 348 ,(string-join
349 #'identity
350 '("pid" 349 '("pid"
351 "euid" 350 "euid"
352 "user" 351 "user"
@@ -355,8 +354,7 @@ NAME must be equal to `tramp-current-connection'."
355 "comm=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") 354 "comm=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
356 ",") 355 ",")
357 "-o" 356 "-o"
358 ,(mapconcat 357 ,(string-join
359 #'identity
360 '("state" 358 '("state"
361 "ppid" 359 "ppid"
362 "pgid" 360 "pgid"
@@ -419,8 +417,7 @@ See `tramp-process-attributes-ps-format'.")
419;; Tested with BusyBox v1.24.1. 417;; Tested with BusyBox v1.24.1.
420(defconst tramp-busybox-process-attributes-ps-args 418(defconst tramp-busybox-process-attributes-ps-args
421 `("-o" 419 `("-o"
422 ,(mapconcat 420 ,(string-join
423 #'identity
424 '("pid" 421 '("pid"
425 "user" 422 "user"
426 "group" 423 "group"
@@ -428,8 +425,7 @@ See `tramp-process-attributes-ps-format'.")
428 ",") 425 ",")
429 "-o" "stat=abcde" 426 "-o" "stat=abcde"
430 "-o" 427 "-o"
431 ,(mapconcat 428 ,(string-join
432 #'identity
433 '("ppid" 429 '("ppid"
434 "pgid" 430 "pgid"
435 "tty" 431 "tty"
@@ -472,8 +468,7 @@ See `tramp-process-attributes-ps-format'.")
472(defconst tramp-darwin-process-attributes-ps-args 468(defconst tramp-darwin-process-attributes-ps-args
473 `("-acxww" 469 `("-acxww"
474 "-o" 470 "-o"
475 ,(mapconcat 471 ,(string-join
476 #'identity
477 '("pid" 472 '("pid"
478 "uid" 473 "uid"
479 "user" 474 "user"
@@ -482,8 +477,7 @@ See `tramp-process-attributes-ps-format'.")
482 ",") 477 ",")
483 "-o" "state=abcde" 478 "-o" "state=abcde"
484 "-o" 479 "-o"
485 ,(mapconcat 480 ,(string-join
486 #'identity
487 '("ppid" 481 '("ppid"
488 "pgid" 482 "pgid"
489 "sess" 483 "sess"
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index d1f723e9807..7a6c9658aa9 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -2392,8 +2392,7 @@ The method used must be an out-of-band method."
2392 v 'file-error 2392 v 'file-error
2393 "Cannot find remote listener: %s" remote-copy-program)) 2393 "Cannot find remote listener: %s" remote-copy-program))
2394 (setq remote-copy-program 2394 (setq remote-copy-program
2395 (mapconcat 2395 (string-join
2396 #'identity
2397 (append 2396 (append
2398 (list remote-copy-program) remote-copy-args 2397 (list remote-copy-program) remote-copy-args
2399 (list (if v1 (concat "<" source) (concat ">" target)) "&")) 2398 (list (if v1 (concat "<" source) (concat ">" target)) "&"))
@@ -3010,8 +3009,7 @@ implementation will be used."
3010 ;; We must also disable buffering, 3009 ;; We must also disable buffering,
3011 ;; otherwise strings larger than 4096 3010 ;; otherwise strings larger than 4096
3012 ;; bytes, sent by the process, could 3011 ;; bytes, sent by the process, could
3013 ;; block, see termios(3) and 3012 ;; block, see termios(3) and Bug#61341.
3014 ;; <https://github.com/emacs-lsp/lsp-mode/issues/2375#issuecomment-1407272718>.
3015 ;; FIXME: Shall we rather use "stty raw"? 3013 ;; FIXME: Shall we rather use "stty raw"?
3016 (if (tramp-check-remote-uname v "Darwin") 3014 (if (tramp-check-remote-uname v "Darwin")
3017 (tramp-send-command 3015 (tramp-send-command
@@ -3118,8 +3116,7 @@ implementation will be used."
3118 (format 3116 (format
3119 "%s %s %s" 3117 "%s %s %s"
3120 (tramp-get-method-parameter vec 'tramp-remote-shell) 3118 (tramp-get-method-parameter vec 'tramp-remote-shell)
3121 (mapconcat 3119 (string-join
3122 #'identity
3123 (tramp-get-method-parameter vec 'tramp-remote-shell-args) 3120 (tramp-get-method-parameter vec 'tramp-remote-shell-args)
3124 " ") 3121 " ")
3125 (tramp-shell-quote-argument (format "kill -%d $$" i)))) 3122 (tramp-shell-quote-argument (format "kill -%d $$" i))))
@@ -4972,7 +4969,7 @@ Goes through the list `tramp-inline-compress-commands'."
4972 (tramp-call-process 4969 (tramp-call-process
4973 vec1 tramp-encoding-shell nil t nil 4970 vec1 tramp-encoding-shell nil t nil
4974 tramp-encoding-command-switch 4971 tramp-encoding-command-switch
4975 (mapconcat #'identity command " ")) 4972 (string-join command " "))
4976 (goto-char (point-min)) 4973 (goto-char (point-min))
4977 (not (search-forward "remotecommand" nil 'noerror))))) 4974 (not (search-forward "remotecommand" nil 'noerror)))))
4978 4975
@@ -4991,11 +4988,11 @@ Goes through the list `tramp-inline-compress-commands'."
4991 found string) 4988 found string)
4992 (with-temp-buffer 4989 (with-temp-buffer
4993 ;; Check hostkey of VEC2, seen from VEC1. 4990 ;; Check hostkey of VEC2, seen from VEC1.
4994 (tramp-send-command vec1 (mapconcat #'identity command " ")) 4991 (tramp-send-command vec1 (string-join command " "))
4995 ;; Check hostkey of VEC2, seen locally. 4992 ;; Check hostkey of VEC2, seen locally.
4996 (tramp-call-process 4993 (tramp-call-process
4997 vec1 tramp-encoding-shell nil t nil tramp-encoding-command-switch 4994 vec1 tramp-encoding-shell nil t nil tramp-encoding-command-switch
4998 (mapconcat #'identity command " ")) 4995 (string-join command " "))
4999 (goto-char (point-min)) 4996 (goto-char (point-min))
5000 (while (and (not found) (not (eobp))) 4997 (while (and (not found) (not (eobp)))
5001 (setq string 4998 (setq string
@@ -5219,8 +5216,7 @@ connection if a previous connection has died for some reason."
5219 ;; Replace `login-args' place holders. 5216 ;; Replace `login-args' place holders.
5220 (setq 5217 (setq
5221 command 5218 command
5222 (mapconcat 5219 (string-join
5223 #'identity
5224 (append 5220 (append
5225 ;; We do not want to see the trailing local 5221 ;; We do not want to see the trailing local
5226 ;; prompt in `start-file-process'. 5222 ;; prompt in `start-file-process'.
@@ -5521,12 +5517,10 @@ Nonexistent directories are removed from spec."
5521 (format 5517 (format
5522 "%s %s %s 'echo %s \\\"$PATH\\\"'" 5518 "%s %s %s 'echo %s \\\"$PATH\\\"'"
5523 (tramp-get-method-parameter vec 'tramp-remote-shell) 5519 (tramp-get-method-parameter vec 'tramp-remote-shell)
5524 (mapconcat 5520 (string-join
5525 #'identity
5526 (tramp-get-method-parameter vec 'tramp-remote-shell-login) 5521 (tramp-get-method-parameter vec 'tramp-remote-shell-login)
5527 " ") 5522 " ")
5528 (mapconcat 5523 (string-join
5529 #'identity
5530 (tramp-get-method-parameter vec 'tramp-remote-shell-args) 5524 (tramp-get-method-parameter vec 'tramp-remote-shell-args)
5531 " ") 5525 " ")
5532 (tramp-shell-quote-argument tramp-end-of-heredoc)) 5526 (tramp-shell-quote-argument tramp-end-of-heredoc))
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 9fa9866aec8..95b42fb1c43 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -4527,8 +4527,7 @@ Return it as number of seconds. Used in `tramp-process-attributes-ps-format'."
4527(defconst tramp-process-attributes-ps-args 4527(defconst tramp-process-attributes-ps-args
4528 `("-eww" 4528 `("-eww"
4529 "-o" 4529 "-o"
4530 ,(mapconcat 4530 ,(string-join
4531 #'identity
4532 '("pid" 4531 '("pid"
4533 "euid" 4532 "euid"
4534 "euser" 4533 "euser"
@@ -5002,7 +5001,7 @@ substitution. SPEC-LIST is a list of char/value pairs used for
5002 (if (consp (tramp-get-method-parameter v 'tramp-direct-async)) 5001 (if (consp (tramp-get-method-parameter v 'tramp-direct-async))
5003 (append 5002 (append
5004 (tramp-get-method-parameter v 'tramp-direct-async) 5003 (tramp-get-method-parameter v 'tramp-direct-async)
5005 `(,(mapconcat #'identity command " "))) 5004 `(,(string-join command " ")))
5006 command))) 5005 command)))
5007 5006
5008 ;; Check for `tramp-sh-file-name-handler', because something 5007 ;; Check for `tramp-sh-file-name-handler', because something
@@ -5898,8 +5897,7 @@ the remote host use line-endings as defined in the variable
5898 (let ((inhibit-read-only t)) (delete-region (point-min) (point-max))) 5897 (let ((inhibit-read-only t)) (delete-region (point-min) (point-max)))
5899 ;; Replace "\n" by `tramp-rsh-end-of-line'. 5898 ;; Replace "\n" by `tramp-rsh-end-of-line'.
5900 (setq string 5899 (setq string
5901 (mapconcat 5900 (string-join (split-string string "\n") tramp-rsh-end-of-line))
5902 #'identity (split-string string "\n") tramp-rsh-end-of-line))
5903 (unless (or (string-empty-p string) 5901 (unless (or (string-empty-p string)
5904 (string-equal (substring string -1) tramp-rsh-end-of-line)) 5902 (string-equal (substring string -1) tramp-rsh-end-of-line))
5905 (setq string (concat string tramp-rsh-end-of-line))) 5903 (setq string (concat string tramp-rsh-end-of-line)))
@@ -6597,7 +6595,7 @@ verbosity of 6."
6597 (apply #'process-lines program args) 6595 (apply #'process-lines program args)
6598 (error 6596 (error
6599 (tramp-error vec (car err) (cdr err))))) 6597 (tramp-error vec (car err) (cdr err)))))
6600 (tramp-message vec 6 "\n%s" (mapconcat #'identity result "\n")) 6598 (tramp-message vec 6 "\n%s" (string-join result "\n"))
6601 result)) 6599 result))
6602 6600
6603(defun tramp-process-running-p (process-name) 6601(defun tramp-process-running-p (process-name)
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 51fc07117c5..d29e48c0774 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -5542,7 +5542,7 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'."
5542 ;; (tramp--test-message "%s" attributes) 5542 ;; (tramp--test-message "%s" attributes)
5543 (should (equal (cdr (assq 'comm attributes)) (car command))) 5543 (should (equal (cdr (assq 'comm attributes)) (car command)))
5544 (should (equal (cdr (assq 'args attributes)) 5544 (should (equal (cdr (assq 'args attributes))
5545 (mapconcat #'identity command " "))))) 5545 (string-join command " ")))))
5546 5546
5547 ;; Cleanup. 5547 ;; Cleanup.
5548 (ignore-errors (delete-process proc))))) 5548 (ignore-errors (delete-process proc)))))
@@ -6103,8 +6103,7 @@ INPUT, if non-nil, is a string sent to the process."
6103 ;; We make a super long `tramp-remote-path'. 6103 ;; We make a super long `tramp-remote-path'.
6104 (make-directory tmp-name) 6104 (make-directory tmp-name)
6105 (should (file-directory-p tmp-name)) 6105 (should (file-directory-p tmp-name))
6106 (while (tramp-compat-length< 6106 (while (tramp-compat-length< (string-join orig-exec-path ":") 5000)
6107 (mapconcat #'identity orig-exec-path ":") 5000)
6108 (let ((dir (make-temp-file (file-name-as-directory tmp-name) 'dir))) 6107 (let ((dir (make-temp-file (file-name-as-directory tmp-name) 'dir)))
6109 (should (file-directory-p dir)) 6108 (should (file-directory-p dir))
6110 (setq tramp-remote-path 6109 (setq tramp-remote-path
@@ -6126,8 +6125,7 @@ INPUT, if non-nil, is a string sent to the process."
6126 tramp-test-vec "pipe-buf" 4096)) 6125 tramp-test-vec "pipe-buf" 4096))
6127 ;; The last element of `exec-path' is `exec-directory'. 6126 ;; The last element of `exec-path' is `exec-directory'.
6128 (should 6127 (should
6129 (string-equal 6128 (string-equal path (string-join (butlast orig-exec-path) ":"))))
6130 path (mapconcat #'identity (butlast orig-exec-path) ":"))))
6131 ;; The shell "sh" shall always exist. 6129 ;; The shell "sh" shall always exist.
6132 (should (executable-find "sh" 'remote))) 6130 (should (executable-find "sh" 'remote)))
6133 6131
@@ -7182,7 +7180,7 @@ This requires restrictions of file name syntax."
7182 ;; Simplify test in order to speed up. 7180 ;; Simplify test in order to speed up.
7183 (apply #'tramp--test-check-files 7181 (apply #'tramp--test-check-files
7184 (if (tramp--test-expensive-test-p) 7182 (if (tramp--test-expensive-test-p)
7185 files (list (mapconcat #'identity files "")))))) 7183 files (list (string-join files ""))))))
7186 7184
7187(tramp--test-deftest-with-stat tramp-test41-special-characters) 7185(tramp--test-deftest-with-stat tramp-test41-special-characters)
7188 7186