1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-04-27 08:43:40 -07:00

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'.
This commit is contained in:
Michael Albinus 2023-02-14 18:51:44 +01:00
parent 864bf5dda4
commit 82133dea0d
4 changed files with 24 additions and 40 deletions

View file

@ -133,7 +133,7 @@ been set up by `rfn-eshadow-setup-minibuffer'."
;; Use `path-separator' as it does eshell.
(setq eshell-path-env
(if (file-remote-p default-directory)
(mapconcat #'identity (butlast (exec-path)) path-separator)
(string-join (butlast (exec-path)) path-separator)
(getenv "PATH"))))
(with-eval-after-load 'esh-util
@ -345,8 +345,7 @@ NAME must be equal to `tramp-current-connection'."
(defconst tramp-bsd-process-attributes-ps-args
`("-acxww"
"-o"
,(mapconcat
#'identity
,(string-join
'("pid"
"euid"
"user"
@ -355,8 +354,7 @@ NAME must be equal to `tramp-current-connection'."
"comm=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
",")
"-o"
,(mapconcat
#'identity
,(string-join
'("state"
"ppid"
"pgid"
@ -419,8 +417,7 @@ See `tramp-process-attributes-ps-format'.")
;; Tested with BusyBox v1.24.1.
(defconst tramp-busybox-process-attributes-ps-args
`("-o"
,(mapconcat
#'identity
,(string-join
'("pid"
"user"
"group"
@ -428,8 +425,7 @@ See `tramp-process-attributes-ps-format'.")
",")
"-o" "stat=abcde"
"-o"
,(mapconcat
#'identity
,(string-join
'("ppid"
"pgid"
"tty"
@ -472,8 +468,7 @@ See `tramp-process-attributes-ps-format'.")
(defconst tramp-darwin-process-attributes-ps-args
`("-acxww"
"-o"
,(mapconcat
#'identity
,(string-join
'("pid"
"uid"
"user"
@ -482,8 +477,7 @@ See `tramp-process-attributes-ps-format'.")
",")
"-o" "state=abcde"
"-o"
,(mapconcat
#'identity
,(string-join
'("ppid"
"pgid"
"sess"

View file

@ -2392,8 +2392,7 @@ The method used must be an out-of-band method."
v 'file-error
"Cannot find remote listener: %s" remote-copy-program))
(setq remote-copy-program
(mapconcat
#'identity
(string-join
(append
(list remote-copy-program) remote-copy-args
(list (if v1 (concat "<" source) (concat ">" target)) "&"))
@ -3010,8 +3009,7 @@ implementation will be used."
;; We must also disable buffering,
;; otherwise strings larger than 4096
;; bytes, sent by the process, could
;; block, see termios(3) and
;; <https://github.com/emacs-lsp/lsp-mode/issues/2375#issuecomment-1407272718>.
;; block, see termios(3) and Bug#61341.
;; FIXME: Shall we rather use "stty raw"?
(if (tramp-check-remote-uname v "Darwin")
(tramp-send-command
@ -3118,8 +3116,7 @@ implementation will be used."
(format
"%s %s %s"
(tramp-get-method-parameter vec 'tramp-remote-shell)
(mapconcat
#'identity
(string-join
(tramp-get-method-parameter vec 'tramp-remote-shell-args)
" ")
(tramp-shell-quote-argument (format "kill -%d $$" i))))
@ -4972,7 +4969,7 @@ Goes through the list `tramp-inline-compress-commands'."
(tramp-call-process
vec1 tramp-encoding-shell nil t nil
tramp-encoding-command-switch
(mapconcat #'identity command " "))
(string-join command " "))
(goto-char (point-min))
(not (search-forward "remotecommand" nil 'noerror)))))
@ -4991,11 +4988,11 @@ Goes through the list `tramp-inline-compress-commands'."
found string)
(with-temp-buffer
;; Check hostkey of VEC2, seen from VEC1.
(tramp-send-command vec1 (mapconcat #'identity command " "))
(tramp-send-command vec1 (string-join command " "))
;; Check hostkey of VEC2, seen locally.
(tramp-call-process
vec1 tramp-encoding-shell nil t nil tramp-encoding-command-switch
(mapconcat #'identity command " "))
(string-join command " "))
(goto-char (point-min))
(while (and (not found) (not (eobp)))
(setq string
@ -5219,8 +5216,7 @@ connection if a previous connection has died for some reason."
;; Replace `login-args' place holders.
(setq
command
(mapconcat
#'identity
(string-join
(append
;; We do not want to see the trailing local
;; prompt in `start-file-process'.
@ -5521,12 +5517,10 @@ Nonexistent directories are removed from spec."
(format
"%s %s %s 'echo %s \\\"$PATH\\\"'"
(tramp-get-method-parameter vec 'tramp-remote-shell)
(mapconcat
#'identity
(string-join
(tramp-get-method-parameter vec 'tramp-remote-shell-login)
" ")
(mapconcat
#'identity
(string-join
(tramp-get-method-parameter vec 'tramp-remote-shell-args)
" ")
(tramp-shell-quote-argument tramp-end-of-heredoc))

View file

@ -4527,8 +4527,7 @@ Return it as number of seconds. Used in `tramp-process-attributes-ps-format'."
(defconst tramp-process-attributes-ps-args
`("-eww"
"-o"
,(mapconcat
#'identity
,(string-join
'("pid"
"euid"
"euser"
@ -5002,7 +5001,7 @@ substitution. SPEC-LIST is a list of char/value pairs used for
(if (consp (tramp-get-method-parameter v 'tramp-direct-async))
(append
(tramp-get-method-parameter v 'tramp-direct-async)
`(,(mapconcat #'identity command " ")))
`(,(string-join command " ")))
command)))
;; Check for `tramp-sh-file-name-handler', because something
@ -5898,8 +5897,7 @@ the remote host use line-endings as defined in the variable
(let ((inhibit-read-only t)) (delete-region (point-min) (point-max)))
;; Replace "\n" by `tramp-rsh-end-of-line'.
(setq string
(mapconcat
#'identity (split-string string "\n") tramp-rsh-end-of-line))
(string-join (split-string string "\n") tramp-rsh-end-of-line))
(unless (or (string-empty-p string)
(string-equal (substring string -1) tramp-rsh-end-of-line))
(setq string (concat string tramp-rsh-end-of-line)))
@ -6597,7 +6595,7 @@ verbosity of 6."
(apply #'process-lines program args)
(error
(tramp-error vec (car err) (cdr err)))))
(tramp-message vec 6 "\n%s" (mapconcat #'identity result "\n"))
(tramp-message vec 6 "\n%s" (string-join result "\n"))
result))
(defun tramp-process-running-p (process-name)

View file

@ -5542,7 +5542,7 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'."
;; (tramp--test-message "%s" attributes)
(should (equal (cdr (assq 'comm attributes)) (car command)))
(should (equal (cdr (assq 'args attributes))
(mapconcat #'identity command " ")))))
(string-join command " ")))))
;; Cleanup.
(ignore-errors (delete-process proc)))))
@ -6103,8 +6103,7 @@ INPUT, if non-nil, is a string sent to the process."
;; We make a super long `tramp-remote-path'.
(make-directory tmp-name)
(should (file-directory-p tmp-name))
(while (tramp-compat-length<
(mapconcat #'identity orig-exec-path ":") 5000)
(while (tramp-compat-length< (string-join orig-exec-path ":") 5000)
(let ((dir (make-temp-file (file-name-as-directory tmp-name) 'dir)))
(should (file-directory-p dir))
(setq tramp-remote-path
@ -6126,8 +6125,7 @@ INPUT, if non-nil, is a string sent to the process."
tramp-test-vec "pipe-buf" 4096))
;; The last element of `exec-path' is `exec-directory'.
(should
(string-equal
path (mapconcat #'identity (butlast orig-exec-path) ":"))))
(string-equal path (string-join (butlast orig-exec-path) ":"))))
;; The shell "sh" shall always exist.
(should (executable-find "sh" 'remote)))
@ -7182,7 +7180,7 @@ This requires restrictions of file name syntax."
;; Simplify test in order to speed up.
(apply #'tramp--test-check-files
(if (tramp--test-expensive-test-p)
files (list (mapconcat #'identity files ""))))))
files (list (string-join files ""))))))
(tramp--test-deftest-with-stat tramp-test41-special-characters)