Skip to content

Commit

Permalink
Mark files as persistent/sticky (i.e. the won't be removed from the l…
Browse files Browse the repository at this point in the history
…ist)
  • Loading branch information
tomtom committed Oct 28, 2012
1 parent 75e5502 commit a0fae6f
Showing 1 changed file with 51 additions and 1 deletion.
52 changes: 51 additions & 1 deletion plugin/tmru.vim
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,13 @@ if !exists('g:tmru_world') "{{{2
\ 'allow_suspend': 0,
\ 'query': 'Select file',
\ }
" \ 'filter_format': 'fnamemodify(%s, ":t")',
" \ 'filter_format': 'fnamemodify(%s, ":t")',
if !empty(g:tmru_file)
call add(g:tmru_world.key_handlers,
\ {'key': 16, 'agent': s:SNR() .'TogglePersistent', 'key_name': '<c-p>', 'help': 'Toggle a file''s persistent mark'})
call add(g:tmru_world.key_handlers,
\ {'key': 21, 'agent': s:SNR() .'UnsetPersistent', 'key_name': '<c-u>', 'help': 'Unset a file''s persistent mark'})
endif
endif


Expand Down Expand Up @@ -447,6 +453,50 @@ function! s:MruRegister(fname, save)
endf


function! s:UnsetPersistent(world, selected) "{{{3
let mru = s:MruRetrieve()
let filenames = s:GetFilenames(mru)
for filename in a:selected
let fidx = index(filenames, filename)
" TLogVAR filename, fidx
if fidx >= 0
let mru[fidx][1]['sticky'] = 0
endif
endfor
call s:MruStore(mru, 1)
let a:world.base = s:GetFilenames(mru)
let a:world.state = 'reset'
return a:world
endf


function! s:TogglePersistent(world, selected) "{{{3
let mru = s:MruRetrieve()
let filenames = s:GetFilenames(mru)
let msgs = []
for filename in a:selected
let fidx = index(filenames, filename)
" TLogVAR filename, fidx
if fidx >= 0
let props = mru[fidx][1]
let props['sticky'] = !get(props, 'sticky', 0)
call add(msgs, printf('Mark %ssticky: %s', props.sticky ? '' : 'not ', filename))
let mru[fidx][1] = props
endif
endfor
if !empty(msgs)
echom join(msgs, "\n")
echohl MoreMsg
call input("Press ENTER to continue")
echohl NONE
endif
call s:MruStore(mru, 1)
let a:world.base = s:GetFilenames(mru)
let a:world.state = 'reset'
return a:world
endf


function! s:RemoveItem(world, selected) "{{{3
let mru = s:MruRetrieve()
let filenames = s:GetFilenames(mru)
Expand Down

0 comments on commit a0fae6f

Please sign in to comment.