emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master af28a78 41/92: Started implementation of the copy function


From: Alexey Veretennikov
Subject: [elpa] master af28a78 41/92: Started implementation of the copy functionality
Date: Thu, 11 Jun 2015 19:48:03 +0000

branch: master
commit af28a7892abffacb6ef8296ead3f9de578c7edeb
Author: Alexey Veretennikov <address@hidden>
Commit: Alexey Veretennikov <address@hidden>

    Started implementation of the copy functionality
---
 ztree-diff.el |   35 +++++++++++++++++++++++++----------
 ztree-view.el |   21 +++++++++++++++++++++
 2 files changed, 46 insertions(+), 10 deletions(-)

diff --git a/ztree-diff.el b/ztree-diff.el
index 1e232f5..f08f89f 100644
--- a/ztree-diff.el
+++ b/ztree-diff.el
@@ -68,11 +68,10 @@ including . and ..")
 (defvar ztreep-diff-model-normal-face 'ztreep-diff-model-normal-face)
 
 
-(defvar ztreediff-mode-map
-  (let ((map (make-sparse-keymap)))
-    (define-key map (kbd "C") 'ztree-diff-copy)
-    map)
-  "Keymap for `ztreediff-mode'.")
+(defvar ztreediff-dirs-pair nil
+  "Pair of the directories stored. Used to perform the full rescan")
+(make-variable-buffer-local 'ztrediff-dirs-par)
+
 
 ;;;###autoload
 (define-minor-mode ztreediff-mode
@@ -83,8 +82,8 @@ including . and ..")
   " Diff"
   ;; The minor mode keymap
   `(
-    (,(kbd "C") . ztree-diff-copy)))
-
+    (,(kbd "C") . ztree-diff-copy)
+    ([f5] . ztree-diff-full-rescan)))
 
 
 (defun ztree-diff-node-face (node)
@@ -110,6 +109,13 @@ including . and ..")
   (insert-with-face "==============" ztreep-diff-header-face)
   (newline))
 
+(defun ztree-diff-full-rescan ()
+  (interactive)
+  (when (and ztreediff-dirs-pair
+             (yes-or-no-p (format "Force full rescan?")))
+    (ztree-diff (car ztreediff-dirs-pair) (cdr ztreediff-dirs-pair))))
+
+
 (defun ztree-diff-node-action (node)
   (let ((left (ztree-diff-node-left-path node))
         (right (ztree-diff-node-right-path node)))
@@ -126,15 +132,24 @@ including . and ..")
 
 (defun ztree-diff-copy ()
   (interactive)
-  (let ((node (ztree-find-node-in-line (line-number-at-pos))))
-    (when node
-      (message (ztree-diff-node-short-name node)))))
+  (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 
 
 (defun ztree-diff (dir1 dir2)
   "Creates an interactive buffer with the directory tree of the path given"
   (interactive "DLeft directory \nDRight directory ")
   (let* ((difference (ztree-diff-model-create dir1 dir2))
          (buf-name (concat "*" (ztree-diff-node-short-name difference) "*")))
+    (setq ztreediff-dirs-pair (cons dir1 dir2))
     (ztree-view buf-name
                 difference
                 (list ztree-diff-hidden-files-regexp)
diff --git a/ztree-view.el b/ztree-view.el
index 9192c97..e999bff 100644
--- a/ztree-view.el
+++ b/ztree-view.el
@@ -137,6 +137,7 @@ the buffer is split to 2 trees")
     (define-key map (kbd "\r") 'ztree-perform-action)
     (define-key map (kbd "SPC") 'ztree-perform-action)
     (define-key map [double-mouse-1] 'ztree-perform-action)
+    (define-key map (kbd "TAB") 'ztree-jump-side)
     (define-key map (kbd "g") 'ztree-refresh-buffer)
     (if window-system
         (define-key map (kbd "<backspace>") 'ztree-move-up-in-tree)
@@ -188,6 +189,15 @@ the buffer is split to 2 trees")
 node for the line specified"
   (gethash line ztree-line-to-node-table))
 
+(defun ztree-find-node-at-point ()
+  "Returns cons pair (node, side) for the current point or nil
+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)))))
+  
+
 (defun ztree-is-expanded-node (node)
   "Find if the node is in the list of expanded nodes"
   (ztree-find ztree-expanded-nodes-list
@@ -472,6 +482,17 @@ apparently shall not be visible"
                              'face (if face face 'ztreep-leaf-face) short-name)
           (insert short-name))))))
 
+(defun ztree-jump-side ()
+  (interactive)
+  (when ztree-node-side-fun             ; 2-sided tree
+    (let ((center (/ (window-width) 2)))
+      (cond ((< (current-column) center) 
+             (move-to-column (1+ center)))
+            ((> (current-column) center) 
+             (move-to-column 1))
+            (t nil)))))
+
+
 
 (defun ztree-refresh-buffer (&optional line)
   (interactive)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]