Permalink
Browse files

Better default names for Narrow windows fixes #28

  • Loading branch information...
1 parent 4a0b7e3 commit 34964cedbf96ba7d2f78b76f6d3e46e1adaccc50 @chrisbra committed Mar 7, 2014
Showing with 9 additions and 6 deletions.
  1. +7 −6 autoload/nrrwrgn.vim
  2. +2 −0 doc/NarrowRegion.txt
View
@@ -57,7 +57,7 @@ fun! <sid>Init() "{{{1
endif
let s:nrrw_rgn_lines[s:instn] = {}
" show some debugging messages
- let s:nrrw_winname='Narrow_Region'
+ let s:nrrw_winname='NrrwRgn'
" Customization
let s:nrrw_rgn_vert = (exists("g:nrrw_rgn_vert") ? g:nrrw_rgn_vert : 0)
@@ -72,7 +72,8 @@ endfun
fun! <sid>NrrwRgnWin(bang) "{{{1
let local_options = <sid>GetOptions(s:opts)
- let nrrw_winname = s:nrrw_winname. '_'. s:instn
+ let bufname = substitute(expand('%:t:r'), ' ', '_', 'g')[0:8]
+ let nrrw_winname = s:nrrw_winname. '_'. bufname . '_'. s:instn
let nrrw_win = bufwinnr('^'.nrrw_winname.'$')
if nrrw_win != -1
exe ":noa ". nrrw_win. 'wincmd w'
@@ -177,15 +178,15 @@ fun! <sid>WriteNrrwRgn(...) "{{{1
" Write the buffer back to the original buffer
setl nomod
exe ":WidenRegion"
- if bufname('') !~# 'Narrow_Region' && bufwinnr(s:nrrw_winname. '_'. s:instn) > 0
+ if bufname('') !~# 'NrrwRgn' && bufwinnr(s:nrrw_winname. '_'. s:instn) > 0
exe ':noa'. bufwinnr(s:nrrw_winname. '_'. s:instn). 'wincmd w'
endif
else
call <sid>StoreLastNrrwRgn(nrrw_instn)
" b:orig_buf might not exists (see issue #2)
let winnr = (exists("b:orig_buf") ? bufwinnr(b:orig_buf) : 0)
" Best guess
- if bufname('') =~# 'Narrow_Region' && winnr > 0
+ if bufname('') =~# 'NrrwRgn' && winnr > 0
exe ':noa'. winnr. 'wincmd w'
endif
if !exists("a:1")
@@ -228,7 +229,7 @@ fun! <sid>UpdateOrigWin() abort
if !get(g:, 'nrrw_rgn_update_orig_win', 0)
return
endif
- if bufname('') !~# 'Narrow_Region'
+ if bufname('') !~# 'NrrwRgn'
return
else
let instn = b:nrrw_instn
@@ -1136,7 +1137,7 @@ fun! nrrwrgn#UnifiedDiff() "{{{1
let save_winposview=winsaveview()
let orig_win = winnr()
" close previous opened Narrowed buffers
- silent! windo | if bufname('')=~'^Narrow_Region' &&
+ silent! windo | if bufname('')=~'^NrrwRgn' &&
\ &diff |diffoff|q!|endif
" minimize Window
" this is disabled, because this might be useful, to see everything
View
@@ -362,6 +362,8 @@ looking at my Amazon whishlist: http://www.amazon.de/wishlist/2BKAHE8J7Z6UW
use the g:nrrw_rgn_update_orig_win variable to enable
- error when narrowed window was moved to new tab and trying to quit
(https://github.com/chrisbra/NrrwRgn/2, reported by Mario Ricalde, thanks!)
+- better default names for the narrowed window
+ (https://github.com/chrisbra/Nrrwrgn/28, reported by Mario Ricalde, thanks!)
0.31: Feb 16, 2013 {{{1
- NRM threw some errors (reported by pydave in

0 comments on commit 34964ce

Please sign in to comment.