From 739dca7818514f1b7c318fd195f90535a416f57f Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Mon, 17 Dec 2018 12:26:58 +0100 Subject: 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. --- lisp/net/tramp-compat.el | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'lisp/net/tramp-compat.el') diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el index df0e0887b4a..e1bd18b0a90 100644 --- a/lisp/net/tramp-compat.el +++ b/lisp/net/tramp-compat.el @@ -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)))) + (elem + (push elem elems))) + tree)) + (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: -- cgit v1.2.1