@@ -36,6 +36,9 @@ call s:InitVariable('g:strip_whitespace_on_save', 0)
3636let default_blacklist= [' diff' , ' gitcommit' , ' unite' , ' qf' , ' help' ]
3737call s: InitVariable (' g:better_whitespace_filetypes_blacklist' , default_blacklist)
3838
39+ " Disable verbosity by default
40+ call s: InitVariable (' g:better_whitespace_verbosity' , 0 )
41+
3942" Only init once
4043let s: better_whitespace_initialized = 0
4144
@@ -67,6 +70,13 @@ function! s:WhitespaceInit()
6770 let s: better_whitespace_initialized = 1
6871endfunction
6972
73+ " Like 'echo', but only outputs the message when verbosity is enabled
74+ function ! s: Echo (message)
75+ if g: better_whitespace_verbosity == 1
76+ echo a: message
77+ endif
78+ endfunction
79+
7080" Enable the whitespace highlighting
7181function ! s: EnableWhitespace ()
7282 if g: better_whitespace_enabled == 0
@@ -75,7 +85,7 @@ function! s:EnableWhitespace()
7585 " Match default whitespace
7686 call s: InAllWindows (' match ExtraWhitespace /\s\+$/' )
7787 call <SID> SetupAutoCommands ()
78- echo " Whitespace Highlighting: Enabled"
88+ call <SID> Echo ( " Whitespace Highlighting: Enabled" )
7989 endif
8090endfunction
8191
@@ -86,7 +96,7 @@ function! s:DisableWhitespace()
8696 " Clear current whitespace matches
8797 call s: InAllWindows (" match ExtraWhitespace '' | syn clear ExtraWhitespace" )
8898 call <SID> SetupAutoCommands ()
89- echo " Whitespace Highlighting: Disabled"
99+ call <SID> Echo ( " Whitespace Highlighting: Disabled" )
90100 endif
91101endfunction
92102
@@ -112,12 +122,12 @@ function! s:CurrentLineWhitespaceOff( level )
112122 let g: current_line_whitespace_disabled_hard = 1
113123 let g: current_line_whitespace_disabled_soft = 0
114124 call s: InAllWindows (' syn clear ExtraWhitespace | match ExtraWhitespace /\s\+$/' )
115- echo " Current Line Hightlight Off (hard)"
125+ call <SID> Echo ( " Current Line Hightlight Off (hard)" )
116126 elseif a: level == ' soft'
117127 let g: current_line_whitespace_disabled_soft = 1
118128 let g: current_line_whitespace_disabled_hard = 0
119129 call s: InAllWindows (" match ExtraWhitespace ''" )
120- echo " Current Line Hightlight Off (soft)"
130+ call <SID> Echo ( " Current Line Hightlight Off (soft)" )
121131 endif
122132 " Re-run auto commands with the new settings
123133 call <SID> SetupAutoCommands ()
@@ -131,7 +141,7 @@ function! s:CurrentLineWhitespaceOn()
131141 let g: current_line_whitespace_disabled_soft = 0
132142 call <SID> SetupAutoCommands ()
133143 call s: InAllWindows (' syn clear ExtraWhitespace | match ExtraWhitespace /\s\+$/' )
134- echo " Current Line Hightlight On"
144+ call <SID> Echo ( " Current Line Hightlight On" )
135145 endif
136146endfunction
137147
@@ -154,10 +164,10 @@ endfunction
154164function ! s: ToggleStripWhitespaceOnSave ()
155165 if g: strip_whitespace_on_save == 0
156166 let g: strip_whitespace_on_save = 1
157- echo " Strip Whitespace On Save: Enabled"
167+ call <SID> Echo ( " Strip Whitespace On Save: Enabled" )
158168 else
159169 let g: strip_whitespace_on_save = 0
160- echo " Strip Whitespace On Save: Disabled"
170+ call <SID> Echo ( " Strip Whitespace On Save: Disabled" )
161171 endif
162172 call <SID> SetupAutoCommands ()
163173endfunction
0 commit comments