Evgeny Podjachev avatar Evgeny Podjachev committed 7bbdf7c

Added command YATEStationary to look into several tags without reopen YATE buffer.

Comments (0)

Files changed (1)

 "
 "				to you Vundle config to install yate.
 "
-" Usage:		Command :YATE toggles visibility of search buffer.
+" Usage:		Command :YATE toggles visibility of search buffer wich will be closed after tag was selected.
+"				Command :YATEStationary toggles visibility of search buffer wich will not be closed after tag is selected, instead cursor remains in YATE buffer to allow select another tag.
 " 				Parameter g:YATE_window_height sets height of search buffer. Default = 15.
 " 				Parameter g:YATE_strip_long_paths enables(1)/disables(0) cutting of long file paths. Default = 1.
 " 				Parameter g:YATE_enable_real_time_search enables(1)/disables(0) as-you-type search. Default = 1.
 "
 " Version:		1.3.1
 "
-" ChangeLog:	1.3.2:
+" ChangeLog:	1.4.0:	Added command YATEStationary to look into several tags
+"						without reopen YATE buffer.
+" 						Fixed conflict if already there is mapping on Q.
+"
 " 				1.3.1:	Disabled work of AutoComplPop plugin in YATE buffer.
 "
 " 				1.3.0:	Added parameter g:YATE_clear_search_string to control
 	let s:yate_history = []
 endif
 
-command! -bang YATE :call <SID>ToggleTagExplorerBuffer()
+command! -bang YATE :call <SID>ToggleTagExplorerBuffer(0)
+command! -bang YATEStationary :call <SID>ToggleTagExplorerBuffer(1)
 
-fun <SID>GotoTag(open_command)
+fun <SID>GotoTag(open_command, stationary)
 	let str=getline('.')
 
 	if !exists("s:tags_list") || !len(s:tags_list)
 	endif
 
 	let index=str2nr(str)
-	
+
+	let pos_in_yate = getpos(".") " save cursor position may halp later
 	exe ':wincmd p'
-	exe ':'.s:yate_winnr.'bd!'
-	let s:yate_winnr=-1
+	if !a:stationary
+		exe ':'.s:yate_winnr.'bd!'
+		let s:yate_winnr=-1
+	endif
 
 	exe ':silent '.a:open_command.' '.s:tags_list[index]['filename']
 	let str=substitute(s:tags_list[index]['cmd'],"\*","\\\\*","g")
 	" Without it you should press Enter to suppress error mesage if there are
 	" no matches of corresponding regexp.
 	exe ':redraw'
+
+	if a:stationary
+		" return to yate
+		exe ':wincmd p'
+		call setpos('.', pos_in_yate)
+	endif
 endfun
 
 fun <SID>AutoCompleteString(str)
 	endif
 endfun
 
-fun <SID>GotoTagE()
-	cal <SID>GotoTag('e')
+fun <SID>GotoTagE(stationary)
+	cal <SID>GotoTag('e', a:stationary)
 endfun
 
 fun <SID>OnBufLeave()
 	call <SID>PrintTagsList()
 endfun
 
-fun! <SID>ToggleTagExplorerBuffer()
+fun! <SID>ToggleTagExplorerBuffer(stationary)
 	if !exists("s:yate_winnr") || s:yate_winnr==-1
-		exe "bo".g:YATE_window_height."sp YATE"
+		let buffer_name = 'YATE'
+		if a:stationary
+			let buffer_name = 'YATE (stationary)'
+		endif
+
+		exe "bo".g:YATE_window_height."sp ".buffer_name
 
 		exe "inoremap <silent> <buffer> <Tab> <C-O>:cal <SID>GenerateTagsListCB()<CR>"
 
-		exe "inoremap <expr> <buffer> <Enter> pumvisible() ? '<CR><C-O>:cal <SID>GotoTagE()<CR>' : '<C-O>:cal <SID>GotoTagE()<CR>'"
-		exe "noremap <silent> <buffer> <Enter> :cal <SID>GotoTag('e')<CR>"
+		exe printf("inoremap <expr> <buffer> <Enter> pumvisible() ? '<CR><C-O>:cal <SID>GotoTagE(%d)<CR>' : '<C-O>:cal <SID>GotoTagE(%d)<CR>'", a:stationary, a:stationary)
+		exe printf("noremap <silent> <buffer> <Enter> :cal <SID>GotoTag('e', %d)<CR>", a:stationary)
+
+"		exe printf("noremap <silent> <buffer> p :cal <SID>GotoTag('ped', %d)<CR>", a:stationary)
 
-		exe "noremap <silent> <buffer> <2-leftmouse> :cal <SID>GotoTag('e')<CR>"
-		exe "inoremap <silent> <buffer> <2-leftmouse> <C-O>:cal <SID>GotoTag('e')<CR>"
+		exe printf("noremap <silent> <buffer> <2-leftmouse> :cal <SID>GotoTag('e', %d)<CR>", a:stationary)
+		exe printf("inoremap <silent> <buffer> <2-leftmouse> <C-O>:cal <SID>GotoTag('e', %d)<CR>", a:stationary)
 
-		exe "inoremap <silent> <buffer> <C-Enter> <C-O>:cal <SID>GotoTag('tabnew')<CR>"
-		exe "noremap <silent> <buffer> <C-Enter> :cal <SID>GotoTag('tabnew')<CR>"
+		exe printf("inoremap <silent> <buffer> <C-Enter> <C-O>:cal <SID>GotoTag('tabnew', %d)<CR>", a:stationary)
+		exe printf("noremap <silent> <buffer> <C-Enter> :cal <SID>GotoTag('tabnew', %d)<CR>", a:stationary)
 
-		exe "inoremap <silent> <buffer> <S-Enter> <C-O>:cal <SID>GotoTag('sp')<CR>"
-		exe "noremap <silent> <buffer> <S-Enter> :cal <SID>GotoTag('sp')<CR>"
+		exe printf("inoremap <silent> <buffer> <S-Enter> <C-O>:cal <SID>GotoTag('sp', %d)<CR>", a:stationary)
+		exe printf("noremap <silent> <buffer> <S-Enter> :cal <SID>GotoTag('sp', %d)<CR>", a:stationary)
 
-		exe "inoremap <silent> <buffer> <C-S-Enter> <C-O>:cal <SID>GotoTag('vs')<CR>"
-		exe "noremap <silent> <buffer> <C-S-Enter> :cal <SID>GotoTag('vs')<CR>"
+		exe printf("inoremap <silent> <buffer> <C-S-Enter> <C-O>:cal <SID>GotoTag('vs', %d)<CR>", a:stationary)
+		exe printf("noremap <silent> <buffer> <C-S-Enter> :cal <SID>GotoTag('vs', %d)<CR>", a:stationary)
 		
 		exe "inoremap <silent> <buffer> <C-H> <C-R>=<SID>ShowHistory()<CR>"
 		exe "noremap <silent> <buffer> <C-H> I<C-R>=<SID>ShowHistory()<CR>"
 		hi def link YATE_tag_kind Type
 		hi def link YATE_tag_filename Directory
 			
-		let s:yate_winnr=bufnr("YATE")
+		let s:yate_winnr=bufnr(buffer_name)
 		
 		setlocal buftype=nofile
 		setlocal noswapfile
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.