Skip to content
This repository has been archived by the owner on Jun 17, 2023. It is now read-only.

Address #38, #39 #45

Merged
merged 3 commits into from
Feb 8, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion ztree-diff.el
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ By default paths starting with dot (like .git) are ignored")
(defvar-local ztree-diff-wait-message nil
"Message showing while constructing the diff tree.")

(defvar ztree-diff--ediff-previous-window-configuration nil
Copy link
Owner

@fourier fourier Feb 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no conventions on private variables in ztree to have double dashes, please remove one.
Also please use defvar-local since we are allowing multiple ztree buffers

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

You should use double dashes for private variables/functions--it's Emacs convention, and helps keep the interface small.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to flame on this, but this I see as a more "modern" convention, which is certainly not emacs-wide, as tons of build-in packages are not using it (ediff, dired, gnus etc).
Moreover there are a lot of other "conventions", i.e. ztree/myvariable etc. Maybe I'll change it at some point but I see no reason in it right now..
And in this package I would prefer the consistency in naming anyway, evening if conventions are not that convenient.

"Window configuration prior to calling `ediff'.")

;;;###autoload
(define-minor-mode ztreediff-mode
Expand Down Expand Up @@ -224,6 +226,34 @@ Argument NODE node containing paths to files to call a diff on."
(let ((node (car found)))
(ztree-diff-simple-diff node)))))

(defun ztree-diff-ediff-before-setup-hook-function ()
"Hook function for `ediff-before-setup-hook'.

See the Info node `(ediff) hooks'.

This hook function removes itself."
(setq ztree-diff--ediff-previous-window-configuration (current-window-configuration))
(remove-hook 'ediff-before-setup-hook #'ztree-diff-ediff-before-setup-hook-function))

(defun ztree-diff-ediff-quit-hook-function ()
"Hook function for `ediff-quit-hook'.

See the Info node `(ediff) hooks'.

This hook function removes itself."
(ediff-kill-buffer-carefully ediff-registry-buffer)
(set-window-configuration ztree-diff--ediff-previous-window-configuration)
(remove-hook 'ediff-quit-hook #'ztree-diff-ediff-quit-hook-function))

(defun ztree-diff-ediff (file-a file-b &optional startup-hooks)
"Ediff that cleans up after itself.

Ediff-related buffers are killed and the pre-Ediff window
configuration is restored."
(add-hook 'ediff-before-setup-hook #'ztree-diff-ediff-before-setup-hook-function)
(add-hook 'ediff-quit-hook #'ztree-diff-ediff-quit-hook-function t)
(ediff file-a file-b startup-hooks))

(defun ztree-diff-node-action (node hard)
"Perform action on NODE:
1 if both left and right sides present:
Expand All @@ -243,7 +273,7 @@ Argument NODE node containing paths to files to call a diff on."
(if (eql (ztree-diff-node-different node) 'same)
(funcall open-f left)
(if hard
(ediff left right)
(ztree-diff-ediff left right)
(ztree-diff-simple-diff node))))
(left (funcall open-f left))
(right (funcall open-f right))
Expand Down