Commit 739dca78 authored by Michael Albinus's avatar Michael Albinus
Browse files

Use `flatten-tree' in Tramp

* lisp/net/tramp-compat.el (tramp-compat-flatten-tree): New defun.
(tramp-compat-flatten-list): Remove.

* lisp/net/tramp-sudoedit.el (tramp-sudoedit-send-command): Use it.
parent 36b05dc8
Pipeline #300 failed with stage
in 3 seconds
......@@ -264,24 +264,25 @@ If NAME is a remote file name, the local part of NAME is unquoted."
A nil value for either argument stands for the current time."
(equal (or t1 (current-time)) (or t2 (current-time)))))
(if (fboundp 'flatten-tree)
(defalias 'tramp-compat-flatten-tree 'flatten-tree)
(defun tramp-compat-flatten-tree (tree)
"Take TREE and \"flatten\" it."
(let (elems)
(setq tree (list tree))
(while (let ((elem (pop tree)))
(cond ((consp elem)
(setq tree (cons (car elem) (cons (cdr elem) tree))))
(push elem elems)))
(nreverse elems))))
(add-hook 'tramp-unload-hook
(lambda ()
(unload-feature 'tramp-loaddefs 'force)
(unload-feature 'tramp-compat 'force)))
;; There does not exist a common `flatten-list' yet, this is discussed
;; in Bug#33309. For the time being we implement our own version,
;; derived from `eshell-flatten-list'.
(defun tramp-compat-flatten-list (args)
"Flatten any lists within ARGS, so that there are no sublists."
(let ((new-list (list t)))
(dolist (a args)
(if (and (listp a)
(listp (cdr a)))
(nconc new-list (tramp-compat-flatten-list a))
(nconc new-list (list a))))
(cdr new-list)))
(provide 'tramp-compat)
;;; TODO:
......@@ -798,13 +798,13 @@ in case of error, t otherwise."
(user (or (tramp-file-name-user vec) ""))
(spec (format-spec-make ?h host ?u user))
(args (append
(lambda (x)
(setq x (mapcar (lambda (y) (format-spec y spec)) x))
(unless (member "" x) x))
(tramp-compat-flatten-list (delq nil args))))
(tramp-compat-flatten-tree (delq nil args))))
(delete-exited-processes t)
(process-connection-type tramp-process-connection-type)
(p (apply #'start-process
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment