[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master e3447f1 5/5: Merge commit '07009d7695eb7b82225712336fe3884
From: |
Alexey Veretennikov |
Subject: |
[elpa] master e3447f1 5/5: Merge commit '07009d7695eb7b82225712336fe388495dd48169' |
Date: |
Sat, 24 Sep 2016 17:52:13 +0000 (UTC) |
branch: master
commit e3447f1607bf879a775591f6473746f94cf23cbe
Merge: 47be1cb 07009d7
Author: Alexey Veretennikov <address@hidden>
Commit: Alexey Veretennikov <address@hidden>
Merge commit '07009d7695eb7b82225712336fe388495dd48169'
- Fixed broken 'x' button in ztree-dir
- Fixed broken compare over tramp
---
packages/ztree/ztree-diff-model.el | 25 ++++---------------------
packages/ztree/ztree-diff.el | 2 ++
packages/ztree/ztree-dir.el | 9 ++++++++-
packages/ztree/ztree-util.el | 21 +++++++++++++++++++++
4 files changed, 35 insertions(+), 22 deletions(-)
diff --git a/packages/ztree/ztree-diff-model.el
b/packages/ztree/ztree-diff-model.el
index a9c99ae..20df0c0 100644
--- a/packages/ztree/ztree-diff-model.el
+++ b/packages/ztree/ztree-diff-model.el
@@ -138,30 +138,13 @@ RIGHT if only on the right side."
(string-equal (ztree-diff-node-right-path node1)
(ztree-diff-node-right-path node1))))
-(defun ztree-diff-untrampify-filename (file)
- "Return FILE as the local file name."
- ;; FIXME: We shouldn't use internal Tramp functions.
- (require 'tramp)
- (declare-function tramp-tramp-file-p "tramp" (name))
- (declare-function tramp-file-name-localname "tramp" (vec))
- (declare-function tramp-dissect-file-name "tramp" (name &optional nodefault))
- (if (not (tramp-tramp-file-p file))
- file
- (tramp-file-name-localname (tramp-dissect-file-name file))))
-
-(defun ztree-diff-modef-quotify-string (x)
- "Surround string X with quotes."
- (concat "\"" x "\""))
-
(defun ztree-diff-model-files-equal (file1 file2)
"Compare files FILE1 and FILE2 using external diff.
Returns t if equal."
- ;; FIXME: This "untrampification" only works if both file1 and file2 are on
- ;; the same host.
- ;; FIXME: We assume that default-directory is also on the same host as
- ;; file(1|2).
- (let* ((file1-untrampified (ztree-diff-untrampify-filename
(ztree-diff-modef-quotify-string file1)))
- (file2-untrampified (ztree-diff-untrampify-filename
(ztree-diff-modef-quotify-string file2)))
+ (unless (ztree-same-host-p file1 file2)
+ (error "Compared files are not on the same host"))
+ (let* ((file1-untrampified (ztree-quotify-string (ztree-untrampify-filename
file1)))
+ (file2-untrampified (ztree-quotify-string (ztree-untrampify-filename
file2)))
(diff-command (concat diff-command " -q" " " file1-untrampified " "
file2-untrampified))
(diff-output (shell-command-to-string diff-command)))
(if (<= (length diff-output) 2) 'same 'diff)))
diff --git a/packages/ztree/ztree-diff.el b/packages/ztree/ztree-diff.el
index cfd0c96..c454709 100644
--- a/packages/ztree/ztree-diff.el
+++ b/packages/ztree/ztree-diff.el
@@ -520,6 +520,8 @@ Argument DIR2 right directory."
(error "Path %s is not a directory" dir2))
(unless (file-exists-p dir2)
(error "Path %s does not exist" dir2))
+ (unless (ztree-same-host-p dir1 dir2)
+ (error "Compared directories are not on the same host"))
(let* ((model
(ztree-diff-node-create nil dir1 dir2 nil))
(buf-name (concat "*"
diff --git a/packages/ztree/ztree-dir.el b/packages/ztree/ztree-dir.el
index 53617f9..7d866ff 100644
--- a/packages/ztree/ztree-dir.el
+++ b/packages/ztree/ztree-dir.el
@@ -145,6 +145,13 @@ Otherwise, the ztree window is used to find the file."
(ztree-refresh-buffer))
+(defun ztree-dir-directory-files (path)
+ "Returns the list of files/directories for the given PATH"
+ ;; remove . and .. from the list of files to avoid infinite
+ ;; recursion
+ (remove-if (lambda (x) (string-match-p "/\\.\\.?$" x))
+ (directory-files path 'full)))
+
;;;###autoload
@@ -160,7 +167,7 @@ Otherwise, the ztree window is used to find the file."
#'ztree-file-short-name
#'file-directory-p
#'string-equal
- (lambda (x) (directory-files x 'full))
+ #'ztree-dir-directory-files
nil ; face
#'ztree-find-file) ; action
(ztreedir-mode))))
diff --git a/packages/ztree/ztree-util.el b/packages/ztree/ztree-util.el
index 9f458d6..07935b7 100644
--- a/packages/ztree/ztree-util.el
+++ b/packages/ztree/ztree-util.el
@@ -65,6 +65,27 @@ Used since `car-safe' returns nil for atoms"
(insert text)
(put-text-property start (point) 'face face)))
+(defun ztree-untrampify-filename (file)
+ "Return FILE as the local file name."
+ ;; FIXME: We shouldn't use internal Tramp functions.
+ (require 'tramp)
+ (declare-function tramp-tramp-file-p "tramp" (name))
+ (declare-function tramp-file-name-localname "tramp" (vec))
+ (declare-function tramp-dissect-file-name "tramp" (name &optional nodefault))
+ (if (not (tramp-tramp-file-p file))
+ file
+ (tramp-file-name-localname (tramp-dissect-file-name file))))
+
+(defun ztree-quotify-string (str)
+ "Surround STR with quotes."
+ (concat "\"" str "\""))
+
+(defun ztree-same-host-p (file1 file2)
+ "Return t if FILE1 and FILE2 are on the same host."
+ (let ((file1-remote (file-remote-p file1))
+ (file2-remote (file-remote-p file2)))
+ (string-equal file1-remote file2-remote)))
+
(provide 'ztree-util)
;;; ztree-util.el ends here