##// END OF EJS Templates
hgcommand.vim: requirements & doc self-install more consistent; cosmetics...
Christian Ebert -
r2759:19436fac default
parent child Browse files
Show More
This diff has been collapsed as it changes many lines, (580 lines changed) Show them Hide them
@@ -3,7 +3,7 b''
3 " Vim plugin to assist in working with HG-controlled files.
3 " Vim plugin to assist in working with HG-controlled files.
4 "
4 "
5 " Last Change: 2006/02/22
5 " Last Change: 2006/02/22
6 " Version: 1.76
6 " Version: 1.77
7 " Maintainer: Mathieu Clabaut <mathieu.clabaut@gmail.com>
7 " Maintainer: Mathieu Clabaut <mathieu.clabaut@gmail.com>
8 " License: This file is placed in the public domain.
8 " License: This file is placed in the public domain.
9 " Credits:
9 " Credits:
@@ -13,7 +13,7 b''
13
13
14 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
14 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
15 "
15 "
16 " Section: Documentation
16 " Section: Documentation
17 "----------------------------
17 "----------------------------
18 "
18 "
19 " Documentation should be available by ":help hgcommand" command, once the
19 " Documentation should be available by ":help hgcommand" command, once the
@@ -21,7 +21,7 b''
21 "
21 "
22 " You still can read the documentation at the end of this file. Locate it by
22 " You still can read the documentation at the end of this file. Locate it by
23 " searching the "hgcommand-contents" string (and set ft=help to have
23 " searching the "hgcommand-contents" string (and set ft=help to have
24 " appropriate syntaxic coloration).
24 " appropriate syntaxic coloration).
25
25
26 " Section: Plugin header {{{1
26 " Section: Plugin header {{{1
27
27
@@ -34,11 +34,33 b' if exists("loaded_hgcommand")'
34 endif
34 endif
35 let loaded_hgcommand = 1
35 let loaded_hgcommand = 1
36
36
37 " store 'compatible' settings
38 let s:save_cpo = &cpo
39 set cpo&vim
40
41 " run checks
42 let s:script_name = expand("<sfile>:t:r")
43
44 function! s:HGCleanupOnFailure(err)
45 echohl WarningMsg
46 echomsg s:script_name . ":" a:err "Plugin not loaded"
47 echohl None
48 let loaded_hgcommand = "no"
49 unlet s:save_cpo s:script_name
50 endfunction
51
37 if v:version < 602
52 if v:version < 602
38 echohl WarningMsg|echomsg "HGCommand 1.69 or later requires VIM 6.2 or later"|echohl None
53 call <SID>HGCleanupOnFailure("VIM 6.2 or later required.")
39 finish
54 finish
40 endif
55 endif
41
56
57 if !exists("*system")
58 call <SID>HGCleanupOnFailure("builtin system() function required.")
59 finish
60 endif
61
62 let s:script_version = "v0.2"
63
42 " Section: Event group setup {{{1
64 " Section: Event group setup {{{1
43
65
44 augroup HGCommand
66 augroup HGCommand
@@ -63,7 +85,7 b' unlet! s:vimDiffScratchList'
63 function! s:HGResolveLink(fileName)
85 function! s:HGResolveLink(fileName)
64 let resolved = resolve(a:fileName)
86 let resolved = resolve(a:fileName)
65 if resolved != a:fileName
87 if resolved != a:fileName
66 let resolved = s:HGResolveLink(resolved)
88 let resolved = <SID>HGResolveLink(resolved)
67 endif
89 endif
68 return resolved
90 return resolved
69 endfunction
91 endfunction
@@ -74,7 +96,7 b' endfunction'
74
96
75 function! s:HGChangeToCurrentFileDir(fileName)
97 function! s:HGChangeToCurrentFileDir(fileName)
76 let oldCwd=getcwd()
98 let oldCwd=getcwd()
77 let fileName=s:HGResolveLink(a:fileName)
99 let fileName=<SID>HGResolveLink(a:fileName)
78 let newCwd=fnamemodify(fileName, ':h')
100 let newCwd=fnamemodify(fileName, ':h')
79 if strlen(newCwd) > 0
101 if strlen(newCwd) > 0
80 execute 'cd' escape(newCwd, ' ')
102 execute 'cd' escape(newCwd, ' ')
@@ -82,7 +104,7 b' function! s:HGChangeToCurrentFileDir(fil'
82 return oldCwd
104 return oldCwd
83 endfunction
105 endfunction
84
106
85 " Function: s:HGGetOption(name, default) {{{2
107 " Function: <SID>HGGetOption(name, default) {{{2
86 " Grab a user-specified option to override the default provided. Options are
108 " Grab a user-specified option to override the default provided. Options are
87 " searched in the window, buffer, then global spaces.
109 " searched in the window, buffer, then global spaces.
88
110
@@ -110,9 +132,9 b' function! s:HGEditFile(name, origBuffNR)'
110 "Name parameter will be pasted into expression.
132 "Name parameter will be pasted into expression.
111 let name = escape(a:name, ' *?\')
133 let name = escape(a:name, ' *?\')
112
134
113 let editCommand = s:HGGetOption('HGCommandEdit', 'edit')
135 let editCommand = <SID>HGGetOption('HGCommandEdit', 'edit')
114 if editCommand != 'edit'
136 if editCommand != 'edit'
115 if s:HGGetOption('HGCommandSplit', 'horizontal') == 'horizontal'
137 if <SID>HGGetOption('HGCommandSplit', 'horizontal') == 'horizontal'
116 if name == ""
138 if name == ""
117 let editCommand = 'rightbelow new'
139 let editCommand = 'rightbelow new'
118 else
140 else
@@ -154,8 +176,8 b' function! s:HGCreateCommandBuffer(cmd, c'
154
176
155 let resultBufferName=''
177 let resultBufferName=''
156
178
157 if s:HGGetOption("HGCommandNameResultBuffers", 0)
179 if <SID>HGGetOption("HGCommandNameResultBuffers", 0)
158 let nameMarker = s:HGGetOption("HGCommandNameMarker", '_')
180 let nameMarker = <SID>HGGetOption("HGCommandNameMarker", '_')
159 if strlen(a:statusText) > 0
181 if strlen(a:statusText) > 0
160 let bufName=a:cmdName . ' -- ' . a:statusText
182 let bufName=a:cmdName . ' -- ' . a:statusText
161 else
183 else
@@ -170,7 +192,7 b' function! s:HGCreateCommandBuffer(cmd, c'
170 endwhile
192 endwhile
171 endif
193 endif
172
194
173 let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " " . a:cmd
195 let hgCommand = <SID>HGGetOption("HGCommandHGExec", "hg") . " " . a:cmd
174 "echomsg "DBG :".hgCommand
196 "echomsg "DBG :".hgCommand
175 let hgOut = system(hgCommand)
197 let hgOut = system(hgCommand)
176 " HACK: diff command does not return proper error codes
198 " HACK: diff command does not return proper error codes
@@ -192,7 +214,7 b' function! s:HGCreateCommandBuffer(cmd, c'
192 return -1
214 return -1
193 endif
215 endif
194
216
195 if s:HGEditFile(resultBufferName, a:origBuffNR) == -1
217 if <SID>HGEditFile(resultBufferName, a:origBuffNR) == -1
196 return -1
218 return -1
197 endif
219 endif
198
220
@@ -200,7 +222,7 b' function! s:HGCreateCommandBuffer(cmd, c'
200 set noswapfile
222 set noswapfile
201 set filetype=
223 set filetype=
202
224
203 if s:HGGetOption("HGCommandDeleteOnHide", 0)
225 if <SID>HGGetOption("HGCommandDeleteOnHide", 0)
204 set bufhidden=delete
226 set bufhidden=delete
205 endif
227 endif
206
228
@@ -213,8 +235,8 b' function! s:HGCreateCommandBuffer(cmd, c'
213 " This could be fixed by explicitly detecting whether the last line is
235 " This could be fixed by explicitly detecting whether the last line is
214 " within a fold, but I prefer to simply unfold the result buffer altogether.
236 " within a fold, but I prefer to simply unfold the result buffer altogether.
215
237
216 if has('folding')
238 if has("folding")
217 normal zR
239 setlocal nofoldenable
218 endif
240 endif
219
241
220 $d
242 $d
@@ -243,7 +265,7 b' function! s:HGBufferCheck(hgBuffer)'
243 return origBuffer
265 return origBuffer
244 else
266 else
245 " Original buffer no longer exists.
267 " Original buffer no longer exists.
246 return -1
268 return -1
247 endif
269 endif
248 else
270 else
249 " No original buffer
271 " No original buffer
@@ -256,7 +278,7 b' endfunction'
256 " for the current buffer.
278 " for the current buffer.
257
279
258 function! s:HGCurrentBufferCheck()
280 function! s:HGCurrentBufferCheck()
259 return s:HGBufferCheck(bufnr("%"))
281 return <SID>HGBufferCheck(bufnr("%"))
260 endfunction
282 endfunction
261
283
262 " Function: s:HGToggleDeleteOnHide() {{{2
284 " Function: s:HGToggleDeleteOnHide() {{{2
@@ -275,8 +297,8 b' endfunction'
275 " Returns: name of the new command buffer containing the command results
297 " Returns: name of the new command buffer containing the command results
276
298
277 function! s:HGDoCommand(cmd, cmdName, statusText)
299 function! s:HGDoCommand(cmd, cmdName, statusText)
278 let hgBufferCheck=s:HGCurrentBufferCheck()
300 let hgBufferCheck=<SID>HGCurrentBufferCheck()
279 if hgBufferCheck == -1
301 if hgBufferCheck == -1
280 echo "Original buffer no longer exists, aborting."
302 echo "Original buffer no longer exists, aborting."
281 return -1
303 return -1
282 endif
304 endif
@@ -285,8 +307,8 b' function! s:HGDoCommand(cmd, cmdName, st'
285 if isdirectory(fileName)
307 if isdirectory(fileName)
286 let fileName=fileName . "/" . getline(".")
308 let fileName=fileName . "/" . getline(".")
287 endif
309 endif
288 let realFileName = fnamemodify(s:HGResolveLink(fileName), ':t')
310 let realFileName = fnamemodify(<SID>HGResolveLink(fileName), ':t')
289 let oldCwd=s:HGChangeToCurrentFileDir(fileName)
311 let oldCwd=<SID>HGChangeToCurrentFileDir(fileName)
290 try
312 try
291 " TODO
313 " TODO
292 "if !filereadable('HG/Root')
314 "if !filereadable('HG/Root')
@@ -294,7 +316,7 b' function! s:HGDoCommand(cmd, cmdName, st'
294 "endif
316 "endif
295 let fullCmd = a:cmd . ' "' . realFileName . '"'
317 let fullCmd = a:cmd . ' "' . realFileName . '"'
296 "echomsg "DEBUG".fullCmd
318 "echomsg "DEBUG".fullCmd
297 let resultBuffer=s:HGCreateCommandBuffer(fullCmd, a:cmdName, a:statusText, hgBufferCheck)
319 let resultBuffer=<SID>HGCreateCommandBuffer(fullCmd, a:cmdName, a:statusText, hgBufferCheck)
298 return resultBuffer
320 return resultBuffer
299 catch
321 catch
300 echoerr v:exception
322 echoerr v:exception
@@ -314,17 +336,17 b' endfunction'
314 " Returns: string to be exec'd that sets the multiple return values.
336 " Returns: string to be exec'd that sets the multiple return values.
315
337
316 function! s:HGGetStatusVars(revisionVar, branchVar, repositoryVar)
338 function! s:HGGetStatusVars(revisionVar, branchVar, repositoryVar)
317 let hgBufferCheck=s:HGCurrentBufferCheck()
339 let hgBufferCheck=<SID>HGCurrentBufferCheck()
318 "echomsg "DBG : in HGGetStatusVars"
340 "echomsg "DBG : in HGGetStatusVars"
319 if hgBufferCheck == -1
341 if hgBufferCheck == -1
320 return ""
342 return ""
321 endif
343 endif
322 let fileName=bufname(hgBufferCheck)
344 let fileName=bufname(hgBufferCheck)
323 let fileNameWithoutLink=s:HGResolveLink(fileName)
345 let fileNameWithoutLink=<SID>HGResolveLink(fileName)
324 let realFileName = fnamemodify(fileNameWithoutLink, ':t')
346 let realFileName = fnamemodify(fileNameWithoutLink, ':t')
325 let oldCwd=s:HGChangeToCurrentFileDir(realFileName)
347 let oldCwd=<SID>HGChangeToCurrentFileDir(realFileName)
326 try
348 try
327 let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " root "
349 let hgCommand = <SID>HGGetOption("HGCommandHGExec", "hg") . " root "
328 let roottext=system(hgCommand)
350 let roottext=system(hgCommand)
329 " Suppress ending null char ! Does it work in window ?
351 " Suppress ending null char ! Does it work in window ?
330 let roottext=substitute(roottext,'^.*/\([^/\n\r]*\)\n\_.*$','\1','')
352 let roottext=substitute(roottext,'^.*/\([^/\n\r]*\)\n\_.*$','\1','')
@@ -335,22 +357,22 b' function! s:HGGetStatusVars(revisionVar,'
335 if a:repositoryVar != ""
357 if a:repositoryVar != ""
336 let returnExpression=returnExpression . " | let " . a:repositoryVar . "='" . roottext . "'"
358 let returnExpression=returnExpression . " | let " . a:repositoryVar . "='" . roottext . "'"
337 endif
359 endif
338 let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " status -mardui " . realFileName
360 let hgCommand = <SID>HGGetOption("HGCommandHGExec", "hg") . " status -mardui " . realFileName
339 let statustext=system(hgCommand)
361 let statustext=system(hgCommand)
340 if(v:shell_error)
362 if(v:shell_error)
341 return ""
363 return ""
342 endif
364 endif
343 if match(statustext, '^[?I]') >= 0
365 if match(statustext, '^[?I]') >= 0
344 let revision="NEW"
366 let revision="NEW"
345 elseif match(statustext, '^[R]') >= 0
367 elseif match(statustext, '^[R]') >= 0
346 let revision="REMOVED"
368 let revision="REMOVED"
347 elseif match(statustext, '^[D]') >= 0
369 elseif match(statustext, '^[D]') >= 0
348 let revision="DELETED"
370 let revision="DELETED"
349 elseif match(statustext, '^[A]') >= 0
371 elseif match(statustext, '^[A]') >= 0
350 let revision="ADDED"
372 let revision="ADDED"
351 else
373 else
352 " The file is tracked, we can try to get is revision number
374 " The file is tracked, we can try to get is revision number
353 let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " parents -b "
375 let hgCommand = <SID>HGGetOption("HGCommandHGExec", "hg") . " parents -b "
354 let statustext=system(hgCommand)
376 let statustext=system(hgCommand)
355 if(v:shell_error)
377 if(v:shell_error)
356 return ""
378 return ""
@@ -381,7 +403,7 b' function! s:HGSetupBuffer(...)'
381 return
403 return
382 endif
404 endif
383
405
384 if !s:HGGetOption("HGCommandEnableBufferSetup", 0)
406 if !<SID>HGGetOption("HGCommandEnableBufferSetup", 0)
385 \ || @% == ""
407 \ || @% == ""
386 \ || s:HGCommandEditFileRunning > 0
408 \ || s:HGCommandEditFileRunning > 0
387 \ || exists("b:HGOrigBuffNR")
409 \ || exists("b:HGOrigBuffNR")
@@ -399,7 +421,7 b' function! s:HGSetupBuffer(...)'
399 let branch=""
421 let branch=""
400 let repository=""
422 let repository=""
401
423
402 exec s:HGGetStatusVars('revision', 'branch', 'repository')
424 exec <SID>HGGetStatusVars('revision', 'branch', 'repository')
403 "echomsg "DBG ".revision."#".branch."#".repository
425 "echomsg "DBG ".revision."#".branch."#".repository
404 if revision != ""
426 if revision != ""
405 let b:HGRevision=revision
427 let b:HGRevision=revision
@@ -427,7 +449,7 b' endfunction'
427 function! s:HGMarkOrigBufferForSetup(hgBuffer)
449 function! s:HGMarkOrigBufferForSetup(hgBuffer)
428 checktime
450 checktime
429 if a:hgBuffer != -1
451 if a:hgBuffer != -1
430 let origBuffer = s:HGBufferCheck(a:hgBuffer)
452 let origBuffer = <SID>HGBufferCheck(a:hgBuffer)
431 "This should never not work, but I'm paranoid
453 "This should never not work, but I'm paranoid
432 if origBuffer != a:hgBuffer
454 if origBuffer != a:hgBuffer
433 call setbufvar(origBuffer, "HGBufferSetup", 0)
455 call setbufvar(origBuffer, "HGBufferSetup", 0)
@@ -436,7 +458,7 b' function! s:HGMarkOrigBufferForSetup(hgB'
436 "We are presumably in the original buffer
458 "We are presumably in the original buffer
437 let b:HGBufferSetup = 0
459 let b:HGBufferSetup = 0
438 "We do the setup now as now event will be triggered allowing it later.
460 "We do the setup now as now event will be triggered allowing it later.
439 call s:HGSetupBuffer()
461 call <SID>HGSetupBuffer()
440 endif
462 endif
441 return a:hgBuffer
463 return a:hgBuffer
442 endfunction
464 endfunction
@@ -483,11 +505,12 b' function! s:HGFlexiMkdir(dir)'
483 if exists("*mkdir") " we can use Vim's own mkdir()
505 if exists("*mkdir") " we can use Vim's own mkdir()
484 call mkdir(a:dir)
506 call mkdir(a:dir)
485 elseif !exists("+shellslash")
507 elseif !exists("+shellslash")
486 call system('mkdir -p "'.a:dir.'"')
508 call system("mkdir -p '".a:dir."'")
487 else " M$
509 else " M$
488 let l:ssl = &shellslash
510 let l:ssl = &shellslash
489 try
511 try
490 set shellslash
512 set shellslash
513 " no single quotes?
491 call system('mkdir "'.a:dir.'"')
514 call system('mkdir "'.a:dir.'"')
492 finally
515 finally
493 let &shellslash = l:ssl
516 let &shellslash = l:ssl
@@ -495,19 +518,18 b' function! s:HGFlexiMkdir(dir)'
495 endif
518 endif
496 endfunction
519 endfunction
497
520
498 function! s:HGInstallDocumentation(full_name, revision)
521 function! s:HGInstallDocumentation(full_name)
499 " Figure out document path based on full name of this script:
522 " Figure out document path based on full name of this script:
500 let l:vim_plugin_path = fnamemodify(a:full_name, ':h')
523 let l:vim_doc_path = fnamemodify(a:full_name, ":h:h") . "/doc"
501 let l:vim_doc_path = fnamemodify(a:full_name, ':h:h') . "/doc"
502 if filewritable(l:vim_doc_path) != 2
524 if filewritable(l:vim_doc_path) != 2
503 echomsg "hgcommand: Trying to update docs at: " . l:vim_doc_path
525 echomsg s:script_name . ": Trying to update docs at" l:vim_doc_path
504 silent! call <SID>HGFlexiMkdir(l:vim_doc_path)
526 silent! call <SID>HGFlexiMkdir(l:vim_doc_path)
505 if filewritable(l:vim_doc_path) != 2
527 if filewritable(l:vim_doc_path) != 2
506 " Try first item in 'runtimepath':
528 " Try first item in 'runtimepath':
507 let l:vimfiles = matchstr(&runtimepath, '[^,]\+\ze,')
529 let l:vim_doc_path =
508 let l:vim_doc_path = l:vimfiles . "/doc"
530 \ substitute(&runtimepath, '^\([^,]*\).*', '\1/doc', 'e')
509 if filewritable(l:vim_doc_path) != 2
531 if filewritable(l:vim_doc_path) != 2
510 echomsg "hgcommand: Trying to update docs at: " . l:vim_doc_path
532 echomsg s:script_name . ": Trying to update docs at" l:vim_doc_path
511 silent! call <SID>HGFlexiMkdir(l:vim_doc_path)
533 silent! call <SID>HGFlexiMkdir(l:vim_doc_path)
512 if filewritable(l:vim_doc_path) != 2
534 if filewritable(l:vim_doc_path) != 2
513 " Put a warning:
535 " Put a warning:
@@ -519,54 +541,51 b' function! s:HGInstallDocumentation(full_'
519 endif
541 endif
520 endif
542 endif
521
543
522 " Full name of script and documentation file:
544 " Full name of documentation file:
523 let l:script_name = fnamemodify(a:full_name, ':t')
545 let l:doc_file =
524 let l:doc_name = fnamemodify(a:full_name, ':t:r') . '.txt'
546 \ l:vim_doc_path . "/" . s:script_name . ".txt"
525 let l:doc_file = l:vim_doc_path . "/" . l:doc_name
526
527 " Bail out if document file is still up to date:
547 " Bail out if document file is still up to date:
528 if filereadable(l:doc_file) && getftime(a:full_name) < getftime(l:doc_file)
548 if filereadable(l:doc_file) &&
549 \ getftime(a:full_name) < getftime(l:doc_file)
529 return 0
550 return 0
530 endif
551 endif
531
552
553 " temporary global settings
554 let l:lz = &lazyredraw
555 let l:hls = &hlsearch
556 set lazyredraw nohlsearch
532 " Create a new buffer & read in the plugin file (me):
557 " Create a new buffer & read in the plugin file (me):
533 setl nomodeline
558 1 new
534 1 new!
559 setlocal noswapfile modifiable nomodeline
535 setl noswapfile modifiable
560 if has("folding")
536 sil exe 'read ' . a:full_name
561 setlocal nofoldenable
562 endif
563 silent execute "read" escape(a:full_name, " ")
564 let l:doc_buf = bufnr("%")
537
565
538 setl modeline
566 1
539 let l:buf = bufnr("%")
540
541 norm zR
542 norm gg
543
544 " Delete from first line to a line starts with
567 " Delete from first line to a line starts with
545 " === START_DOC
568 " === START_DOC
546 sil 1,/^=\{3,}\s\+START_DOC\C/ d
569 silent 1,/^=\{3,}\s\+START_DOC\C/ d
547
548 " Delete from a line starts with
570 " Delete from a line starts with
549 " === END_DOC
571 " === END_DOC
550 " to the end of the documents:
572 " to the end of the documents:
551 sil /^=\{3,}\s\+END_DOC\C/,$ d
573 silent /^=\{3,}\s\+END_DOC\C/,$ d
552
553 " Remove fold marks:
554 sil %s/{\{3}[1-9]/ /e
555
574
556 " Add modeline for help doc: the modeline string is mangled intentionally
575 " Add modeline for help doc: the modeline string is mangled intentionally
557 " to avoid it be recognized by VIM:
576 " to avoid it be recognized by VIM:
558 call append(line('$'), '')
577 call append(line("$"), "")
559 call append(line('$'), ' v' . 'im:tw=78:ts=8:ft=help:norl:')
578 call append(line("$"), " v" . "im:tw=78:ts=8:ft=help:norl:")
560
579
561 " Replace revision:
580 " Replace revision:
562 sil exe "normal :1s/#version#/ v" . a:revision . "/\<CR>"
581 silent execute "normal :1s/#version#/" . s:script_version . "/\<CR>"
563
564 " Save the help document and wipe out buffer:
582 " Save the help document and wipe out buffer:
565 sil exe 'wq! ' . l:doc_file . ' | bw ' . l:buf
583 silent execute "wq!" escape(l:doc_file, " ") "| bw" l:doc_buf
566
567 " Build help tags:
584 " Build help tags:
568 sil exe 'helptags ' . l:vim_doc_path
585 silent execute "helptags" l:vim_doc_path
569
586
587 let &hlsearch = l:hls
588 let &lazyredraw = l:lz
570 return 1
589 return 1
571 endfunction
590 endfunction
572
591
@@ -578,7 +597,7 b' endfunction'
578
597
579 function! HGGetRevision()
598 function! HGGetRevision()
580 let revision=""
599 let revision=""
581 exec s:HGGetStatusVars('revision', '', '')
600 exec <SID>HGGetStatusVars('revision', '', '')
582 return revision
601 return revision
583 endfunction
602 endfunction
584
603
@@ -597,16 +616,16 b' function! HGEnableBufferSetup()'
597 let g:HGCommandEnableBufferSetup=1
616 let g:HGCommandEnableBufferSetup=1
598 augroup HGCommandPlugin
617 augroup HGCommandPlugin
599 au!
618 au!
600 au BufEnter * call s:HGSetupBuffer()
619 au BufEnter * call <SID>HGSetupBuffer()
601 au BufWritePost * call s:HGSetupBuffer()
620 au BufWritePost * call <SID>HGSetupBuffer()
602 " Force resetting up buffer on external file change (HG update)
621 " Force resetting up buffer on external file change (HG update)
603 au FileChangedShell * call s:HGSetupBuffer(1)
622 au FileChangedShell * call <SID>HGSetupBuffer(1)
604 augroup END
623 augroup END
605
624
606 " Only auto-load if the plugin is fully loaded. This gives other plugins a
625 " Only auto-load if the plugin is fully loaded. This gives other plugins a
607 " chance to run.
626 " chance to run.
608 if g:loaded_hgcommand == 2
627 if g:loaded_hgcommand == 2
609 call s:HGSetupBuffer()
628 call <SID>HGSetupBuffer()
610 endif
629 endif
611 endfunction
630 endfunction
612
631
@@ -647,7 +666,7 b' endfunction'
647
666
648 " Function: s:HGAdd() {{{2
667 " Function: s:HGAdd() {{{2
649 function! s:HGAdd()
668 function! s:HGAdd()
650 return s:HGMarkOrigBufferForSetup(s:HGDoCommand('add', 'hgadd', ''))
669 return <SID>HGMarkOrigBufferForSetup(<SID>HGDoCommand('add', 'hgadd', ''))
651 endfunction
670 endfunction
652
671
653 " Function: s:HGAnnotate(...) {{{2
672 " Function: s:HGAnnotate(...) {{{2
@@ -657,7 +676,7 b' function! s:HGAnnotate(...)'
657 " This is a HGAnnotate buffer. Perform annotation of the version
676 " This is a HGAnnotate buffer. Perform annotation of the version
658 " indicated by the current line.
677 " indicated by the current line.
659 let revision = substitute(getline("."),'\(^[0-9]*\):.*','\1','')
678 let revision = substitute(getline("."),'\(^[0-9]*\):.*','\1','')
660 if s:HGGetOption('HGCommandAnnotateParent', 0) != 0 && revision > 0
679 if <SID>HGGetOption('HGCommandAnnotateParent', 0) != 0 && revision > 0
661 let revision = revision - 1
680 let revision = revision - 1
662 endif
681 endif
663 else
682 else
@@ -676,7 +695,7 b' function! s:HGAnnotate(...)'
676 return -1
695 return -1
677 endif
696 endif
678
697
679 let resultBuffer=s:HGDoCommand('annotate -ndu -r ' . revision, 'hgannotate', revision)
698 let resultBuffer=<SID>HGDoCommand('annotate -ndu -r ' . revision, 'hgannotate', revision)
680 "echomsg "DBG: ".resultBuffer
699 "echomsg "DBG: ".resultBuffer
681 if resultBuffer != -1
700 if resultBuffer != -1
682 set filetype=HGAnnotate
701 set filetype=HGAnnotate
@@ -691,10 +710,10 b' function! s:HGCommit(...)'
691 " is used; if bang is supplied, an empty message is used; otherwise, the
710 " is used; if bang is supplied, an empty message is used; otherwise, the
692 " user is provided a buffer from which to edit the commit message.
711 " user is provided a buffer from which to edit the commit message.
693 if a:2 != "" || a:1 == "!"
712 if a:2 != "" || a:1 == "!"
694 return s:HGMarkOrigBufferForSetup(s:HGDoCommand('commit -m "' . a:2 . '"', 'hgcommit', ''))
713 return <SID>HGMarkOrigBufferForSetup(<SID>HGDoCommand('commit -m "' . a:2 . '"', 'hgcommit', ''))
695 endif
714 endif
696
715
697 let hgBufferCheck=s:HGCurrentBufferCheck()
716 let hgBufferCheck=<SID>HGCurrentBufferCheck()
698 if hgBufferCheck == -1
717 if hgBufferCheck == -1
699 echo "Original buffer no longer exists, aborting."
718 echo "Original buffer no longer exists, aborting."
700 return -1
719 return -1
@@ -710,7 +729,7 b' function! s:HGCommit(...)'
710 let messageFileName = tempname()
729 let messageFileName = tempname()
711
730
712 let fileName=bufname(hgBufferCheck)
731 let fileName=bufname(hgBufferCheck)
713 let realFilePath=s:HGResolveLink(fileName)
732 let realFilePath=<SID>HGResolveLink(fileName)
714 let newCwd=fnamemodify(realFilePath, ':h')
733 let newCwd=fnamemodify(realFilePath, ':h')
715 if strlen(newCwd) == 0
734 if strlen(newCwd) == 0
716 " Account for autochdir being in effect, which will make this blank, but
735 " Account for autochdir being in effect, which will make this blank, but
@@ -720,7 +739,7 b' function! s:HGCommit(...)'
720
739
721 let realFileName=fnamemodify(realFilePath, ':t')
740 let realFileName=fnamemodify(realFilePath, ':t')
722
741
723 if s:HGEditFile(messageFileName, hgBufferCheck) == -1
742 if <SID>HGEditFile(messageFileName, hgBufferCheck) == -1
724 return
743 return
725 endif
744 endif
726
745
@@ -751,9 +770,9 b' function! s:HGCommit(...)'
751 silent put =\"HG: Enter Log. Lines beginning with `HG:' are removed automatically\"
770 silent put =\"HG: Enter Log. Lines beginning with `HG:' are removed automatically\"
752 silent put ='HG: Type <leader>cc (or your own <Plug>HGCommit mapping)'
771 silent put ='HG: Type <leader>cc (or your own <Plug>HGCommit mapping)'
753
772
754 if s:HGGetOption('HGCommandCommitOnWrite', 1) == 1
773 if <SID>HGGetOption('HGCommandCommitOnWrite', 1) == 1
755 execute 'au HGCommit BufWritePre' autoPattern 'g/^HG:/d'
774 execute 'au HGCommit BufWritePre' autoPattern 'g/^HG:/d'
756 execute 'au HGCommit BufWritePost' autoPattern 'call s:HGFinishCommit("' . messageFileName . '", "' . newCwd . '", "' . realFileName . '", ' . hgBufferCheck . ') | au! * ' autoPattern
775 execute 'au HGCommit BufWritePost' autoPattern 'call <SID>HGFinishCommit("' . messageFileName . '", "' . newCwd . '", "' . realFileName . '", ' . hgBufferCheck . ') | au! * ' autoPattern
757 silent put ='HG: or write this buffer'
776 silent put ='HG: or write this buffer'
758 endif
777 endif
759
778
@@ -782,7 +801,7 b' function! s:HGDiff(...)'
782 let caption = ''
801 let caption = ''
783 endif
802 endif
784
803
785 let hgdiffopt=s:HGGetOption('HGCommandDiffOpt', 'w')
804 let hgdiffopt=<SID>HGGetOption('HGCommandDiffOpt', 'w')
786
805
787 if hgdiffopt == ""
806 if hgdiffopt == ""
788 let diffoptionstring=""
807 let diffoptionstring=""
@@ -790,8 +809,8 b' function! s:HGDiff(...)'
790 let diffoptionstring=" -" . hgdiffopt . " "
809 let diffoptionstring=" -" . hgdiffopt . " "
791 endif
810 endif
792
811
793 let resultBuffer = s:HGDoCommand('diff ' . diffoptionstring . revOptions , 'hgdiff', caption)
812 let resultBuffer = <SID>HGDoCommand('diff ' . diffoptionstring . revOptions , 'hgdiff', caption)
794 if resultBuffer != -1
813 if resultBuffer != -1
795 set filetype=diff
814 set filetype=diff
796 endif
815 endif
797 return resultBuffer
816 return resultBuffer
@@ -800,7 +819,7 b' endfunction'
800
819
801 " Function: s:HGGotoOriginal(["!]) {{{2
820 " Function: s:HGGotoOriginal(["!]) {{{2
802 function! s:HGGotoOriginal(...)
821 function! s:HGGotoOriginal(...)
803 let origBuffNR = s:HGCurrentBufferCheck()
822 let origBuffNR = <SID>HGCurrentBufferCheck()
804 if origBuffNR > 0
823 if origBuffNR > 0
805 let origWinNR = bufwinnr(origBuffNR)
824 let origWinNR = bufwinnr(origBuffNR)
806 if origWinNR == -1
825 if origWinNR == -1
@@ -830,11 +849,11 b' function! s:HGFinishCommit(messageFile, '
830 if strlen(a:targetDir) > 0
849 if strlen(a:targetDir) > 0
831 execute 'cd' escape(a:targetDir, ' ')
850 execute 'cd' escape(a:targetDir, ' ')
832 endif
851 endif
833 let resultBuffer=s:HGCreateCommandBuffer('commit -l "' . a:messageFile . '" "'. a:targetFile . '"', 'hgcommit', '', a:origBuffNR)
852 let resultBuffer=<SID>HGCreateCommandBuffer('commit -l "' . a:messageFile . '" "'. a:targetFile . '"', 'hgcommit', '', a:origBuffNR)
834 execute 'cd' escape(oldCwd, ' ')
853 execute 'cd' escape(oldCwd, ' ')
835 execute 'bw' escape(a:messageFile, ' *?\')
854 execute 'bw' escape(a:messageFile, ' *?\')
836 silent execute 'call delete("' . a:messageFile . '")'
855 silent execute 'call delete("' . a:messageFile . '")'
837 return s:HGMarkOrigBufferForSetup(resultBuffer)
856 return <SID>HGMarkOrigBufferForSetup(resultBuffer)
838 else
857 else
839 echoerr "Can't read message file; no commit is possible."
858 echoerr "Can't read message file; no commit is possible."
840 return -1
859 return -1
@@ -851,7 +870,7 b' function! s:HGLog(...)'
851 let caption = a:1
870 let caption = a:1
852 endif
871 endif
853
872
854 let resultBuffer=s:HGDoCommand('log' . versionOption, 'hglog', caption)
873 let resultBuffer=<SID>HGDoCommand('log' . versionOption, 'hglog', caption)
855 if resultBuffer != ""
874 if resultBuffer != ""
856 set filetype=rcslog
875 set filetype=rcslog
857 endif
876 endif
@@ -860,14 +879,14 b' endfunction'
860
879
861 " Function: s:HGRevert() {{{2
880 " Function: s:HGRevert() {{{2
862 function! s:HGRevert()
881 function! s:HGRevert()
863 return s:HGMarkOrigBufferForSetup(s:HGDoCommand('revert', 'hgrevert', ''))
882 return <SID>HGMarkOrigBufferForSetup(<SID>HGDoCommand('revert', 'hgrevert', ''))
864 endfunction
883 endfunction
865
884
866 " Function: s:HGReview(...) {{{2
885 " Function: s:HGReview(...) {{{2
867 function! s:HGReview(...)
886 function! s:HGReview(...)
868 if a:0 == 0
887 if a:0 == 0
869 let versiontag=""
888 let versiontag=""
870 if s:HGGetOption('HGCommandInteractive', 0)
889 if <SID>HGGetOption('HGCommandInteractive', 0)
871 let versiontag=input('Revision: ')
890 let versiontag=input('Revision: ')
872 endif
891 endif
873 if versiontag == ""
892 if versiontag == ""
@@ -881,7 +900,7 b' function! s:HGReview(...)'
881 let versionOption=" -r " . versiontag . " "
900 let versionOption=" -r " . versiontag . " "
882 endif
901 endif
883
902
884 let resultBuffer = s:HGDoCommand('cat' . versionOption, 'hgreview', versiontag)
903 let resultBuffer = <SID>HGDoCommand('cat' . versionOption, 'hgreview', versiontag)
885 if resultBuffer > 0
904 if resultBuffer > 0
886 let &filetype=getbufvar(b:HGOrigBuffNR, '&filetype')
905 let &filetype=getbufvar(b:HGOrigBuffNR, '&filetype')
887 endif
906 endif
@@ -891,18 +910,18 b' endfunction'
891
910
892 " Function: s:HGStatus() {{{2
911 " Function: s:HGStatus() {{{2
893 function! s:HGStatus()
912 function! s:HGStatus()
894 return s:HGDoCommand('status', 'hgstatus', '')
913 return <SID>HGDoCommand('status', 'hgstatus', '')
895 endfunction
914 endfunction
896
915
897
916
898 " Function: s:HGUpdate() {{{2
917 " Function: s:HGUpdate() {{{2
899 function! s:HGUpdate()
918 function! s:HGUpdate()
900 return s:HGMarkOrigBufferForSetup(s:HGDoCommand('update', 'update', ''))
919 return <SID>HGMarkOrigBufferForSetup(<SID>HGDoCommand('update', 'update', ''))
901 endfunction
920 endfunction
902
921
903 " Function: s:HGVimDiff(...) {{{2
922 " Function: s:HGVimDiff(...) {{{2
904 function! s:HGVimDiff(...)
923 function! s:HGVimDiff(...)
905 let originalBuffer = s:HGCurrentBufferCheck()
924 let originalBuffer = <SID>HGCurrentBufferCheck()
906 let s:HGCommandEditFileRunning = s:HGCommandEditFileRunning + 1
925 let s:HGCommandEditFileRunning = s:HGCommandEditFileRunning + 1
907 try
926 try
908 " If there's already a VimDiff'ed window, restore it.
927 " If there's already a VimDiff'ed window, restore it.
@@ -910,16 +929,16 b' function! s:HGVimDiff(...)'
910
929
911 if exists("s:vimDiffSourceBuffer") && s:vimDiffSourceBuffer != originalBuffer
930 if exists("s:vimDiffSourceBuffer") && s:vimDiffSourceBuffer != originalBuffer
912 " Clear the existing vimdiff setup by removing the result buffers.
931 " Clear the existing vimdiff setup by removing the result buffers.
913 call s:HGWipeoutCommandBuffers(s:vimDiffSourceBuffer, 'vimdiff')
932 call <SID>HGWipeoutCommandBuffers(s:vimDiffSourceBuffer, 'vimdiff')
914 endif
933 endif
915
934
916 " Split and diff
935 " Split and diff
917 if(a:0 == 2)
936 if(a:0 == 2)
918 " Reset the vimdiff system, as 2 explicit versions were provided.
937 " Reset the vimdiff system, as 2 explicit versions were provided.
919 if exists('s:vimDiffSourceBuffer')
938 if exists('s:vimDiffSourceBuffer')
920 call s:HGWipeoutCommandBuffers(s:vimDiffSourceBuffer, 'vimdiff')
939 call <SID>HGWipeoutCommandBuffers(s:vimDiffSourceBuffer, 'vimdiff')
921 endif
940 endif
922 let resultBuffer = s:HGReview(a:1)
941 let resultBuffer = <SID>HGReview(a:1)
923 if resultBuffer < 0
942 if resultBuffer < 0
924 echomsg "Can't open HG revision " . a:1
943 echomsg "Can't open HG revision " . a:1
925 return resultBuffer
944 return resultBuffer
@@ -930,10 +949,10 b' function! s:HGVimDiff(...)'
930 let s:vimDiffScratchList = '{'. resultBuffer . '}'
949 let s:vimDiffScratchList = '{'. resultBuffer . '}'
931 " If no split method is defined, cheat, and set it to vertical.
950 " If no split method is defined, cheat, and set it to vertical.
932 try
951 try
933 call s:HGOverrideOption('HGCommandSplit', s:HGGetOption('HGCommandDiffSplit', s:HGGetOption('HGCommandSplit', 'vertical')))
952 call <SID>HGOverrideOption('HGCommandSplit', <SID>HGGetOption('HGCommandDiffSplit', <SID>HGGetOption('HGCommandSplit', 'vertical')))
934 let resultBuffer=s:HGReview(a:2)
953 let resultBuffer=<SID>HGReview(a:2)
935 finally
954 finally
936 call s:HGOverrideOption('HGCommandSplit')
955 call <SID>HGOverrideOption('HGCommandSplit')
937 endtry
956 endtry
938 if resultBuffer < 0
957 if resultBuffer < 0
939 echomsg "Can't open HG revision " . a:1
958 echomsg "Can't open HG revision " . a:1
@@ -947,16 +966,16 b' function! s:HGVimDiff(...)'
947 " Add new buffer
966 " Add new buffer
948 try
967 try
949 " Force splitting behavior, otherwise why use vimdiff?
968 " Force splitting behavior, otherwise why use vimdiff?
950 call s:HGOverrideOption("HGCommandEdit", "split")
969 call <SID>HGOverrideOption("HGCommandEdit", "split")
951 call s:HGOverrideOption("HGCommandSplit", s:HGGetOption('HGCommandDiffSplit', s:HGGetOption('HGCommandSplit', 'vertical')))
970 call <SID>HGOverrideOption("HGCommandSplit", <SID>HGGetOption('HGCommandDiffSplit', <SID>HGGetOption('HGCommandSplit', 'vertical')))
952 if(a:0 == 0)
971 if(a:0 == 0)
953 let resultBuffer=s:HGReview()
972 let resultBuffer=<SID>HGReview()
954 else
973 else
955 let resultBuffer=s:HGReview(a:1)
974 let resultBuffer=<SID>HGReview(a:1)
956 endif
975 endif
957 finally
976 finally
958 call s:HGOverrideOption("HGCommandEdit")
977 call <SID>HGOverrideOption("HGCommandEdit")
959 call s:HGOverrideOption("HGCommandSplit")
978 call <SID>HGOverrideOption("HGCommandSplit")
960 endtry
979 endtry
961 if resultBuffer < 0
980 if resultBuffer < 0
962 echomsg "Can't open current HG revision"
981 echomsg "Can't open current HG revision"
@@ -975,14 +994,14 b' function! s:HGVimDiff(...)'
975 wincmd W
994 wincmd W
976 execute 'buffer' originalBuffer
995 execute 'buffer' originalBuffer
977 " Store info for later original buffer restore
996 " Store info for later original buffer restore
978 let s:vimDiffRestoreCmd =
997 let s:vimDiffRestoreCmd =
979 \ "call setbufvar(".originalBuffer.", \"&diff\", ".getbufvar(originalBuffer, '&diff').")"
998 \ "call setbufvar(".originalBuffer.", \"&diff\", ".getbufvar(originalBuffer, '&diff').")"
980 \ . "|call setbufvar(".originalBuffer.", \"&foldcolumn\", ".getbufvar(originalBuffer, '&foldcolumn').")"
999 \ . "|call setbufvar(".originalBuffer.", \"&foldcolumn\", ".getbufvar(originalBuffer, '&foldcolumn').")"
981 \ . "|call setbufvar(".originalBuffer.", \"&foldenable\", ".getbufvar(originalBuffer, '&foldenable').")"
1000 \ . "|call setbufvar(".originalBuffer.", \"&foldenable\", ".getbufvar(originalBuffer, '&foldenable').")"
982 \ . "|call setbufvar(".originalBuffer.", \"&foldmethod\", '".getbufvar(originalBuffer, '&foldmethod')."')"
1001 \ . "|call setbufvar(".originalBuffer.", \"&foldmethod\", '".getbufvar(originalBuffer, '&foldmethod')."')"
983 \ . "|call setbufvar(".originalBuffer.", \"&scrollbind\", ".getbufvar(originalBuffer, '&scrollbind').")"
1002 \ . "|call setbufvar(".originalBuffer.", \"&scrollbind\", ".getbufvar(originalBuffer, '&scrollbind').")"
984 \ . "|call setbufvar(".originalBuffer.", \"&wrap\", ".getbufvar(originalBuffer, '&wrap').")"
1003 \ . "|call setbufvar(".originalBuffer.", \"&wrap\", ".getbufvar(originalBuffer, '&wrap').")"
985 \ . "|if &foldmethod=='manual'|execute 'normal zE'|endif"
1004 \ . "|if &foldmethod=='manual'|execute 'normal! zE'|endif"
986 diffthis
1005 diffthis
987 wincmd w
1006 wincmd w
988 else
1007 else
@@ -1012,17 +1031,17 b' endfunction'
1012
1031
1013 " Section: Command definitions {{{1
1032 " Section: Command definitions {{{1
1014 " Section: Primary commands {{{2
1033 " Section: Primary commands {{{2
1015 com! HGAdd call s:HGAdd()
1034 com! HGAdd call <SID>HGAdd()
1016 com! -nargs=? HGAnnotate call s:HGAnnotate(<f-args>)
1035 com! -nargs=? HGAnnotate call <SID>HGAnnotate(<f-args>)
1017 com! -bang -nargs=? HGCommit call s:HGCommit(<q-bang>, <q-args>)
1036 com! -bang -nargs=? HGCommit call <SID>HGCommit(<q-bang>, <q-args>)
1018 com! -nargs=* HGDiff call s:HGDiff(<f-args>)
1037 com! -nargs=* HGDiff call <SID>HGDiff(<f-args>)
1019 com! -bang HGGotoOriginal call s:HGGotoOriginal(<q-bang>)
1038 com! -bang HGGotoOriginal call <SID>HGGotoOriginal(<q-bang>)
1020 com! -nargs=? HGLog call s:HGLog(<f-args>)
1039 com! -nargs=? HGLog call <SID>HGLog(<f-args>)
1021 com! HGRevert call s:HGRevert()
1040 com! HGRevert call <SID>HGRevert()
1022 com! -nargs=? HGReview call s:HGReview(<f-args>)
1041 com! -nargs=? HGReview call <SID>HGReview(<f-args>)
1023 com! HGStatus call s:HGStatus()
1042 com! HGStatus call <SID>HGStatus()
1024 com! HGUpdate call s:HGUpdate()
1043 com! HGUpdate call <SID>HGUpdate()
1025 com! -nargs=* HGVimDiff call s:HGVimDiff(<f-args>)
1044 com! -nargs=* HGVimDiff call <SID>HGVimDiff(<f-args>)
1026
1045
1027 " Section: HG buffer management commands {{{2
1046 " Section: HG buffer management commands {{{2
1028 com! HGDisableBufferSetup call HGDisableBufferSetup()
1047 com! HGDisableBufferSetup call HGDisableBufferSetup()
@@ -1158,7 +1177,7 b' endfunction'
1158
1177
1159 augroup HGVimDiffRestore
1178 augroup HGVimDiffRestore
1160 au!
1179 au!
1161 au BufUnload * call s:HGVimDiffRestore(expand("<abuf>"))
1180 au BufUnload * call <SID>HGVimDiffRestore(expand("<abuf>"))
1162 augroup END
1181 augroup END
1163
1182
1164 " Section: Optional activation of buffer management {{{1
1183 " Section: Optional activation of buffer management {{{1
@@ -1168,23 +1187,24 b" if s:HGGetOption('HGCommandEnableBufferS"
1168 endif
1187 endif
1169
1188
1170 " Section: Doc installation {{{1
1189 " Section: Doc installation {{{1
1171 "
1172 let s:revision="0.1"
1173 if s:HGInstallDocumentation(escape(expand('<sfile>:p'), ' '), s:revision)
1174 echom expand('<sfile>:t:r') . ' v' . s:revision .
1175 \ ': Help-documentation installed.'
1176 endif
1177
1190
1178 " delete one-time vars and functions
1191 if <SID>HGInstallDocumentation(expand("<sfile>:p"))
1179 delfunction <SID>HGInstallDocumentation
1192 echomsg s:script_name s:script_version . ": updated documentation"
1180 delfunction <SID>HGFlexiMkdir
1193 endif
1181 unlet s:revision
1182
1183
1194
1184 " Section: Plugin completion {{{1
1195 " Section: Plugin completion {{{1
1185
1196
1197 " delete one-time vars and functions
1198 delfunction <SID>HGInstallDocumentation
1199 delfunction <SID>HGFlexiMkdir
1200 delfunction <SID>HGCleanupOnFailure
1201 unlet s:script_version s:script_name
1202
1186 let loaded_hgcommand=2
1203 let loaded_hgcommand=2
1187 silent do HGCommand User HGPluginFinish
1204 silent do HGCommand User HGPluginFinish
1205
1206 let &cpo = s:save_cpo
1207 unlet s:save_cpo
1188 " vim:se expandtab sts=2 sw=2:
1208 " vim:se expandtab sts=2 sw=2:
1189 finish
1209 finish
1190
1210
@@ -1216,16 +1236,16 b' 1. Contents\t\t\t\t\t\t *hgcommand-contents*'
1216 ==============================================================================
1236 ==============================================================================
1217 2. HGCommand Installation *hgcommand-install*
1237 2. HGCommand Installation *hgcommand-install*
1218
1238
1219 In order to install the plugin, place the hgcommand.vim file into a plugin'
1239 In order to install the plugin, place the hgcommand.vim file into a plugin'
1220 directory in your runtime path (please see |add-global-plugin| and
1240 directory in your runtime path (please see |add-global-plugin| and
1221 |'runtimepath'|.
1241 |'runtimepath'|.
1222
1242
1223 HGCommand may be customized by setting variables, creating maps, and
1243 HGCommand may be customized by setting variables, creating maps, and
1224 specifying event handlers. Please see |hgcommand-customize| for more
1244 specifying event handlers. Please see |hgcommand-customize| for more
1225 details.
1245 details.
1226
1246
1227 *hgcommand-auto-help*
1247 *hgcommand-auto-help*
1228 The help file is automagically generated when the |hgcommand| script is
1248 The help file is automagically generated when the |hgcommand| script is
1229 loaded for the first time.
1249 loaded for the first time.
1230
1250
1231 ==============================================================================
1251 ==============================================================================
@@ -1233,32 +1253,32 b' 2. HGCommand Installation\t\t\t\t *hgcomma'
1233 3. HGCommand Intro *hgcommand*
1253 3. HGCommand Intro *hgcommand*
1234 *hgcommand-intro*
1254 *hgcommand-intro*
1235
1255
1236 The HGCommand plugin provides global ex commands for manipulating
1256 The HGCommand plugin provides global ex commands for manipulating
1237 HG-controlled source files. In general, each command operates on the
1257 HG-controlled source files. In general, each command operates on the
1238 current buffer and accomplishes a separate hg function, such as update,
1258 current buffer and accomplishes a separate hg function, such as update,
1239 commit, log, and others (please see |hgcommand-commands| for a list of all
1259 commit, log, and others (please see |hgcommand-commands| for a list of all
1240 available commands). The results of each operation are displayed in a
1260 available commands). The results of each operation are displayed in a
1241 scratch buffer. Several buffer variables are defined for those scratch
1261 scratch buffer. Several buffer variables are defined for those scratch
1242 buffers (please see |hgcommand-buffer-variables|).
1262 buffers (please see |hgcommand-buffer-variables|).
1243
1263
1244 The notion of "current file" means either the current buffer, or, in the
1264 The notion of "current file" means either the current buffer, or, in the
1245 case of a directory buffer, the file on the current line within the buffer.
1265 case of a directory buffer, the file on the current line within the buffer.
1246
1266
1247 For convenience, any HGCommand invoked on a HGCommand scratch buffer acts
1267 For convenience, any HGCommand invoked on a HGCommand scratch buffer acts
1248 as though it was invoked on the original file and splits the screen so that
1268 as though it was invoked on the original file and splits the screen so that
1249 the output appears in a new window.
1269 the output appears in a new window.
1250
1270
1251 Many of the commands accept revisions as arguments. By default, most
1271 Many of the commands accept revisions as arguments. By default, most
1252 operate on the most recent revision on the current branch if no revision is
1272 operate on the most recent revision on the current branch if no revision is
1253 specified (though see |HGCommandInteractive| to prompt instead).
1273 specified (though see |HGCommandInteractive| to prompt instead).
1254
1274
1255 Each HGCommand is mapped to a key sequence starting with the <Leader>
1275 Each HGCommand is mapped to a key sequence starting with the <Leader>
1256 keystroke. The default mappings may be overridden by supplying different
1276 keystroke. The default mappings may be overridden by supplying different
1257 mappings before the plugin is loaded, such as in the vimrc, in the standard
1277 mappings before the plugin is loaded, such as in the vimrc, in the standard
1258 fashion for plugin mappings. For examples, please see
1278 fashion for plugin mappings. For examples, please see
1259 |hgcommand-mappings-override|.
1279 |hgcommand-mappings-override|.
1260
1280
1261 The HGCommand plugin may be configured in several ways. For more details,
1281 The HGCommand plugin may be configured in several ways. For more details,
1262 please see |hgcommand-customize|.
1282 please see |hgcommand-customize|.
1263
1283
1264 ==============================================================================
1284 ==============================================================================
@@ -1282,85 +1302,85 b' 4.1 HGCommand commands\t\t\t\t\t *hgcommand-'
1282
1302
1283 :HGAdd *:HGAdd*
1303 :HGAdd *:HGAdd*
1284
1304
1285 This command performs "hg add" on the current file. Please note, this does
1305 This command performs "hg add" on the current file. Please note, this does
1286 not commit the newly-added file.
1306 not commit the newly-added file.
1287
1307
1288 :HGAnnotate *:HGAnnotate*
1308 :HGAnnotate *:HGAnnotate*
1289
1309
1290 This command performs "hg annotate" on the current file. If an argument is
1310 This command performs "hg annotate" on the current file. If an argument is
1291 given, the argument is used as a revision number to display. If not given
1311 given, the argument is used as a revision number to display. If not given
1292 an argument, it uses the most recent version of the file on the current
1312 an argument, it uses the most recent version of the file on the current
1293 branch. Additionally, if the current buffer is a HGAnnotate buffer
1313 branch. Additionally, if the current buffer is a HGAnnotate buffer
1294 already, the version number on the current line is used.
1314 already, the version number on the current line is used.
1295
1315
1296 If the |HGCommandAnnotateParent| variable is set to a non-zero value, the
1316 If the |HGCommandAnnotateParent| variable is set to a non-zero value, the
1297 version previous to the one on the current line is used instead. This
1317 version previous to the one on the current line is used instead. This
1298 allows one to navigate back to examine the previous version of a line.
1318 allows one to navigate back to examine the previous version of a line.
1299
1319
1300 The filetype of the HGCommand scratch buffer is set to 'HGAnnotate', to
1320 The filetype of the HGCommand scratch buffer is set to 'HGAnnotate', to
1301 take advantage of the bundled syntax file.
1321 take advantage of the bundled syntax file.
1302
1322
1303
1323
1304 :HGCommit[!] *:HGCommit*
1324 :HGCommit[!] *:HGCommit*
1305
1325
1306 If called with arguments, this performs "hg commit" using the arguments as
1326 If called with arguments, this performs "hg commit" using the arguments as
1307 the log message.
1327 the log message.
1308
1328
1309 If '!' is used with no arguments, an empty log message is committed.
1329 If '!' is used with no arguments, an empty log message is committed.
1310
1330
1311 If called with no arguments, this is a two-step command. The first step
1331 If called with no arguments, this is a two-step command. The first step
1312 opens a buffer to accept a log message. When that buffer is written, it is
1332 opens a buffer to accept a log message. When that buffer is written, it is
1313 automatically closed and the file is committed using the information from
1333 automatically closed and the file is committed using the information from
1314 that log message. The commit can be abandoned if the log message buffer is
1334 that log message. The commit can be abandoned if the log message buffer is
1315 deleted or wiped before being written.
1335 deleted or wiped before being written.
1316
1336
1317 Alternatively, the mapping that is used to invoke :HGCommit (by default
1337 Alternatively, the mapping that is used to invoke :HGCommit (by default
1318 <Leader>hgc) can be used in the log message buffer to immediately commit.
1338 <Leader>hgc) can be used in the log message buffer to immediately commit.
1319 This is useful if the |HGCommandCommitOnWrite| variable is set to 0 to
1339 This is useful if the |HGCommandCommitOnWrite| variable is set to 0 to
1320 disable the normal commit-on-write behavior.
1340 disable the normal commit-on-write behavior.
1321
1341
1322 :HGDiff *:HGDiff*
1342 :HGDiff *:HGDiff*
1323
1343
1324 With no arguments, this performs "hg diff" on the current file against the
1344 With no arguments, this performs "hg diff" on the current file against the
1325 current repository version.
1345 current repository version.
1326
1346
1327 With one argument, "hg diff" is performed on the current file against the
1347 With one argument, "hg diff" is performed on the current file against the
1328 specified revision.
1348 specified revision.
1329
1349
1330 With two arguments, hg diff is performed between the specified revisions of
1350 With two arguments, hg diff is performed between the specified revisions of
1331 the current file.
1351 the current file.
1332
1352
1333 This command uses the 'HGCommandDiffOpt' variable to specify diff options.
1353 This command uses the 'HGCommandDiffOpt' variable to specify diff options.
1334 If that variable does not exist, then 'wbBc' is assumed. If you wish to
1354 If that variable does not exist, then 'wbBc' is assumed. If you wish to
1335 have no options, then set it to the empty string.
1355 have no options, then set it to the empty string.
1336
1356
1337
1357
1338 :HGGotoOriginal *:HGGotoOriginal*
1358 :HGGotoOriginal *:HGGotoOriginal*
1339
1359
1340 This command returns the current window to the source buffer, if the
1360 This command returns the current window to the source buffer, if the
1341 current buffer is a HG command output buffer.
1361 current buffer is a HG command output buffer.
1342
1362
1343 :HGGotoOriginal!
1363 :HGGotoOriginal!
1344
1364
1345 Like ":HGGotoOriginal" but also executes :bufwipeout on all HG command
1365 Like ":HGGotoOriginal" but also executes :bufwipeout on all HG command
1346 output buffers for the source buffer.
1366 output buffers for the source buffer.
1347
1367
1348 :HGLog *:HGLog*
1368 :HGLog *:HGLog*
1349
1369
1350 Performs "hg log" on the current file.
1370 Performs "hg log" on the current file.
1351
1371
1352 If an argument is given, it is passed as an argument to the "-r" option of
1372 If an argument is given, it is passed as an argument to the "-r" option of
1353 "hg log".
1373 "hg log".
1354
1374
1355 :HGRevert *:HGRevert*
1375 :HGRevert *:HGRevert*
1356
1376
1357 Replaces the current file with the most recent version from the repository
1377 Replaces the current file with the most recent version from the repository
1358 in order to wipe out any undesired changes.
1378 in order to wipe out any undesired changes.
1359
1379
1360 :HGReview *:HGReview*
1380 :HGReview *:HGReview*
1361
1381
1362 Retrieves a particular version of the current file. If no argument is
1382 Retrieves a particular version of the current file. If no argument is
1363 given, the most recent version of the file on the current branch is
1383 given, the most recent version of the file on the current branch is
1364 retrieved. Otherwise, the specified version is retrieved.
1384 retrieved. Otherwise, the specified version is retrieved.
1365
1385
1366 :HGStatus *:HGStatus*
1386 :HGStatus *:HGStatus*
@@ -1369,37 +1389,37 b' 4.1 HGCommand commands\t\t\t\t\t *hgcommand-'
1369
1389
1370 :HGUpdate *:HGUpdate*
1390 :HGUpdate *:HGUpdate*
1371
1391
1372 Performs "hg update" on the current file. This intentionally does not
1392 Performs "hg update" on the current file. This intentionally does not
1373 automatically reload the current buffer, though vim should prompt the user
1393 automatically reload the current buffer, though vim should prompt the user
1374 to do so if the underlying file is altered by this command.
1394 to do so if the underlying file is altered by this command.
1375
1395
1376 :HGVimDiff *:HGVimDiff*
1396 :HGVimDiff *:HGVimDiff*
1377
1397
1378 With no arguments, this prompts the user for a revision and then uses
1398 With no arguments, this prompts the user for a revision and then uses
1379 vimdiff to display the differences between the current file and the
1399 vimdiff to display the differences between the current file and the
1380 specified revision. If no revision is specified, the most recent version
1400 specified revision. If no revision is specified, the most recent version
1381 of the file on the current branch is used.
1401 of the file on the current branch is used.
1382
1402
1383 With one argument, that argument is used as the revision as above. With
1403 With one argument, that argument is used as the revision as above. With
1384 two arguments, the differences between the two revisions is displayed using
1404 two arguments, the differences between the two revisions is displayed using
1385 vimdiff.
1405 vimdiff.
1386
1406
1387 With either zero or one argument, the original buffer is used to perform
1407 With either zero or one argument, the original buffer is used to perform
1388 the vimdiff. When the other buffer is closed, the original buffer will be
1408 the vimdiff. When the other buffer is closed, the original buffer will be
1389 returned to normal mode.
1409 returned to normal mode.
1390
1410
1391 Once vimdiff mode is started using the above methods, additional vimdiff
1411 Once vimdiff mode is started using the above methods, additional vimdiff
1392 buffers may be added by passing a single version argument to the command.
1412 buffers may be added by passing a single version argument to the command.
1393 There may be up to 4 vimdiff buffers total.
1413 There may be up to 4 vimdiff buffers total.
1394
1414
1395 Using the 2-argument form of the command resets the vimdiff to only those 2
1415 Using the 2-argument form of the command resets the vimdiff to only those 2
1396 versions. Additionally, invoking the command on a different file will
1416 versions. Additionally, invoking the command on a different file will
1397 close the previous vimdiff buffers.
1417 close the previous vimdiff buffers.
1398
1418
1399
1419
1400 4.2 Mappings *hgcommand-mappings*
1420 4.2 Mappings *hgcommand-mappings*
1401
1421
1402 By default, a mapping is defined for each command. These mappings execute
1422 By default, a mapping is defined for each command. These mappings execute
1403 the default (no-argument) form of each command.
1423 the default (no-argument) form of each command.
1404
1424
1405 <Leader>hga HGAdd
1425 <Leader>hga HGAdd
@@ -1416,20 +1436,20 b' 4.2 Mappings\t\t\t\t\t\t *hgcommand-mappings*'
1416
1436
1417 *hgcommand-mappings-override*
1437 *hgcommand-mappings-override*
1418
1438
1419 The default mappings can be overriden by user-provided instead by mapping
1439 The default mappings can be overriden by user-provided instead by mapping
1420 to <Plug>CommandName. This is especially useful when these mappings
1440 to <Plug>CommandName. This is especially useful when these mappings
1421 collide with other existing mappings (vim will warn of this during plugin
1441 collide with other existing mappings (vim will warn of this during plugin
1422 initialization, but will not clobber the existing mappings).
1442 initialization, but will not clobber the existing mappings).
1423
1443
1424 For instance, to override the default mapping for :HGAdd to set it to
1444 For instance, to override the default mapping for :HGAdd to set it to
1425 '\add', add the following to the vimrc: >
1445 '\add', add the following to the vimrc: >
1426
1446
1427 nmap \add <Plug>HGAdd
1447 nmap \add <Plug>HGAdd
1428 <
1448 <
1429 4.3 Automatic buffer variables *hgcommand-buffer-variables*
1449 4.3 Automatic buffer variables *hgcommand-buffer-variables*
1430
1450
1431 Several buffer variables are defined in each HGCommand result buffer.
1451 Several buffer variables are defined in each HGCommand result buffer.
1432 These may be useful for additional customization in callbacks defined in
1452 These may be useful for additional customization in callbacks defined in
1433 the event handlers (please see |hgcommand-events|).
1453 the event handlers (please see |hgcommand-events|).
1434
1454
1435 The following variables are automatically defined:
1455 The following variables are automatically defined:
@@ -1440,24 +1460,24 b' b:hgOrigBuffNR\t\t\t\t\t\t *b:hgOrigBuffN'
1440
1460
1441 b:hgcmd *b:hgcmd*
1461 b:hgcmd *b:hgcmd*
1442
1462
1443 This variable is set to the name of the hg command that created the result
1463 This variable is set to the name of the hg command that created the result
1444 buffer.
1464 buffer.
1445 ==============================================================================
1465 ==============================================================================
1446
1466
1447 5. Configuration and customization *hgcommand-customize*
1467 5. Configuration and customization *hgcommand-customize*
1448 *hgcommand-config*
1468 *hgcommand-config*
1449
1469
1450 The HGCommand plugin can be configured in two ways: by setting
1470 The HGCommand plugin can be configured in two ways: by setting
1451 configuration variables (see |hgcommand-options|) or by defining HGCommand
1471 configuration variables (see |hgcommand-options|) or by defining HGCommand
1452 event handlers (see |hgcommand-events|). Additionally, the HGCommand
1472 event handlers (see |hgcommand-events|). Additionally, the HGCommand
1453 plugin provides several option for naming the HG result buffers (see
1473 plugin provides several option for naming the HG result buffers (see
1454 |hgcommand-naming|) and supported a customized status line (see
1474 |hgcommand-naming|) and supported a customized status line (see
1455 |hgcommand-statusline| and |hgcommand-buffer-management|).
1475 |hgcommand-statusline| and |hgcommand-buffer-management|).
1456
1476
1457 5.1 HGCommand configuration variables *hgcommand-options*
1477 5.1 HGCommand configuration variables *hgcommand-options*
1458
1478
1459 Several variables affect the plugin's behavior. These variables are
1479 Several variables affect the plugin's behavior. These variables are
1460 checked at time of execution, and may be defined at the window, buffer, or
1480 checked at time of execution, and may be defined at the window, buffer, or
1461 global level and are checked in that order of precedence.
1481 global level and are checked in that order of precedence.
1462
1482
1463
1483
@@ -1478,87 +1498,87 b' 5.1 HGCommand configuration variables\t\t\t'
1478
1498
1479 HGCommandAnnotateParent *HGCommandAnnotateParent*
1499 HGCommandAnnotateParent *HGCommandAnnotateParent*
1480
1500
1481 This variable, if set to a non-zero value, causes the zero-argument form of
1501 This variable, if set to a non-zero value, causes the zero-argument form of
1482 HGAnnotate when invoked on a HGAnnotate buffer to go to the version
1502 HGAnnotate when invoked on a HGAnnotate buffer to go to the version
1483 previous to that displayed on the current line. If not set, it defaults to
1503 previous to that displayed on the current line. If not set, it defaults to
1484 0.
1504 0.
1485
1505
1486 HGCommandCommitOnWrite *HGCommandCommitOnWrite*
1506 HGCommandCommitOnWrite *HGCommandCommitOnWrite*
1487
1507
1488 This variable, if set to a non-zero value, causes the pending hg commit to
1508 This variable, if set to a non-zero value, causes the pending hg commit to
1489 take place immediately as soon as the log message buffer is written. If
1509 take place immediately as soon as the log message buffer is written. If
1490 set to zero, only the HGCommit mapping will cause the pending commit to
1510 set to zero, only the HGCommit mapping will cause the pending commit to
1491 occur. If not set, it defaults to 1.
1511 occur. If not set, it defaults to 1.
1492
1512
1493 HGCommandHGExec *HGCommandHGExec*
1513 HGCommandHGExec *HGCommandHGExec*
1494
1514
1495 This variable controls the executable used for all HG commands. If not
1515 This variable controls the executable used for all HG commands. If not
1496 set, it defaults to "hg".
1516 set, it defaults to "hg".
1497
1517
1498 HGCommandDeleteOnHide *HGCommandDeleteOnHide*
1518 HGCommandDeleteOnHide *HGCommandDeleteOnHide*
1499
1519
1500 This variable, if set to a non-zero value, causes the temporary HG result
1520 This variable, if set to a non-zero value, causes the temporary HG result
1501 buffers to automatically delete themselves when hidden.
1521 buffers to automatically delete themselves when hidden.
1502
1522
1503 HGCommandDiffOpt *HGCommandDiffOpt*
1523 HGCommandDiffOpt *HGCommandDiffOpt*
1504
1524
1505 This variable, if set, determines the options passed to the diff command of
1525 This variable, if set, determines the options passed to the diff command of
1506 HG. If not set, it defaults to 'w'.
1526 HG. If not set, it defaults to 'w'.
1507
1527
1508 HGCommandDiffSplit *HGCommandDiffSplit*
1528 HGCommandDiffSplit *HGCommandDiffSplit*
1509
1529
1510 This variable overrides the |HGCommandSplit| variable, but only for buffers
1530 This variable overrides the |HGCommandSplit| variable, but only for buffers
1511 created with |:HGVimDiff|.
1531 created with |:HGVimDiff|.
1512
1532
1513 HGCommandEdit *HGCommandEdit*
1533 HGCommandEdit *HGCommandEdit*
1514
1534
1515 This variable controls whether the original buffer is replaced ('edit') or
1535 This variable controls whether the original buffer is replaced ('edit') or
1516 split ('split'). If not set, it defaults to 'edit'.
1536 split ('split'). If not set, it defaults to 'edit'.
1517
1537
1518 HGCommandEnableBufferSetup *HGCommandEnableBufferSetup*
1538 HGCommandEnableBufferSetup *HGCommandEnableBufferSetup*
1519
1539
1520 This variable, if set to a non-zero value, activates HG buffer management
1540 This variable, if set to a non-zero value, activates HG buffer management
1521 mode see (|hgcommand-buffer-management|). This mode means that three
1541 mode see (|hgcommand-buffer-management|). This mode means that three
1522 buffer variables, 'HGRepository', 'HGRevision' and 'HGBranch', are set if
1542 buffer variables, 'HGRepository', 'HGRevision' and 'HGBranch', are set if
1523 the file is HG-controlled. This is useful for displaying version
1543 the file is HG-controlled. This is useful for displaying version
1524 information in the status bar.
1544 information in the status bar.
1525
1545
1526 HGCommandInteractive *HGCommandInteractive*
1546 HGCommandInteractive *HGCommandInteractive*
1527
1547
1528 This variable, if set to a non-zero value, causes appropriate commands (for
1548 This variable, if set to a non-zero value, causes appropriate commands (for
1529 the moment, only |:HGReview|) to query the user for a revision to use
1549 the moment, only |:HGReview|) to query the user for a revision to use
1530 instead of the current revision if none is specified.
1550 instead of the current revision if none is specified.
1531
1551
1532 HGCommandNameMarker *HGCommandNameMarker*
1552 HGCommandNameMarker *HGCommandNameMarker*
1533
1553
1534 This variable, if set, configures the special attention-getting characters
1554 This variable, if set, configures the special attention-getting characters
1535 that appear on either side of the hg buffer type in the buffer name. This
1555 that appear on either side of the hg buffer type in the buffer name. This
1536 has no effect unless |HGCommandNameResultBuffers| is set to a true value.
1556 has no effect unless |HGCommandNameResultBuffers| is set to a true value.
1537 If not set, it defaults to '_'.
1557 If not set, it defaults to '_'.
1538
1558
1539 HGCommandNameResultBuffers *HGCommandNameResultBuffers*
1559 HGCommandNameResultBuffers *HGCommandNameResultBuffers*
1540
1560
1541 This variable, if set to a true value, causes the hg result buffers to be
1561 This variable, if set to a true value, causes the hg result buffers to be
1542 named in the old way ('<source file name> _<hg command>_'). If not set or
1562 named in the old way ('<source file name> _<hg command>_'). If not set or
1543 set to a false value, the result buffer is nameless.
1563 set to a false value, the result buffer is nameless.
1544
1564
1545 HGCommandSplit *HGCommandSplit*
1565 HGCommandSplit *HGCommandSplit*
1546
1566
1547 This variable controls the orientation of the various window splits that
1567 This variable controls the orientation of the various window splits that
1548 may occur (such as with HGVimDiff, when using a HG command on a HG command
1568 may occur (such as with HGVimDiff, when using a HG command on a HG command
1549 buffer, or when the |HGCommandEdit| variable is set to 'split'. If set to
1569 buffer, or when the |HGCommandEdit| variable is set to 'split'. If set to
1550 'horizontal', the resulting windows will be on stacked on top of one
1570 'horizontal', the resulting windows will be on stacked on top of one
1551 another. If set to 'vertical', the resulting windows will be side-by-side.
1571 another. If set to 'vertical', the resulting windows will be side-by-side.
1552 If not set, it defaults to 'horizontal' for all but HGVimDiff windows.
1572 If not set, it defaults to 'horizontal' for all but HGVimDiff windows.
1553
1573
1554 5.2 HGCommand events *hgcommand-events*
1574 5.2 HGCommand events *hgcommand-events*
1555
1575
1556 For additional customization, HGCommand can trigger user-defined events.
1576 For additional customization, HGCommand can trigger user-defined events.
1557 Event handlers are provided by defining User event autocommands (see
1577 Event handlers are provided by defining User event autocommands (see
1558 |autocommand|, |User|) in the HGCommand group with patterns matching the
1578 |autocommand|, |User|) in the HGCommand group with patterns matching the
1559 event name.
1579 event name.
1560
1580
1561 For instance, the following could be added to the vimrc to provide a 'q'
1581 For instance, the following could be added to the vimrc to provide a 'q'
1562 mapping to quit a HGCommand scratch buffer: >
1582 mapping to quit a HGCommand scratch buffer: >
1563
1583
1564 augroup HGCommand
1584 augroup HGCommand
@@ -1570,10 +1590,10 b' 5.2 HGCommand events\t\t\t\t *hgc'
1570 The following hooks are available:
1590 The following hooks are available:
1571
1591
1572 HGBufferCreated This event is fired just after a hg command result
1592 HGBufferCreated This event is fired just after a hg command result
1573 buffer is created and filled with the result of a hg
1593 buffer is created and filled with the result of a hg
1574 command. It is executed within the context of the HG
1594 command. It is executed within the context of the HG
1575 command buffer. The HGCommand buffer variables may be
1595 command buffer. The HGCommand buffer variables may be
1576 useful for handlers of this event (please see
1596 useful for handlers of this event (please see
1577 |hgcommand-buffer-variables|).
1597 |hgcommand-buffer-variables|).
1578
1598
1579 HGBufferSetup This event is fired just after HG buffer setup occurs,
1599 HGBufferSetup This event is fired just after HG buffer setup occurs,
@@ -1586,50 +1606,50 b' HGPluginFinish\t\tThis event is fired just'
1586 loads.
1606 loads.
1587
1607
1588 HGVimDiffFinish This event is fired just after the HGVimDiff command
1608 HGVimDiffFinish This event is fired just after the HGVimDiff command
1589 executes to allow customization of, for instance,
1609 executes to allow customization of, for instance,
1590 window placement and focus.
1610 window placement and focus.
1591
1611
1592 5.3 HGCommand buffer naming *hgcommand-naming*
1612 5.3 HGCommand buffer naming *hgcommand-naming*
1593
1613
1594 By default, the buffers containing the result of HG commands are nameless
1614 By default, the buffers containing the result of HG commands are nameless
1595 scratch buffers. It is intended that buffer variables of those buffers be
1615 scratch buffers. It is intended that buffer variables of those buffers be
1596 used to customize the statusline option so that the user may fully control
1616 used to customize the statusline option so that the user may fully control
1597 the display of result buffers.
1617 the display of result buffers.
1598
1618
1599 If the old-style naming is desired, please enable the
1619 If the old-style naming is desired, please enable the
1600 |HGCommandNameResultBuffers| variable. Then, each result buffer will
1620 |HGCommandNameResultBuffers| variable. Then, each result buffer will
1601 receive a unique name that includes the source file name, the HG command,
1621 receive a unique name that includes the source file name, the HG command,
1602 and any extra data (such as revision numbers) that were part of the
1622 and any extra data (such as revision numbers) that were part of the
1603 command.
1623 command.
1604
1624
1605 5.4 HGCommand status line support *hgcommand-statusline*
1625 5.4 HGCommand status line support *hgcommand-statusline*
1606
1626
1607 It is intended that the user will customize the |'statusline'| option to
1627 It is intended that the user will customize the |'statusline'| option to
1608 include HG result buffer attributes. A sample function that may be used in
1628 include HG result buffer attributes. A sample function that may be used in
1609 the |'statusline'| option is provided by the plugin, HGGetStatusLine(). In
1629 the |'statusline'| option is provided by the plugin, HGGetStatusLine(). In
1610 order to use that function in the status line, do something like the
1630 order to use that function in the status line, do something like the
1611 following: >
1631 following: >
1612
1632
1613 set statusline=%<%f\ %{HGGetStatusLine()}\ %h%m%r%=%l,%c%V\ %P
1633 set statusline=%<%f\ %{HGGetStatusLine()}\ %h%m%r%=%l,%c%V\ %P
1614 <
1634 <
1615 of which %{HGGetStatusLine()} is the relevant portion.
1635 of which %{HGGetStatusLine()} is the relevant portion.
1616
1636
1617 The sample HGGetStatusLine() function handles both HG result buffers and
1637 The sample HGGetStatusLine() function handles both HG result buffers and
1618 HG-managed files if HGCommand buffer management is enabled (please see
1638 HG-managed files if HGCommand buffer management is enabled (please see
1619 |hgcommand-buffer-management|).
1639 |hgcommand-buffer-management|).
1620
1640
1621 5.5 HGCommand buffer management *hgcommand-buffer-management*
1641 5.5 HGCommand buffer management *hgcommand-buffer-management*
1622
1642
1623 The HGCommand plugin can operate in buffer management mode, which means
1643 The HGCommand plugin can operate in buffer management mode, which means
1624 that it attempts to set two buffer variables ('HGRevision' and 'HGBranch')
1644 that it attempts to set two buffer variables ('HGRevision' and 'HGBranch')
1625 upon entry into a buffer. This is rather slow because it means that 'hg
1645 upon entry into a buffer. This is rather slow because it means that 'hg
1626 status' will be invoked at each entry into a buffer (during the |BufEnter|
1646 status' will be invoked at each entry into a buffer (during the |BufEnter|
1627 autocommand).
1647 autocommand).
1628
1648
1629 This mode is enabled by default. In order to disable it, set the
1649 This mode is enabled by default. In order to disable it, set the
1630 |HGCommandEnableBufferSetup| variable to a false (zero) value. Enabling
1650 |HGCommandEnableBufferSetup| variable to a false (zero) value. Enabling
1631 this mode simply provides the buffer variables mentioned above. The user
1651 this mode simply provides the buffer variables mentioned above. The user
1632 must explicitly include those in the |'statusline'| option if they are to
1652 must explicitly include those in the |'statusline'| option if they are to
1633 appear in the status line (but see |hgcommand-statusline| for a simple way
1653 appear in the status line (but see |hgcommand-statusline| for a simple way
1634 to do that).
1654 to do that).
1635
1655
@@ -1643,10 +1663,10 b' 9.1 Split window annotation, by Michael '
1643 \:set nowrap<CR>
1663 \:set nowrap<CR>
1644 <
1664 <
1645
1665
1646 This splits the buffer vertically, puts an annotation on the left (minus
1666 This splits the buffer vertically, puts an annotation on the left (minus
1647 the header) with the width set to 40. An editable/normal copy is placed on
1667 the header) with the width set to 40. An editable/normal copy is placed on
1648 the right. The two versions are scroll locked so they move as one. and
1668 the right. The two versions are scroll locked so they move as one. and
1649 wrapping is turned off so that the lines line up correctly. The advantages
1669 wrapping is turned off so that the lines line up correctly. The advantages
1650 are...
1670 are...
1651
1671
1652 1) You get a versioning on the right.
1672 1) You get a versioning on the right.
@@ -1659,9 +1679,9 b' 8. Known bugs\t\t\t\t\t\t *hgcommand-bugs'
1659
1679
1660 Please let me know if you run across any.
1680 Please let me know if you run across any.
1661
1681
1662 HGVimDiff, when using the original (real) source buffer as one of the diff
1682 HGVimDiff, when using the original (real) source buffer as one of the diff
1663 buffers, uses some hacks to try to restore the state of the original buffer
1683 buffers, uses some hacks to try to restore the state of the original buffer
1664 when the scratch buffer containing the other version is destroyed. There
1684 when the scratch buffer containing the other version is destroyed. There
1665 may still be bugs in here, depending on many configuration details.
1685 may still be bugs in here, depending on many configuration details.
1666
1686
1667 ==============================================================================
1687 ==============================================================================
@@ -1674,4 +1694,4 b' 9. TODO \t\t\t\t\t\t *hgcommand-todo*'
1674 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1694 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1675 " v im:tw=78:ts=8:ft=help:norl:
1695 " v im:tw=78:ts=8:ft=help:norl:
1676 " vim600: set foldmethod=marker tabstop=8 shiftwidth=2 softtabstop=2 smartindent smarttab :
1696 " vim600: set foldmethod=marker tabstop=8 shiftwidth=2 softtabstop=2 smartindent smarttab :
1677 "fileencoding=iso-8859-15
1697 "fileencoding=iso-8859-15
General Comments 0
You need to be logged in to leave comments. Login now