branch: externals/ztree commit 50412fa553fb68fcd7218cc44cf66b5342ab6889 Author: Alexey Veretennikov <alexey.veretenni...@gmail.com> Commit: Alexey Veretennikov <alexey.veretenni...@gmail.com>
Issue #65: added ztree-diff-additional-options variable Now the special variable ztree-diff-additional-options introduced to provide an additional arguments to the 'diff' tool. For example one could specify (setq ztree-diff-additional-options '("-w" "-i")) to ignore case differences and whitespace differences. --- ztree-diff-model.el | 16 +++++++++++++--- ztree-diff.el | 5 ++++- ztree-view.el | 12 ++++++++---- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/ztree-diff-model.el b/ztree-diff-model.el index d31ce34..219ad68 100644 --- a/ztree-diff-model.el +++ b/ztree-diff-model.el @@ -36,6 +36,13 @@ (defvar ztree-diff-consider-file-permissions nil "Mark files as different if their permissions are different") +(defvar ztree-diff-additional-options nil + "Command-line options for the diff program used as a diff backend. These options are added to default '-q' option. +Should be a list of strings. +Example: +(setq ztree-diff-options '(\"-w\" \"-i\"))") + + (defvar-local ztree-diff-model-ignore-fun nil "Function which determines if the node should be excluded from comparison.") @@ -154,9 +161,12 @@ Returns t if equal." (and ztree-diff-consider-file-permissions (not (string-equal (nth 8 (file-attributes file1)) (nth 8 (file-attributes file2))))) - (/= 0 (process-file diff-command nil nil nil "-q" - file1-untrampified - file2-untrampified))) + (/= 0 + (apply #'process-file + diff-command nil nil nil + `("-q" ,@ztree-diff-additional-options + ,file1-untrampified + ,file2-untrampified)))) 'diff 'same))) diff --git a/ztree-diff.el b/ztree-diff.el index 3ff39fb..7634816 100644 --- a/ztree-diff.el +++ b/ztree-diff.el @@ -242,7 +242,7 @@ See the Info node `(ediff) hooks'. This hook function removes itself." (push (current-window-configuration) ztree-diff-ediff-previous-window-configurations) - (setq ztree-prev-position (cons (line-number-at-pos (point)) (current-column))) + (ztree-save-current-position) (remove-hook 'ediff-before-setup-hook #'ztree-diff-ediff-before-setup-hook-function)) (defun ztree-diff-ediff-quit-hook-function () @@ -272,6 +272,9 @@ configuration is restored." 1.1.2 simple diff otherwiste 1.2 if they are the same - view left 2 if left or right present - view left or rigth" + ;; save current position in case if the window + ;; configuration will change + (ztree-save-current-position) (let ((left (ztree-diff-node-left-path node)) (right (ztree-diff-node-right-path node)) ;; FIXME: The GNU convention is to only use "path" for lists of diff --git a/ztree-view.el b/ztree-view.el index e053210..9f0cef8 100644 --- a/ztree-view.el +++ b/ztree-view.el @@ -683,6 +683,12 @@ Returns the position where the text starts." (ztree-scroll-to-line (line-number-at-pos))))) +(defun ztree-save-current-position () + "Save the current position into the global variable." + (setq ztree-prev-position (cons (line-number-at-pos (point)) + (current-column)))) + + (defun ztree-refresh-buffer (&optional line) "Refresh the buffer. Optional argument LINE scroll to the line given." @@ -694,8 +700,7 @@ Optional argument LINE scroll to the line given." ;; create a hash table of node properties for line (setq ztree-line-tree-properties (make-hash-table)) (let ((inhibit-read-only t)) - (setq ztree-prev-position (cons (line-number-at-pos (point)) - (current-column))) + (ztree-save-current-position) (erase-buffer) (funcall ztree-tree-header-fun) (setq ztree-start-line (line-number-at-pos (point))) @@ -707,8 +712,7 @@ Optional argument LINE scroll to the line given." (goto-char (+ (cdr ztree-prev-position) (point))))) ((and (null line) (null prev-pos)) ;; first refresh (ztree-scroll-to-line ztree-start-line) - (setq ztree-prev-position (cons (line-number-at-pos (point)) - (current-column)))) + (ztree-save-current-position)) ((and (null line) prev-pos) ;; not first refresh ;; restore cursor position if possible (ztree-scroll-to-line (car ztree-prev-position))