-
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
vundo-diff #78
vundo-diff #78
Conversation
vundo-diff.el
Outdated
(display-buffer dbuf))))) | ||
|
||
;;;###autoload | ||
(define-minor-mode vundo-diff-mode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with setting these keybindings by default in vundo.el, and autoload them in vundo-diff.el.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That way we don't need a minor mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, great, done. Should we declare-function
in vundo.el
to avoid linter issues? I'm always worried autoloads won't get compiled or run correctly (for no good reason).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that I had missed a key conflict, and moved (d)ebug
to (D)ebug
.
vundo-diff.el
Outdated
'font-lock-face | ||
'(diff-file-header diff-header)) | ||
collect | ||
(if-let* ((vundo-highlight-saved-nodes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know what you want to to, but are you sure this is the right way? Don't you need to assign vundo-highlight-saved-nodes
to some variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This basically means you only get "Saved at: " in the diff buffer when you have enabled highlight-saved-nodes
. But that's sort of silly; I have removed it. We are storing TS data anyway. I also update vundo.el so that TS info is always calculated (including on save), whether or not we are showing it. No sense mixing display and backend logic.
Thanks. Indent fixed. For your color codes in terminal, maybe try The one other feature I considered overnight is just replacing those terrible tmp file names with the Current/Marked (with TS). But it sounds a bit fragile, so maybe not worth it for the improved cleanliness. |
vundo-diff.el
Outdated
(vundo--move-to-node current marked orig vundo--prev-mod-list) | ||
(with-current-buffer mrkbuf | ||
(insert-buffer-substring-no-properties orig)) | ||
(vundo--refresh-buffer orig (current-buffer) 'incremental) | ||
(vundo--move-to-node marked current orig vundo--prev-mod-list) | ||
(vundo--refresh-buffer orig (current-buffer) 'incremental) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to double-check. Is it your understanding that you need to (vundo--refresh-buffer ... 'incremental)
after every move-to-node
like this? Somehow I got the impression that this is needed only once (i.e. you can move as much as you like). But I get aref
and no route
errors without both of these calls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually maybe this was because I wasn't doing trim-undo-list
. Just added that and dropped to a single refresh-buffer
and all seems OK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I take it back. I get no route
without a refresh-buffer
after each move. Restored that. Any idea why? Perhaps because I'm "reversing direction", i.e. moving from current->marked then marked->current?
I have added a sanity check wrapper prior to the moves, and pushed some README/NEWS changes for your consideration. I'm still playing with the formatting in the diff buffer, will wrap that up soon. |
I made a few more improvements today:
This PR is pretty well complete IMO, pending any further review. |
Looks nice!
Why use the async version? IMO the sync version is perfectly fine and should be simpler to use, right? And I wonder if we can use a single key to mark/unmark nodes, instead of using both |
Since it's the default, people might be used to that behavior of diff. The cost to support async is not high: just a lambda for the process sentinel. And sometimes tmp files are across a tramp link. [Update: since all the undo data are in process, I don't buy my own argument. I've switched to a sync-call for simplicity. ]
We could make it so that And if you don't mind taking a look up at my question about |
Ok, I trust your judgement here.
Yeah, moving to a node pushes new undo entries onto undo-list, and we need to process those with |
Thanks for the feedback.
I think what confuses me is this note from the
That doesn't seem to be the case here. I.e. you must call Found one more little doc tweak I pushed, so this is ready to go. In terms of version bump, I do have a couple of small things I'd like to send in as a small additional PR once this is merged:
|
Oh, I would trust the me that wrote the comment much more than I trust the me right now. If the comment says so, we should be able to run I think I know why you'll get "no route". One example: in an undo list [1 2 3 4 5], you'd have mod list [1 2 3 4 5], and if you go back to node 3, your undo list becomes [1 2 3 4 5 4' 3'], but without calling Good call though, I never thought about this before. I should add a comment somewhere calling this out. So the branch is ready for a final review, right? It'd be great if you can squash everything and write a commit message. Then I'll review and merge it. |
Right, you can't change direction between
Great thanks, commits squashed, ready for review. Once merged I'll submit my small PR for timestamp stuff (I'm already loving multiple |
Ok, some final nits:
|
27b49a8
to
428b6a1
Compare
Add support for computing the diff between a marked and the current node, displaying in a custom vundo-diff buffer with color-matched timestamped modifications. * vundo-diff.el: New file. * vundo.el (vundo, vundo--node-timestamp, vundo--draw-tree): Return timestamp from undo-list or unmodified current buffer, bind new keys, change overlay priority, and separate timestamp display from calculation.
OK should be all set, thanks for the review. I also threw in a docstring escape of single quotes to silence the compiler. Once this is merged I have a TS-related PR I'll post. |
Merged, thanks! |
This provides
vundo-diff
support with the following capabilities:It's optional, enabled by the(now builtin)vundo-diff-mode
global minor mode(m)ark
,(u)nmark
, and(d)iff