Mercurial > vim-lawrencium
comparison plugin/lawrencium.vim @ 40:a63ec818ab21
Added `qnew` and `qrefresh` commands to the `Hgstatus` window.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Fri, 30 Mar 2012 15:29:10 -0700 |
parents | 9361f6b9e5a4 |
children | decbefcf74db |
comparison
equal
deleted
inserted
replaced
39:42c40b8144f8 | 40:a63ec818ab21 |
---|---|
368 command! -buffer Hgstatusvdiff :call s:HgStatus_Diff(1) | 368 command! -buffer Hgstatusvdiff :call s:HgStatus_Diff(1) |
369 command! -buffer Hgstatusrefresh :call s:HgStatus_Refresh() | 369 command! -buffer Hgstatusrefresh :call s:HgStatus_Refresh() |
370 command! -buffer -range Hgstatusaddremove :call s:HgStatus_AddRemove(<line1>, <line2>) | 370 command! -buffer -range Hgstatusaddremove :call s:HgStatus_AddRemove(<line1>, <line2>) |
371 command! -buffer -range=% -bang Hgstatuscommit :call s:HgStatus_Commit(<line1>, <line2>, <bang>0, 0) | 371 command! -buffer -range=% -bang Hgstatuscommit :call s:HgStatus_Commit(<line1>, <line2>, <bang>0, 0) |
372 command! -buffer -range=% -bang Hgstatusvcommit :call s:HgStatus_Commit(<line1>, <line2>, <bang>0, 1) | 372 command! -buffer -range=% -bang Hgstatusvcommit :call s:HgStatus_Commit(<line1>, <line2>, <bang>0, 1) |
373 command! -buffer -range=% -nargs=+ Hgstatusqnew :call s:HgStatus_QNew(<line1>, <line2>, <f-args>) | |
374 command! -buffer -range=% Hgstatusqrefresh :call s:HgStatus_QRefresh(<line1>, <line2>) | |
373 | 375 |
374 " Add some handy mappings. | 376 " Add some handy mappings. |
375 if g:lawrencium_define_mappings | 377 if g:lawrencium_define_mappings |
376 nnoremap <buffer> <silent> <cr> :Hgstatusedit<cr> | 378 nnoremap <buffer> <silent> <cr> :Hgstatusedit<cr> |
377 nnoremap <buffer> <silent> <C-N> :call search('^[MARC\!\?I ]\s.', 'We')<cr> | 379 nnoremap <buffer> <silent> <C-N> :call search('^[MARC\!\?I ]\s.', 'We')<cr> |
460 function! s:HgStatus_Diff(vertical) abort | 462 function! s:HgStatus_Diff(vertical) abort |
461 " Open the file and run `Hgdiff` on it. | 463 " Open the file and run `Hgdiff` on it. |
462 call s:HgStatus_FileEdit() | 464 call s:HgStatus_FileEdit() |
463 call s:HgDiff('%:p', a:vertical) | 465 call s:HgDiff('%:p', a:vertical) |
464 endfunction | 466 endfunction |
467 | |
468 function! s:HgStatus_QNew(linestart, lineend, patchname, ...) abort | |
469 " Get the selected filenames. | |
470 let l:filenames = s:HgStatus_GetSelectedFiles(a:linestart, a:lineend, ['M', 'A', 'R']) | |
471 if len(l:filenames) == 0 | |
472 call s:error("No files in selection or file to create patch.") | |
473 endif | |
474 | |
475 " Run `Hg qnew` on those paths. | |
476 let l:repo = s:hg_repo() | |
477 call insert(l:filenames, a:patchname, 0) | |
478 if a:0 > 0 | |
479 call insert(l:filenames, '-m', 0) | |
480 let l:message = '"' . join(a:000, ' ') . '"' | |
481 call insert(l:filenames, l:message, 1) | |
482 endif | |
483 call l:repo.RunCommand('qnew', l:filenames) | |
484 endfunction | |
485 | |
486 function! s:HgStatus_QRefresh(linestart, lineend) abort | |
487 " Get the selected filenames. | |
488 let l:filenames = s:HgStatus_GetSelectedFiles(a:linestart, a:lineend, ['M', 'A', 'R']) | |
489 if len(l:filenames) == 0 | |
490 call s:error("No files in selection or file to refresh the patch.") | |
491 endif | |
492 | |
493 " Run `Hg qrefresh` on those paths. | |
494 let l:repo = s:hg_repo() | |
495 call insert(l:filenames, '-s', 0) | |
496 call l:repo.RunCommand('qrefresh', l:filenames) | |
497 endfunction | |
498 | |
465 | 499 |
466 function! s:HgStatus_GetSelectedFile() abort | 500 function! s:HgStatus_GetSelectedFile() abort |
467 let l:filenames = s:HgStatus_GetSelectedFiles() | 501 let l:filenames = s:HgStatus_GetSelectedFiles() |
468 return l:filenames[0] | 502 return l:filenames[0] |
469 endfunction | 503 endfunction |