From ca9bf8f792061929a7ef9f0a61022bf1b79539f0 Mon Sep 17 00:00:00 2001 From: Iain Patterson Date: Tue, 7 Jul 2009 14:32:36 +0100 Subject: [PATCH] Vim 5 compatibility Vim 5 doesn't recognise the prefix for functions or the += syntax for variable assignment. It also doesn't recognise variables in the global scope without an explicit g: prefix. Rewrite Startup_Resize() and Resize_Columns() with the above in mind. --- .vimrc | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/.vimrc b/.vimrc index c3eee65..9f8f25a 100644 --- a/.vimrc +++ b/.vimrc @@ -109,8 +109,8 @@ autocmd! augroup END " Save the current window width so we can restore it when we quit. -if ! exists("oldcols") - let oldcols=&columns +if ! exists("g:oldcols") + let g:oldcols=&columns endif " More GUI options. Add icon, tearoffs and toolbar. @@ -254,7 +254,8 @@ fun! Resize_Columns(op, ...) let l:columns = a:1 endif - let l:resize = "se columns" . a:op . "=" . l:columns + exe "let l:resize=" . &columns . a:op . l:columns + let l:resize = "se columns=" . l:resize " HACK: Inside screen there is an extra line for the status bar. Vim " manages the resize by sending an escape sequence to set the number of @@ -264,10 +265,10 @@ fun! Resize_Columns(op, ...) " the real terminal being shrunk by a line. We ask for the terminal to grow " by a line so it ends up actually being the same. if &term =~ '^screen' - let l:resize .= " lines+=1" + let l:resize = l:resize . " lines=" . (&lines + 1) endif - exec l:resize + exe l:resize endfun " Toggle number display. @@ -300,7 +301,7 @@ fun! Number(resize) endfun " Restore window size. -au Display VimLeave * if exists("oldcols") | call Resize_Columns("-", (&columns - oldcols)) | endif +au Display VimLeave * if exists("g:oldcols") | call Resize_Columns("-", (&columns - g:oldcols)) | endif " Map Makefile mode. au Mode BufEnter * if &ft == "make" | call MakeMode_map() | endif @@ -366,29 +367,37 @@ map Q " Vim tip 99: What's the highlighting group under the cursor? call Mapping("h", ":echo \"hi<\" . synIDattr(synID(line(\".\"),col(\".\"),1),\"name\") . '> trans<' . synIDattr(synID(line(\".\"),col(\".\"),0),\"name\") . \"> lo<\" . synIDattr(synIDtrans(synID(line(\".\"),col(\".\"),1)),\"name\") . \">\"") -fun! Startup_Resize() +fun! Startup_Resize() + let l:columns = 0 + " Resize for numbers. - if version >= "700" - let l:columns = &numberwidth - else - let l:columns = 8 + if &number + if version >= "700" + let l:columns = &numberwidth + else + let l:columns = 8 + endif endif " Resize for signs. if has("signs") - if version >= "600" - let l:columns += 2 + if g:marksigns + if version >= "600" + let l:columns = l:columns + 2 + endif endif endif - call Resize_Columns("+", l:columns) + if g:oldcols < (80 + l:columns) + call Resize_Columns("+", l:columns) + endif endfun " Show numbers by default. au Display VimEnter * call Number(0) " Resize after startup. -au Display VimEnter * call Startup_Resize() +au Display VimEnter * call Startup_Resize() endif """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -- 2.7.4