Skip to content

Commit fd3d1e9

Browse files
Charles Campbellvim-scripts
authored andcommitted
Version 22
* The internally used "only" command was occasionally issuing an "Already one window" message, which is now prevented. * SavePosn() issued an error message when ZoomWin was handling - fixed! * Saves/restores yank registers for every zoom/unzoom.
1 parent 6768a63 commit fd3d1e9

1 file changed

Lines changed: 81 additions & 11 deletions

File tree

plugin/ZoomWin.vim

Lines changed: 81 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
" ZoomWin: Brief-like ability to zoom into/out-of a window
22
" Author: Charles Campbell
33
" original version by Ron Aaron
4-
" Date: May 10, 2005
5-
" Version: 21
4+
" Date: Apr 07, 2006
5+
" Version: 22
66
" History: see :help zoomwin-history {{{1
77
" GetLatestVimScripts: 508 1 :AutoInstall: ZoomWin.vim
88

@@ -12,8 +12,9 @@ if &cp || exists("g:loaded_ZoomWin")
1212
finish
1313
endif
1414
let s:keepcpo = &cpo
15-
let g:loaded_ZoomWin = "v21"
15+
let g:loaded_ZoomWin = "v22"
1616
set cpo&vim
17+
"DechoTabOn
1718

1819
" ---------------------------------------------------------------------
1920
" Public Interface: {{{1
@@ -72,6 +73,7 @@ fun! ZoomWin()
7273

7374
if winbufnr(2) == -1
7475
" there's only one window - restore to multiple-windows mode {{{2
76+
" call Decho("there's only one window - restore to multiple windows")
7577

7678
if exists("s:sessionfile") && filereadable(s:sessionfile)
7779
" save position in current one-window-only
@@ -84,6 +86,7 @@ fun! ZoomWin()
8486
let ei_keep= &ei
8587
set ei=all
8688
exe 'silent! so '.s:sessionfile
89+
" Decho("@@<".@@.">")
8790
let v:this_session= s:sesskeep
8891

8992
if exists("s:savedposn1")
@@ -110,6 +113,7 @@ fun! ZoomWin()
110113
endif
111114

112115
else " there's more than one window - go to only-one-window mode {{{2
116+
" call Decho("there's multiple windows - goto one-window-only")
113117

114118
let s:winkeep = winnr()
115119
let s:sesskeep = v:this_session
@@ -120,38 +124,76 @@ fun! ZoomWin()
120124
" call Dret("ZoomWin : commandline window error")
121125
return
122126
endif
127+
" call Decho("1: @@<".@@.">")
123128

124129
" disable all events (autocmds)
125130
" call Decho("disable events")
126131
let ei_keep= &ei
127132
set ei=all
133+
" call Decho("2: @@<".@@.">")
128134

129135
" save window positioning commands
130136
" call Decho("save window positioning commands")
131137
windo let s:savedposn{winnr()}= s:SavePosn(1)
132138
call s:GotoWinNum(s:winkeep)
133139

134140
" set up name of session file
141+
" call Decho("3: @@<".@@.">")
135142
let s:sessionfile= tempname()
143+
" call Decho("4: @@<".@@.">")
136144

137145
" save session
138146
" call Decho("save session")
139147
let ssop_keep = &ssop
140148
let &ssop = 'blank,help,winsize'
149+
" call Decho("5: @@<".@@.">")
141150
exe 'mksession! '.s:sessionfile
151+
" call Decho("6: @@<".@@.">")
152+
let keepyy= @@
153+
let keepy0= @0
154+
let keepy1= @1
155+
let keepy2= @2
156+
let keepy3= @3
157+
let keepy4= @4
158+
let keepy5= @5
159+
let keepy6= @6
160+
let keepy7= @7
161+
let keepy8= @8
162+
let keepy9= @9
142163
set lz ei=all bh=
164+
if v:version >= 700
165+
exe "keepalt keepmarks new! ".s:sessionfile
166+
keepjumps keepmarks v/wincmd\|split\|resize/d
167+
keepalt w!
168+
keepalt bw!
169+
else
143170
exe "new! ".s:sessionfile
144171
v/wincmd\|split\|resize/d
145172
w!
146-
bw!
173+
bw!
174+
endif
175+
let @@= keepyy
176+
let @0= keepy0
177+
let @1= keepy1
178+
let @2= keepy2
179+
let @3= keepy3
180+
let @4= keepy4
181+
let @5= keepy5
182+
let @6= keepy6
183+
let @7= keepy7
184+
let @8= keepy8
185+
let @9= keepy9
186+
" call Decho("7: @@<".@@.">")
147187

