Skip to content
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

Add tags and tags switch commands #100

Open
00sapo opened this issue Oct 2, 2020 · 2 comments
Open

Add tags and tags switch commands #100

00sapo opened this issue Oct 2, 2020 · 2 comments

Comments

@00sapo
Copy link

00sapo commented Oct 2, 2020

It would be useful to have a command to tag versions (similarly to git tags) and a command to switch to a certain tag version.

For instance, when you're debugging code, you often need to observe the program behavior with different strategies, but you don't want to put wrong code on git...

@simnalamburt
Copy link
Owner

To add tag support, we'll need to store the tag information somewhere. Does vim undotree have such feature?

Currently, vim-mundo is just a fancy frontend for vim's undotree feature, it doesn't have any external storage or something.

@idbrii
Copy link
Contributor

idbrii commented Jul 6, 2021

but you don't want to put wrong code on git...

Why not? You could make multiple branches with different experiments. That would allow you to quickly switch between them (including groups of files instead of individual ones), diff them, and build upon them. And when you're done, delete the branches. All without pushing that experimental code anywhere.

However, maybe mundo can better communicate what the numbers in the undotree mean. Given the graph:

o    [5] <1 min ago 
|    
o    [4] <1 min ago 
|    
| o  [3] <1 min ago 
| |  
| @  [2] 7 mins ago 
|/   
o    [1] 7 mins ago 
|    
o    [0] Original   

You can use :undo 4 to apply the change state for the node marked [4]. So the nodes are already tagged, but not with names! Adding names, tracking them in mundo, showing them in the graph, and knowing when to clear them seems like unnecessary complexity that isn't part of the goal of mundo (visualizing the undotree)).

However, if you really want to use undo instead of git, you can whip something up like so:

function! s:GetMarkList()
    let b:undomarks = get(b:, 'undomarks', {})
    return b:undomarks
endf

function! s:SetMarkList(key, val)
    let marks = s:GetMarkList()
    let marks[a:key] = a:val
endf

function! s:UndoComplete(...)
    return keys(s:GetMarkList())
endf

" These commands only apply to the current buffer, not the mundo
" buffer. (This code doesn't integrate with mundo at all.)
command! -nargs=+ UndoMark call s:SetMarkList(<q-args>, undotree().seq_cur)
command! -nargs=+ -complete=customlist,s:UndoComplete UndoJump exec 'undo' get(s:GetMarkList(), <q-args>, 'invalid mark')

Then you can :UndoMark blah and :UndoJump <Tab>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants