[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 159ddbd 26/36: Fixed partial update
From: |
Alexey Veretennikov |
Subject: |
[elpa] master 159ddbd 26/36: Fixed partial update |
Date: |
Wed, 27 Jan 2016 23:50:57 +0000 |
branch: master
commit 159ddbddd2c4f1c11e01d0a01b56ca3a13289258
Author: Alexey Veretennikov <address@hidden>
Commit: Alexey Veretennikov <address@hidden>
Fixed partial update
---
ztree-diff-model.el | 106 +++++++++++++++++++++------------------------------
ztree-diff.el | 51 +++++++++++++++++++++---
ztree-dir.el | 4 +-
ztree-util.el | 4 +-
ztree-view.el | 11 +++--
ztree.el | 4 +-
6 files changed, 101 insertions(+), 79 deletions(-)
diff --git a/ztree-diff-model.el b/ztree-diff-model.el
index b32350b..e73e1ee 100644
--- a/ztree-diff-model.el
+++ b/ztree-diff-model.el
@@ -1,8 +1,8 @@
;;; ztree-diff-model.el --- diff model for directory trees -*-
lexical-binding: t; -*-
-;; Copyright (C) 2013-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2016 Free Software Foundation, Inc.
;;
-;; Author: Alexey Veretennikov <alexey dot veretennikov at gmail dot com>
+;; Author: Alexey Veretennikov <address@hidden>
;;
;; Created: 2013-11-1l
;;
@@ -31,18 +31,19 @@
;;; Code:
(require 'ztree-util)
-
-(defvar-local ztree-diff-model-wait-message nil
- "Message showing while constructing the diff tree.")
+(eval-when-compile (require 'cl-lib))
(defvar-local ztree-diff-model-ignore-fun nil
"Function which determines if the node should be excluded from comparison.")
-(defun ztree-diff-model-update-wait-message ()
- "Update the wait mesage with one more '.' progress indication."
- (when ztree-diff-model-wait-message
- (setq ztree-diff-model-wait-message (concat ztree-diff-model-wait-message
"."))
- (message ztree-diff-model-wait-message)))
+(defvar-local ztree-diff-model-progress-fun nil
+ "Function which should be called whenever the progress indications is
updated.")
+
+
+(defun ztree-diff-model-update-progress ()
+ "Update the progress."
+ (when ztree-diff-model-progress-fun
+ (funcall ztree-diff-model-progress-fun)))
;; Create a record ztree-diff-node with defined fields and getters/setters
;; here:
@@ -153,30 +154,24 @@ Filters out . and .."
(directory-files dir 'full)))
(defun ztree-diff-model-partial-rescan (node)
- "Rescan the NODE."
- (let ((parent (ztree-diff-node-parent node))
- (isdir (ztree-diff-node-is-directory node))
- (left (ztree-diff-node-left-path node))
- (right (ztree-diff-node-right-path node)))
- (if (not parent) ;; if no parent - traverse
- (ztree-diff-node-recreate node)
- ;; verify if the node is not ignored by any chance
- (when (or (ztree-diff-node-ignore-p node)
- (eql (ztree-diff-node-different node) 'ignore))
- (ztree-diff-node-set-different node 'ignore))
- ;; if node is a directory - traverse
- (when (and left right
- (file-exists-p left)
- (file-exists-p right))
- (if isdir ;; traverse directory
- (ztree-diff-node-recreate node)
- ;; node is a file
- (ztree-diff-node-set-different
- node
- (if (ztree-diff-node-ignore-p node) 'ignore
- (ztree-diff-model-files-equal left right)))))
- ;; update all parents statuses
- (ztree-diff-node-update-all-parents-diff node))))
+ "Rescan the NODE.
+The node is a either a file or directory with both
+left and right parts existing."
+ ;; if a directory - recreate
+ (if (ztree-diff-node-is-directory node)
+ (ztree-diff-node-recreate node)
+ ;; if a file, change a status
+ (ztree-diff-node-set-different
+ node
+ (if (or (ztree-diff-model-ignore-p node) ; if should be ignored
+ (eql (ztree-diff-node-different node) 'ignore) ; was ignored
+ (eql (ztree-diff-node-different ; or parent was ignored
+ (ztree-diff-node-parent node)) 'ignore))
+ 'ignore
+ (ztree-diff-model-files-equal (ztree-diff-node-left-path node)
+ (ztree-diff-node-right-path node)))))
+ ;; update all parents statuses
+ (ztree-diff-node-update-all-parents-diff node))
(defun ztree-diff-model-subtree (parent path side diff)
"Create a subtree with given PARENT for the given PATH.
@@ -256,8 +251,9 @@ if in ignore list - ignore
if parent has ignored status - ignore"
(let ((parent (ztree-diff-node-parent node)))
(and parent
- (or (ztree-diff-model-ignore-p node)
- (eql (ztree-diff-node-different parent) 'ignore)))))
+ (or (eql (ztree-diff-node-different parent) 'ignore)
+ (ztree-diff-model-ignore-p node)))))
+
(defun ztree-diff-node-recreate (node)
@@ -269,7 +265,7 @@ if parent has ignored status - ignore"
(children-status (if should-ignore 'ignore 'new))
(children nil)) ;; list of children
;; update waiting status
- (ztree-diff-model-update-wait-message)
+ (ztree-diff-model-update-progress)
;; update node status ignore status either inhereted from the
;; parent or the own
(when should-ignore
@@ -346,35 +342,21 @@ if parent has ignored status - ignore"
(ztree-diff-node-set-children node children)))
-(defun ztree-diff-model-create (dir1 dir2 &optional ignore-p)
- "Create a node based on DIR1 and DIR2.
-IGNORE-P is the optional filtering function, taking node as
-an argument, which determines if the node should be excluded
-from comparison."
- (unless (file-directory-p dir1)
- (error "Path %s is not a directory" dir1))
- (unless (file-directory-p dir2)
- (error "Path %s is not a directory" dir2))
- (setf ztree-diff-model-ignore-fun ignore-p)
- (setq ztree-diff-model-wait-message (concat "Comparing " dir1 " and " dir2 "
..."))
- (let* ((model
- (ztree-diff-node-create nil dir1 dir2
- (ztree-file-short-name dir1)
- (ztree-file-short-name dir2)
- nil
- nil)))
- (ztree-diff-node-recreate model)
- (message "Done.")
- model))
-
(defun ztree-diff-model-update-node (node)
"Refresh the NODE."
- (setq ztree-diff-model-wait-message
- (concat "Updating " (ztree-diff-node-short-name node) " ..."))
- (ztree-diff-node-recreate node)
- (message "Done."))
+ (ztree-diff-node-recreate node))
+
+
+(defun ztree-diff-model-set-ignore-fun (ignore-p)
+ "Set the buffer-local ignore function to IGNORE-P.
+Ignore function is a function of one argument (ztree-diff-node)
+which returns t if the node should be ignored (like files starting
+with dot etc)."
+ (setf ztree-diff-model-ignore-fun ignore-p))
+(defun ztree-diff-model-set-progress-fun (progess-fun)
+ (setf ztree-diff-model-progress-fun progess-fun))
(provide 'ztree-diff-model)
diff --git a/ztree-diff.el b/ztree-diff.el
index d04cd36..d0a0f67 100644
--- a/ztree-diff.el
+++ b/ztree-diff.el
@@ -1,8 +1,8 @@
;;; ztree-diff.el --- Text mode diff for directory trees -*- lexical-binding:
t; -*-
-;; Copyright (C) 2013-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2016 Free Software Foundation, Inc.
;;
-;; Author: Alexey Veretennikov <alexey dot veretennikov at gmail dot com>
+;; Author: Alexey Veretennikov <address@hidden>
;;
;; Created: 2013-11-1l
;;
@@ -89,9 +89,13 @@ By default paths starting with dot (like .git) are ignored")
(defvar-local ztree-diff-show-equal-files t
"Show or not equal files/directories on both sides.")
-(defvar ztree-diff-show-filtered-files nil
+(defvar-local ztree-diff-show-filtered-files nil
"Show or not files from the filtered list.")
+(defvar-local ztree-diff-wait-message nil
+ "Message showing while constructing the diff tree.")
+
+
;;;###autoload
(define-minor-mode ztreediff-mode
"A minor mode for displaying the difference of the directory trees in text
mode."
@@ -302,7 +306,10 @@ COPY-TO-RIGHT specifies which side of the NODE to update."
target-full-path)
(ztree-diff-node-set-left-path node
target-full-path))
+ (setq ztree-diff-model-wait-message
+ (concat "Updating " (ztree-diff-node-short-name node) " ..."))
(ztree-diff-model-update-node node)
+ (message "Done.")
(ztree-diff-node-update-all-parents-diff node)
(ztree-refresh-buffer (line-number-at-pos)))))))
@@ -484,20 +491,41 @@ unless it is a parent node."
(ztree-refresh-buffer))
+(defun ztree-diff-update-wait-message ()
+ "Update the wait mesage with one more '.' progress indication."
+ (when ztree-diff-wait-message
+ (setq ztree-diff-wait-message (concat ztree-diff-wait-message "."))
+ (message ztree-diff-wait-message)))
+
;;;###autoload
(defun ztree-diff (dir1 dir2)
"Create an interactive buffer with the directory tree of the path given.
Argument DIR1 left directory.
Argument DIR2 right directory."
(interactive "DLeft directory \nDRight directory ")
- (let* ((difference (ztree-diff-model-create dir1 dir2
#'ztree-diff-node-ignore-p))
+ (unless (and dir1 (file-directory-p dir1))
+ (error "Path %s is not a directory" dir1))
+ (unless (file-exists-p dir1)
+ (error "Path %s does not exist" dir1))
+ (unless (and dir2 (file-directory-p dir2))
+ (error "Path %s is not a directory" dir2))
+ (unless (file-exists-p dir2)
+ (error "Path %s does not exist" dir2))
+ (let* ((model
+ (ztree-diff-node-create nil dir1 dir2
+ (ztree-file-short-name dir1)
+ (ztree-file-short-name dir2)
+ nil
+ nil))
(buf-name (concat "*"
- (ztree-diff-node-short-name difference)
+ (ztree-diff-node-short-name model)
" <--> "
- (ztree-diff-node-right-short-name difference)
+ (ztree-diff-node-right-short-name model)
"*")))
+ ;; after this command we are in a new buffer,
+ ;; so all buffer-local vars are valid
(ztree-view buf-name
- difference
+ model
'ztree-node-is-visible
'ztree-diff-insert-buffer-header
'ztree-diff-node-short-name-wrapper
@@ -508,11 +536,20 @@ Argument DIR2 right directory."
'ztree-diff-node-action
'ztree-diff-node-side)
(ztreediff-mode)
+ (ztree-diff-model-set-ignore-fun #'ztree-diff-node-ignore-p)
+ (ztree-diff-model-set-progress-fun #'ztree-diff-update-wait-message)
(setq ztree-diff-dirs-pair (cons dir1 dir2))
+
+ (setq ztree-diff-wait-message (concat "Comparing " dir1 " and " dir2 "
..."))
+ (ztree-diff-node-recreate model)
+ (message "Done.")
+
(ztree-refresh-buffer)))
+
+
(provide 'ztree-diff)
;;; ztree-diff.el ends here
diff --git a/ztree-dir.el b/ztree-dir.el
index 3dd87b7..90ef4b4 100644
--- a/ztree-dir.el
+++ b/ztree-dir.el
@@ -1,8 +1,8 @@
;;; ztree-dir.el --- Text mode directory tree -*- lexical-binding: t; -*-
-;; Copyright (C) 2013-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2016 Free Software Foundation, Inc.
;;
-;; Author: Alexey Veretennikov <alexey dot veretennikov at gmail dot com>
+;; Author: Alexey Veretennikov <address@hidden>
;;
;; Created: 2013-11-1l
;;
diff --git a/ztree-util.el b/ztree-util.el
index 85df444..109a897 100644
--- a/ztree-util.el
+++ b/ztree-util.el
@@ -1,8 +1,8 @@
;;; ztree-util.el --- Auxulary utilities for the ztree package -*-
lexical-binding: t; -*-
-;; Copyright (C) 2013-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2016 Free Software Foundation, Inc.
;;
-;; Author: Alexey Veretennikov <alexey dot veretennikov at gmail dot com>
+;; Author: Alexey Veretennikov <address@hidden>
;;
;; Created: 2013-11-1l
;;
diff --git a/ztree-view.el b/ztree-view.el
index fd3cd90..dce0d14 100644
--- a/ztree-view.el
+++ b/ztree-view.el
@@ -1,8 +1,8 @@
;;; ztree-view.el --- Text mode tree view (buffer) -*- lexical-binding: t; -*-
-;; Copyright (C) 2013-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2016 Free Software Foundation, Inc.
;;
-;; Author: Alexey Veretennikov <alexey dot veretennikov at gmail dot com>
+;; Author: Alexey Veretennikov <address@hidden>
;;
;; Created: 2013-11-1l
;;
@@ -626,7 +626,9 @@ Optional argument LINE scroll to the line given."
children-fun
face-fun
action-fun
- &optional node-side-fun
+ &optional
+ node-side-fun
+ post-create-hook
)
"Create a ztree view buffer configured with parameters given.
Argument BUFFER-NAME Name of the buffer created.
@@ -641,7 +643,8 @@ Argument EQUAL-FUN An equality function for nodes.
Argument CHILDREN-FUN Function to get children from the node.
Argument FACE-FUN Function to determine face of the node.
Argument ACTION-FUN an action to perform when the Return is pressed.
-Optional argument NODE-SIDE-FUN Determines the side of the node."
+Optional argument NODE-SIDE-FUN Determines the side of the node.
+Optional argument POST-CREATE-FUN"
(let ((buf (get-buffer-create buffer-name)))
(switch-to-buffer buf)
(ztree-mode)
diff --git a/ztree.el b/ztree.el
index 01d7c06..085be7e 100644
--- a/ztree.el
+++ b/ztree.el
@@ -1,8 +1,8 @@
;;; ztree.el --- Text mode directory tree -*- lexical-binding: t; -*-
-;; Copyright (C) 2013-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2016 Free Software Foundation, Inc.
;;
-;; Author: Alexey Veretennikov <alexey dot veretennikov at gmail dot com>
+;; Author: Alexey Veretennikov <address@hidden>
;;
;; Created: 2013-11-1l
;;
- [elpa] master a27dbbd 22/36: Started to fix issues with delete file, (continued)
- [elpa] master a27dbbd 22/36: Started to fix issues with delete file, Alexey Veretennikov, 2016/01/27
- [elpa] master c3144bd 16/36: Updated model - ignored files still not handled, Alexey Veretennikov, 2016/01/27
- [elpa] master bc6a12a 18/36: Traverse function now supports ignored, Alexey Veretennikov, 2016/01/27
- [elpa] master b021697 29/36: Added comment to not to forget to update copy procedure., Alexey Veretennikov, 2016/01/27
- [elpa] master da721ab 33/36: Fixed compile warnings, Alexey Veretennikov, 2016/01/27
- [elpa] master be4e000 24/36: Fix typo in value of Created header keyword, Alexey Veretennikov, 2016/01/27
- [elpa] master b5b2d02 32/36: removed test files, Alexey Veretennikov, 2016/01/27
- [elpa] master 74899aa 30/36: Merge branch 'master' of github.com:fourier/ztree, Alexey Veretennikov, 2016/01/27
- [elpa] master 6d7ce1f 28/36: Fixed Delete method, Alexey Veretennikov, 2016/01/27
- [elpa] master 3d70aef 25/36: Merge pull request #30 from tarsius/fix-typo, Alexey Veretennikov, 2016/01/27
- [elpa] master 159ddbd 26/36: Fixed partial update,
Alexey Veretennikov <=
- [elpa] master a7c5489 35/36: Upgraded version number, Alexey Veretennikov, 2016/01/27
- [elpa] master 7b5dfce 23/36: Use defvar-local instead of combo defvar && make-variable-buffer-local, Alexey Veretennikov, 2016/01/27
- [elpa] master e143f66 27/36: Fixed copy of the files; added 'R' for full rescan, Alexey Veretennikov, 2016/01/27
- [elpa] master dbf9539 31/36: Fixed issue #27, Alexey Veretennikov, 2016/01/27
- [elpa] master 597b005 34/36: 2016-01-26 Stefan Monnier <address@hidden>, Alexey Veretennikov, 2016/01/27
- [elpa] master a136ff8 36/36: Merged from upstream with StefanM's changes, Alexey Veretennikov, 2016/01/27