Handle uncluttered buffers.
[profile.git] / .vimrc
diff --git a/.vimrc b/.vimrc
index b834702..3f4fd1d 100644 (file)
--- a/.vimrc
+++ b/.vimrc
@@ -75,8 +75,10 @@ if ! has("gui_running")
   se bg=dark
 endif
 
-" Allow mouse use in a terminal.
-se mouse=nvir
+" Allow mouse use in a terminal but only if it can work.
+if has("xterm_clipboard")
+  se mouse=nvir
+endif
 
 " Update more quickly.  For use with sign highlighting as polling for
 " CursorMove makes redrawing slow.
@@ -113,8 +115,9 @@ if ! exists("g:oldcols")
   let g:oldcols=&columns
 endif
 
-" More GUI options.  Add icon, tearoffs and toolbar.
-se go+=itT
+" More GUI options.  Add icon and tearoffs.
+se go+=i
+se go+=t
 
 " Allow dynamic window resize even if we aren't in an xterm.
 se t_WS=\e[8;%p1%d;%p2%dt
@@ -363,6 +366,34 @@ map Q <NOP>
 " 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\") . \">\"<CR>")
 
+fun! Uncluttered_Buffer()
+  if exists("uncluttered_buffer")
+    if uncluttered_buffer == 1
+      return 1
+    endif
+  endif
+
+  if version >= "600"
+    if &buftype != ''
+      return 1
+    endif
+  endif
+
+  if &ft == 'perforce'
+    return 1
+  endif
+
+  if &ft == 'svn'
+    return 1
+  endif
+
+  if &ft == 'gitcommit'
+    return 1
+  endif
+
+  return 0
+endfun
+
 fun! Startup_Resize()
   let l:columns = 0
 
@@ -390,10 +421,7 @@ fun! Startup_Resize()
 endfun
 
 " Show numbers by default.
-au Display VimEnter * call Number(0)
-
-" Resize after startup.
-au Display VimEnter * call Startup_Resize()
+au Display VimEnter * if ! Uncluttered_Buffer() | call Number(0) | endif
 endif
 
 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
@@ -529,7 +557,7 @@ fun! <SID>Place_Sign(number, line, old, name)
 endfun
 
 fun! <SID>Highlight_Signs(...)
-  if ! has("signs") || ! g:marksigns
+  if ! has("signs") || ! g:marksigns || Uncluttered_Buffer()
     return
   endif
 
@@ -811,7 +839,7 @@ endfun
 " Find out if any buffer was modified.
 fun! <SID>TabModified(buflist)
   let l:i = 0
-  while i < len(a:buflist)
+  while l:i < len(a:buflist)
     if getbufvar(a:buflist[l:i], "&modified") == 1
       return "+"
     endif
@@ -898,3 +926,8 @@ se go+=e
 let g:p4EnableMenu=1
 let g:p4Presets='P4CONFIG'
 endif
+
+if version >= "500"
+" Resize after startup.
+au Display VimEnter * call Startup_Resize()
+endif