mirror of
https://github.com/neovim/neovim.git
synced 2024-12-31 17:13:26 -07:00
man.vim: remove push_tag and simplify man#open_page
This commit is contained in:
parent
0173bdf98b
commit
c6afad78d3
@ -64,34 +64,22 @@ function! man#open_page(count, count1, mods, ...) abort
|
|||||||
return
|
return
|
||||||
endtry
|
endtry
|
||||||
|
|
||||||
let fullname = name.(empty(sect)?'':'('.sect.')')
|
let [l:buf, l:save_tfu] = [bufnr(), &tagfunc]
|
||||||
call s:push_tag(fullname)
|
|
||||||
let bufname = 'man://'.fullname
|
|
||||||
|
|
||||||
try
|
try
|
||||||
set eventignore+=BufReadCmd
|
set eventignore+=BufReadCmd
|
||||||
|
set tagfunc=man#goto_tag
|
||||||
|
let l:target = l:name . '(' . l:sect . ')'
|
||||||
if a:mods !~# 'tab' && s:find_man()
|
if a:mods !~# 'tab' && s:find_man()
|
||||||
execute 'silent keepalt edit' fnameescape(bufname)
|
execute 'silent keepalt tag' l:target
|
||||||
else
|
else
|
||||||
execute 'silent keepalt' a:mods 'split' fnameescape(bufname)
|
execute 'silent keepalt' a:mods 'stag' l:target
|
||||||
endif
|
endif
|
||||||
finally
|
finally
|
||||||
|
call setbufvar(l:buf, '&tagfunc', l:save_tfu)
|
||||||
set eventignore-=BufReadCmd
|
set eventignore-=BufReadCmd
|
||||||
endtry
|
endtry
|
||||||
|
|
||||||
try
|
|
||||||
let page = s:get_page(path)
|
|
||||||
catch
|
|
||||||
if a:mods =~# 'tab' || !s:find_man()
|
|
||||||
" a new window was opened
|
|
||||||
close
|
|
||||||
endif
|
|
||||||
call s:error(v:exception)
|
|
||||||
return
|
|
||||||
endtry
|
|
||||||
|
|
||||||
let b:man_sect = sect
|
let b:man_sect = sect
|
||||||
call s:put_page(page)
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! man#read_page(ref) abort
|
function! man#read_page(ref) abort
|
||||||
@ -255,32 +243,6 @@ function! s:verify_exists(sect, name) abort
|
|||||||
return s:extract_sect_and_name_path(path) + [path]
|
return s:extract_sect_and_name_path(path) + [path]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:push_tag(name) abort
|
|
||||||
" emulate vim's tag pushing for cases where we don't use 'tagfunc'
|
|
||||||
if !&tagstack
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
let winnr = winnr()
|
|
||||||
let stack = gettagstack(winnr)
|
|
||||||
|
|
||||||
let curidx = stack.curidx
|
|
||||||
let items = stack.items
|
|
||||||
|
|
||||||
let newstack = items[0 : curidx - 1]
|
|
||||||
let newstack += [{
|
|
||||||
\ 'bufnr': bufnr('%'),
|
|
||||||
\ 'from': getpos('.'),
|
|
||||||
\ 'matchnr': 0,
|
|
||||||
\ 'tagname': a:name,
|
|
||||||
\ }]
|
|
||||||
|
|
||||||
call settagstack(winnr, {
|
|
||||||
\ 'length': len(newstack),
|
|
||||||
\ 'items': newstack,
|
|
||||||
\ })
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" extracts the name and sect out of 'path/name.sect'
|
" extracts the name and sect out of 'path/name.sect'
|
||||||
function! s:extract_sect_and_name_path(path) abort
|
function! s:extract_sect_and_name_path(path) abort
|
||||||
let tail = fnamemodify(a:path, ':t')
|
let tail = fnamemodify(a:path, ':t')
|
||||||
|
Loading…
Reference in New Issue
Block a user