# HG changeset patch # User Ludovic Chabant # Date 1323716386 28800 # Node ID 82a49134a85c9b232bca114a7db553105a0ea17e # Parent 1e155bfa94ad9d139c35244c164ae5686db095d4 Added keyboard shortcuts to Hgstatus window. diff -r 1e155bfa94ad -r 82a49134a85c plugin/lawrencium.vim --- a/plugin/lawrencium.vim Sun Dec 11 23:04:36 2011 -0800 +++ b/plugin/lawrencium.vim Mon Dec 12 10:59:46 2011 -0800 @@ -287,16 +287,15 @@ nnoremap :call search('^[MARC\!\?I ]\s.', 'We') nnoremap :call search('^[MARC\!\?I ]\s.','Wbe') nnoremap :execute HgStatus_FileEdit() + nnoremap :execute HgStatus_FileDiff(0) + nnoremap :execute HgStatus_FileDiff(1) nnoremap q :bdelete endfunction function! s:HgStatus_FileEdit() abort - let l:repo = s:hg_repo() - let l:line = getline('.') - " Yay, awesome, Vim's regex syntax is fucked up like shit, especially for - " look-aheads and look-behinds. See for yourself: - let l:filename = matchstr(l:line, '\([MARC\!\?I ]\s\)\@<=.*') - let l:filename = l:repo.GetFullPath(l:filename) + " Get the path of the file the cursor is on. + let l:filename = s:HgStatus_GetSelectedPath() + " Go back to the previous window and open the file there, or open an " existing buffer. wincmd p @@ -307,6 +306,25 @@ endif endfunction +function! s:HgStatus_FileDiff(vertical) abort + " Get the path of the file the cursor is on. + let l:filename = s:HgStatus_GetSelectedPath() + + " Go back to the previous window and call HgDiff. + wincmd p + call s:HgDiff(l:filename, a:vertical) +endfunction + +function! s:HgStatus_GetSelectedPath() abort + let l:repo = s:hg_repo() + let l:line = getline('.') + " Yay, awesome, Vim's regex syntax is fucked up like shit, especially for + " look-aheads and look-behinds. See for yourself: + let l:filename = matchstr(l:line, '\([MARC\!\?I ]\s\)\@<=.*') + let l:filename = l:repo.GetFullPath(l:filename) + return l:filename +endfunction + call s:AddMainCommand("Hgstatus :execute s:HgStatus()") " }}}