148188
" restore user's session options and restore event handling
149189
" call Decho("restore user session options and event handling")
150190
set nolz
151191
let &ssop = ssop_keep
152-
only!
192+
silent! only!
193+
" call Decho("8: @@<".@@.">")
153194
let &ei = ei_keep
154195
echomsg expand("%")
196+
" call Decho("9: @@<".@@.">")
155197
endif
156198

157199
" restore user option settings {{{2
@@ -178,6 +220,12 @@ endfun
178220
fun! s:SavePosn(savewinhoriz)
179221
" call Dfunc("SavePosn(savewinhoriz=".a:savewinhoriz.") file<".expand("%").">")
180222
let swline = line(".")
223+
if swline == 1 && getline(1) == ""
224+
" empty buffer
225+
let savedposn= "silent b ".winbufnr(0)
226+
" call Dret("SavePosn savedposn<".savedposn.">")
227+
return savedposn
228+
endif
181229
let swcol = col(".")
182230
let swwline = winline()-1
183231
let swwcol = virtcol(".") - wincol()
@@ -315,18 +363,30 @@ unlet s:keepcpo
315363
" HelpExtractor:
316364
" Author: Charles E. Campbell, Jr.
317365
" Version: 3
318-
" Date: Sep 09, 2004
366+
" Date: May 25, 2005
319367
"
320368
" History:
369+
" v3 May 25, 2005 : requires placement of code in plugin directory
370+
" cpo is standardized during extraction
321371
" v2 Nov 24, 2003 : On Linux/Unix, will make a document directory
322372
" if it doesn't exist yet
323373
"
324374
" GetLatestVimScripts: 748 1 HelpExtractor.vim
325375
" ---------------------------------------------------------------------
326376
set lz
327-
let s:keepcpo= &cpo
377+
let s:HelpExtractor_keepcpo= &cpo
328378
set cpo&vim
329-
let docdir = substitute(expand("<sfile>:r").".txt",'\<plugin[/\\].*$','doc','')
379+
let docdir = expand("<sfile>:r").".txt"
380+
if docdir =~ '\<plugin\>'
381+
let docdir = substitute(docdir,'\<plugin[/\\].*$','doc','')
382+
else
383+
if has("win32")
384+
echoerr expand("<sfile>:t").' should first be placed in your vimfiles\plugin directory'
385+
else
386+
echoerr expand("<sfile>:t").' should first be placed in your .vim/plugin directory'
387+
endif
388+
finish
389+
endif
330390
if !isdirectory(docdir)
331391
if has("win32")
332392
echoerr 'Please make '.docdir.' directory first'
@@ -358,17 +418,21 @@ set nolz
358418
unlet docdir
359419
unlet curfile
360420
"unlet docfile
361-
let &cpo= s:keepcpo
362-
unlet s:keepcpo
421+
let &cpo= s:HelpExtractor_keepcpo
422+
unlet s:HelpExtractor_keepcpo
363423
finish
364424

365425
" ---------------------------------------------------------------------
366426
" Put the help after the HelpExtractorDoc label...
367427
" HelpExtractorDoc:
368-
*ZoomWin.txt* Zoom into/out-of a window May 10, 2005
428+
*ZoomWin.txt* Zoom into/out-of a window Apr 10, 2006
369429
Authors: Charles E. Campbell, Jr. *zoomwin*
370430
Ron Aaron
371431
Version: 21
432+
Copyright: (c) 2004-2005 by Charles E. Campbell, Jr. *zoomwin-copyright*
433+
The VIM LICENSE applies to ZoomWin.vim and ZoomWin.txt
434+
(see |copyright|) except use "ZoomWin" instead of "Vim"
435+
No warranty, express or implied. Use At-Your-Own-Risk.
372436

373437
==============================================================================
374438
1. Usage *zoomwin-usage*
@@ -393,6 +457,12 @@ Version: 21
393457
==============================================================================
394458
3. History *zoomwin-history*
395459

460+
v22 Apr 10, 2006 : * "only" was occasionally issuing an "Already one
461+
window" message, which is now prevented
462+
* SavePosn() issued error message when handling an
463+
empty buffer
464+
* saves yank registers and restores them on each
465+
zoom/unzoom
396466
v21 Oct 12, 2004 : * v14 fixed a bug when wmw and/or wmv equal to 0;
397467
v21 will invoke the patch only if the version <= 603.
398468
For vim version 6.3 users, this fix allows more files

0 commit comments

Comments
 (0)