-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Live diffing (like undo-tree has) #112
Comments
Thanks for your kind words :) Try this:
|
Thanks for this @casouri ! I went a step further and ended up with this: ;; Displays undo history as a tree and lets you move through it.
(use-package vundo
:defer t
:config
(setq vundo-glyph-alist vundo-unicode-symbols)
;;;;;; Vundo Live Diff ;;;;;;
;; In vundo, you have to manually mark one node and call diff on another node to get their diff.
;; Here we extend vundo to have "live diff mode", that always shows diff between current node and its parent.
;; I turn it on by default. It can be toggled by pressing "f".
(defun vundo-live-diff-post-command ()
"Post command hook function for live diffing."
(when (not (memq this-command '(vundo-quit vundo-confirm)))
(progn
(vundo-diff-mark (vundo-m-parent (vundo--current-node vundo--prev-mod-list)))
(vundo-diff)
)
)
)
(define-minor-mode vundo-live-diff-mode
"Shows live diff between the current node and its parent."
:lighter nil
(if vundo-live-diff-mode
(add-hook 'post-command-hook #'vundo-live-diff-post-command 0 t)
(remove-hook 'post-command-hook #'vundo-live-diff-post-command t)
)
)
(evil-define-key 'normal vundo-mode-map (kbd "F") #'vundo-live-diff-mode)
(add-hook 'vundo-mode-hook (lambda () (vundo-live-diff-mode 1)))
;;;;;/ Vundo Live Diff ;;;;;;
) Now, diff opens immediately, and mark follows the current node so we always see the diff between it and its parent -> this is exactly the behaviour from node-tree that I wanted to replicate. And I can turn it off, of course, if I want. Your code helped a lot, I never wrote minor mode and wouldn't think of it as a solution, and it also helped a lot the fact that the code in vundo(-diff).el is quite nicely written / documented. Btw, a couple of weird errors I hit:
|
Hi, first of all thanks a lot for this package and effort that goes into it!
I have been using undo-tree for years but learned about undo-fu + vundo combo and decided to switch, and I love it, the only thing I have been missing is how undo-tree shows diff. What it does, if I am correct, is show diff between the node you are currently viewing and the node before it, therefore giving you an idea of the changes that this node introduces. I find this super helpful and it usually helps me figure out where I made specific change, so I can go back there, pick a piece of it maybe, then return, and similar. This is done "live" -> so as you move around the tree, the diff window is updated.
I know vundo has the option to show diff on demand, but that makes the workflow from above much harder, I would have to keep marking and unmarking nodes.
How hard would this be to add? Maybe I can help out? I am experienced programmer but not with elisp, however I could probably find my way around with enough time. Would this be a good match for vundo, both regarding DX and current architecture?
Also, do you have any suggestion on how I might hack this in the meantime? Maybe I could hook in into the move functions of vundo (with advice?) and try to automate marking, unmarking, and diffing to run on every move hm.
Thanks!
The text was updated successfully, but these errors were encountered: