[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 739dca7 4/4: Use `flatten-tree' in Tramp
From: |
Michael Albinus |
Subject: |
[Emacs-diffs] master 739dca7 4/4: Use `flatten-tree' in Tramp |
Date: |
Mon, 17 Dec 2018 06:27:23 -0500 (EST) |
branch: master
commit 739dca7818514f1b7c318fd195f90535a416f57f
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>
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 ++++++++++++++-------------
lisp/net/tramp-sudoedit.el | 4 ++--
2 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el
index df0e088..e1bd18b 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:
diff --git a/lisp/net/tramp-sudoedit.el b/lisp/net/tramp-sudoedit.el
index 08fc79d..3d25e13 100644
--- a/lisp/net/tramp-sudoedit.el
+++ b/lisp/net/tramp-sudoedit.el
@@ -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
- (tramp-compat-flatten-list
+ (tramp-compat-flatten-tree
(mapcar
(lambda (x)
(setq x (mapcar (lambda (y) (format-spec y spec)) x))
(unless (member "" x) x))
login))
- (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