branch: master commit 725f388c6b41df75f8c680b7f12d5422d2ebbd49 Author: Alexey Veretennikov <alexey.veretenni...@gmail.com> Commit: Alexey Veretennikov <alexey.veretenni...@gmail.com>
Preparation to copy implementation done --- ztree-diff.el | 45 +++++++++++++++++++++++++++++++++++---------- ztree-view.el | 2 +- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/ztree-diff.el b/ztree-diff.el index f08f89f..50c8b7c 100644 --- a/ztree-diff.el +++ b/ztree-diff.el @@ -134,16 +134,41 @@ including . and ..") (interactive) (let ((found (ztree-find-node-at-point))) (when found - (let ((side (cdr found)) - (node-side (ztree-diff-node-side node))) - )))) - ;; determine a side to copy from/to - ;; (eq node-side 'both) - ;; (eq node-side side)) - - ;; (parent (ztree-diff-node-parent node))) - ;; (when - + (let* ((node (car found)) + (side (cdr found)) + (node-side (ztree-diff-node-side node)) + (copy-to-right t) ; copy from left to right + (node-left (ztree-diff-node-left-path node)) + (node-right (ztree-diff-node-right-path node)) + (source-path nil) + (destination-path nil) + (parent (ztree-diff-node-parent node))) + (when parent + ;; determine a side to copy from/to + ;; algorithm: + ;; 1) if both side are present, use the side + ;; variable + (setq copy-to-right (if (eq node-side 'both) + (eq side 'left) + ;; 2) if one of sides is absent, copy from + ;; the side where the file is present + (eq node-side 'left))) + ;; 3) in both cases determine if the destination + ;; directory is in place + (setq source-path (if copy-to-right node-left node-right) + destination-path (if copy-to-right + (ztree-diff-node-right-path parent) + (ztree-diff-node-left-path parent))) + (when (and source-path destination-path + (yes-or-no-p (format "Copy [%s]%s to [%s]%s/ ?" + (if copy-to-right "LEFT" "RIGHT") + (ztree-diff-node-short-name node) + (if copy-to-right "RIGHT" "LEFT") + destination-path))) + nil ; do copy + )))))) + + (defun ztree-diff (dir1 dir2) "Creates an interactive buffer with the directory tree of the path given" (interactive "DLeft directory \nDRight directory ") diff --git a/ztree-view.el b/ztree-view.el index e999bff..6e6cfce 100644 --- a/ztree-view.el +++ b/ztree-view.el @@ -195,7 +195,7 @@ if there is no node" (let ((center (/ (window-width) 2)) (node (ztree-find-node-in-line (line-number-at-pos)))) (when node - (cons node (if (> (current-column) center) 'left 'right))))) + (cons node (if (> (current-column) center) 'right 'left))))) (defun ztree-is-expanded-node (node)