@@ -10,7 +10,7 @@ function! g:SphinxNotesSnippetEdit(id)
1010 let file = system (join ([s: snippet , ' get' , ' --file' , a: id , ' 2>/dev/null' ], ' ' ))
1111 let line = system (join ([s: snippet , ' get' , ' --line-start' , a: id , ' 2>/dev/null' ], ' ' ))
1212 if &modified
13- execute ' tabedit ' . file
13+ execute ' vsplit ' . file
1414 else
1515 execute ' edit ' . file
1616 endif
@@ -38,7 +38,27 @@ function! g:SphinxNotesSnippetListAndUrl()
3838 call g: SphinxNotesSnippetList (function (' s:CallUrl' ), ' ds' )
3939endfunction
4040
41+ function ! g: SphinxNotesSnippetInput (id, item)
42+ let content = system (join ([s: snippet , ' get' , ' --' . a: item , a: id , ' 2>/dev/null' ], ' ' ))
43+ let content = substitute (content, ' \n\+$' , ' ' , ' ' ) " skip trailing \n
44+ if a: item == ' docname'
45+ " Create doc reference.
46+ let content = ' :doc:`/' . content . ' `'
47+ endif
48+ execute ' normal! i' . content
49+ endfunction
50+
51+ function ! g: SphinxNotesSnippetListAndInputDocname ()
52+ function ! s: InputDocname (selection )
53+ call g: SphinxNotesSnippetInput (s: SplitID (a: selection ), ' docname' )
54+ endfunction
55+ call g: SphinxNotesSnippetList (function (' s:InputDocname' ), ' d' )
56+ endfunction
57+
4158nmap <C-k> e :call g:SphinxNotesSnippetListAndEdit()<CR>
4259nmap <C-k> u :call g:SphinxNotesSnippetListAndUrl()<CR>
60+ nmap <C-k> d :call g:SphinxNotesSnippetListAndInputDocname()<CR>
61+ " FIXME: can't return to insert mode even use a/startinsert!/C-o
62+ imap <C-k> d <C-o> :call g:SphinxNotesSnippetListAndInputDocname()<CR>
4363
4464" vim: set shiftwidth = 2 :
0 commit comments