man.vim: Avoid hard redraw.

Use system() instead of :read to avoid a hard redraw.
This commit is contained in:
Justin M. Keyes 2016-09-03 13:56:47 -04:00
parent f8fc8f51c0
commit c9e39f8227

View File

@ -51,9 +51,9 @@ function! man#open_page(count, count1, mods, ...) abort
call s:push_tag() call s:push_tag()
let bufname = 'man://'.name.(empty(sect)?'':'('.sect.')') let bufname = 'man://'.name.(empty(sect)?'':'('.sect.')')
if a:mods !~# 'tab' && s:find_man() if a:mods !~# 'tab' && s:find_man()
noautocmd execute 'edit' bufname noautocmd execute 'silent edit' bufname
else else
noautocmd execute a:mods 'split' bufname noautocmd execute 'silent' a:mods 'split' bufname
endif endif
let b:man_sect = sect let b:man_sect = sect
call s:read_page(path) call s:read_page(path)
@ -73,22 +73,15 @@ endfunction
function! s:read_page(path) abort function! s:read_page(path) abort
setlocal modifiable setlocal modifiable
setlocal noreadonly setlocal noreadonly
keepjumps %delete _ silent keepjumps %delete _
" Ensure Vim is not recursively invoked (man-db does this) " Force MANPAGER=cat to ensure Vim is not recursively invoked (by man-db).
" by forcing man to use cat as the pager. " http://comments.gmane.org/gmane.editors.vim.devel/29085
" More info here http://comments.gmane.org/gmane.editors.vim.devel/29085 " Respect $MANWIDTH, or default to window width.
let cmd = 'read !env MANPAGER=cat' let cmd = 'env MANPAGER=cat'.(empty($MANWIDTH) ? ' MANWIDTH='.winwidth(0) : '')
if empty($MANWIDTH) let cmd .= ' '.s:man_cmd.' '.shellescape(a:path)
" Do not set $MANWIDTH globally. silent put =system(cmd)
silent execute cmd 'MANWIDTH='.winwidth(0) s:man_cmd shellescape(a:path)
else
" Respect $MANWIDTH even if it is wider/smaller than the current window,
" because the current window might only be temporarily wide/narrow. Since we
" don't reflow, we assume the user set $MANWIDTH intentionally.
silent execute cmd s:man_cmd shellescape(a:path)
endif
" remove all the backspaced text " remove all the backspaced text
silent execute 'keeppatterns keepjumps %substitute,.\b,,e'.(&gdefault?'':'g') execute 'silent keeppatterns keepjumps %substitute,.\b,,e'.(&gdefault?'':'g')
while getline(1) =~# '^\s*$' while getline(1) =~# '^\s*$'
silent keepjumps 1delete _ silent keepjumps 1delete _
endwhile endwhile