diff options
author | Michael Albinus <michael.albinus@gmx.de> | 2018-12-17 12:26:58 +0100 |
---|---|---|
committer | Michael Albinus <michael.albinus@gmx.de> | 2018-12-17 12:26:58 +0100 |
commit | 739dca7818514f1b7c318fd195f90535a416f57f (patch) | |
tree | a8df494bd47b4599088f54b7122346d3e5e7b513 /lisp/net/tramp-compat.el | |
parent | 36b05dc84247db1391a423df94e4b9a478e29dc5 (diff) | |
download | emacs-739dca7818514f1b7c318fd195f90535a416f57f.tar.gz |
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.
Diffstat (limited to 'lisp/net/tramp-compat.el')
-rw-r--r-- | lisp/net/tramp-compat.el | 27 |
1 files changed, 14 insertions, 13 deletions
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: |