Skip to content

Commit e454233

Browse files
committed
Define version as variable, include version in messages
1 parent 27b9aa3 commit e454233

File tree

2 files changed

+31
-35
lines changed

2 files changed

+31
-35
lines changed

autoload/xolox/easytags.vim

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
" Vim script
22
" Author: Peter Odding <peter@peterodding.com>
3-
" Last Change: June 14, 2011
3+
" Last Change: June 18, 2011
44
" URL: http://peterodding.com/code/vim/easytags/
55

6-
let s:script = 'easytags.vim'
7-
86
" Public interface through (automatic) commands. {{{1
97

108
function! xolox#easytags#register(global) " {{{2
@@ -59,7 +57,7 @@ function! xolox#easytags#autoload() " {{{2
5957
let b:easytags_last_highlighted = localtime()
6058
endif
6159
catch
62-
call xolox#misc#msg#warn("%s: %s (at %s)", s:script, v:exception, v:throwpoint)
60+
call xolox#misc#msg#warn("easytags.vim %s: %s (at %s)", g:easytags_version, v:exception, v:throwpoint)
6361
endtry
6462
endfunction
6563

@@ -76,14 +74,14 @@ function! xolox#easytags#update(silent, filter_tags, filenames) " {{{2
7674
if !firstrun
7775
let num_filtered = s:filter_merge_tags(a:filter_tags, tagsfile, output)
7876
if cfile != ''
79-
let msg = "%s: Updated tags for %s in %s."
80-
call xolox#misc#timer#stop(msg, s:script, expand('%:p:~'), starttime)
77+
let msg = "easytags.vim %s: Updated tags for %s in %s."
78+
call xolox#misc#timer#stop(msg, g:easytags_version, expand('%:p:~'), starttime)
8179
elseif !empty(a:filenames)
82-
let msg = "%s: Updated tags in %s."
83-
call xolox#misc#timer#stop(msg, s:script, starttime)
80+
let msg = "easytags.vim %s: Updated tags in %s."
81+
call xolox#misc#timer#stop(msg, g:easytags_version, starttime)
8482
else
85-
let msg = "%s: Filtered %i invalid tags in %s."
86-
call xolox#misc#timer#stop(msg, s:script, num_filtered, starttime)
83+
let msg = "easytags.vim %s: Filtered %i invalid tags in %s."
84+
call xolox#misc#timer#stop(msg, g:easytags_version, num_filtered, starttime)
8785
endif
8886
endif
8987
" When :UpdateTags was executed manually we'll refresh the dynamic
@@ -93,7 +91,7 @@ function! xolox#easytags#update(silent, filter_tags, filenames) " {{{2
9391
endif
9492
return 1
9593
catch
96-
call xolox#misc#msg#warn("%s: %s (at %s)", s:script, v:exception, v:throwpoint)
94+
call xolox#misc#msg#warn("easytags.vim %s: %s (at %s)", g:easytags_version, v:exception, v:throwpoint)
9795
endtry
9896
endfunction
9997

@@ -169,7 +167,7 @@ endfunction
169167
function! s:run_ctags(starttime, cfile, tagsfile, firstrun, cmdline) " {{{3
170168
let lines = []
171169
if a:cmdline != ''
172-
call xolox#misc#msg#debug("%s: Executing %s", s:script, a:cmdline)
170+
call xolox#misc#msg#debug("easytags.vim %s: Executing %s.", g:easytags_version, a:cmdline)
173171
try
174172
let lines = xolox#shell#execute(a:cmdline, 1)
175173
catch /^Vim\%((\a\+)\)\=:E117/
@@ -183,9 +181,9 @@ function! s:run_ctags(starttime, cfile, tagsfile, firstrun, cmdline) " {{{3
183181
endtry
184182
if a:firstrun
185183
if a:cfile != ''
186-
call xolox#misc#timer#stop("%s: Created tags for %s in %s.", s:script, expand('%:p:~'), a:starttime)
184+
call xolox#misc#timer#stop("easytags.vim %s: Created tags for %s in %s.", g:easytags_version, expand('%:p:~'), a:starttime)
187185
else
188-
call xolox#misc#timer#stop("%s: Created tags in %s.", s:script, a:starttime)
186+
call xolox#misc#timer#stop("easytags.vim %s: Created tags in %s.", g:easytags_version, a:starttime)
189187
endif
190188
endif
191189
endif
@@ -280,8 +278,8 @@ function! xolox#easytags#highlight() " {{{2
280278
try
281279
execute command
282280
catch /^Vim\%((\a\+)\)\=:E339/
283-
let msg = "easytags.vim: Failed to highlight %i %s tags because pattern is too big! (%i KB)"
284-
call xolox#misc#msg#warn(printf(msg, len(matches), tagkind.hlgroup, len(pattern) / 1024))
281+
let msg = "easytags.vim %s: Failed to highlight %i %s tags because pattern is too big! (%i KB)"
282+
call xolox#misc#msg#warn(msg, g:easytags_version, len(matches), tagkind.hlgroup, len(pattern) / 1024)
285283
endtry
286284
endif
287285
endif
@@ -291,12 +289,12 @@ function! xolox#easytags#highlight() " {{{2
291289
if bufname == ''
292290
let bufname = 'unnamed buffer #' . bufnr('%')
293291
endif
294-
let msg = "%s: Highlighted tags in %s in %s%s."
295-
call xolox#misc#timer#stop(msg, s:script, bufname, starttime, used_python ? " (using Python)" : "")
292+
let msg = "easytags.vim %s: Highlighted tags in %s in %s%s."
293+
call xolox#misc#timer#stop(msg, g:easytags_version, bufname, starttime, used_python ? " (using Python)" : "")
296294
return 1
297295
endif
298296
catch
299-
call xolox#misc#msg#warn("%s: %s (at %s)", s:script, v:exception, v:throwpoint)
297+
call xolox#misc#msg#warn("easytags.vim %s: %s (at %s)", g:easytags_version, v:exception, v:throwpoint)
300298
endtry
301299
endfunction
302300

@@ -312,8 +310,8 @@ function! xolox#easytags#by_filetype(undo) " {{{2
312310
let [headers, entries] = xolox#easytags#read_tagsfile(global_tagsfile)
313311
call s:save_by_filetype(headers, entries)
314312
call rename(global_tagsfile, disabled_tagsfile)
315-
let msg = "Finished copying tags from %s to %s! Note that your old tags file has been renamed to %s instead of deleting it, should you want to restore it."
316-
call xolox#misc#msg#info(msg, g:easytags_file, g:easytags_by_filetype, disabled_tagsfile)
313+
let msg = "easytags.vim %s: Finished copying tags from %s to %s! Note that your old tags file has been renamed to %s instead of deleting it, should you want to restore it."
314+
call xolox#misc#msg#info(msg, g:easytags_version, g:easytags_file, g:easytags_by_filetype, disabled_tagsfile)
317315
else
318316
let headers = []
319317
let all_entries = []
@@ -322,10 +320,10 @@ function! xolox#easytags#by_filetype(undo) " {{{2
322320
call extend(all_entries, entries)
323321
endfor
324322
call xolox#easytags#write_tagsfile(global_tagsfile, headers, all_entries)
325-
call xolox#misc#msg#info("Finished copying tags from %s to %s!", g:easytags_by_filetype, g:easytags_file)
323+
call xolox#misc#msg#info("easytags.vim %s: Finished copying tags from %s to %s!", g:easytags_version, g:easytags_by_filetype, g:easytags_file)
326324
endif
327325
catch
328-
call xolox#misc#msg#warn("%s: %s (at %s)", s:script, v:exception, v:throwpoint)
326+
call xolox#misc#msg#warn("easytags.vim %s: %s (at %s)", g:easytags_version, v:exception, v:throwpoint)
329327
endtry
330328
endfunction
331329

@@ -369,8 +367,8 @@ function! xolox#easytags#supported_filetypes() " {{{2
369367
endif
370368
endtry
371369
let s:supported_filetypes = map(copy(listing), 's:check_filetype(listing, v:val)')
372-
let msg = "%s: Retrieved %i supported languages in %s."
373-
call xolox#misc#timer#stop(msg, s:script, len(s:supported_filetypes), starttime)
370+
let msg = "easytags.vim %s: Retrieved %i supported languages in %s."
371+
call xolox#misc#timer#stop(msg, g:easytags_version, len(s:supported_filetypes), starttime)
374372
endif
375373
return s:supported_filetypes
376374
endfunction
@@ -473,7 +471,7 @@ function! s:cache_tagged_files() " {{{3
473471
call s:cache_tagged_files_in(fname, ftime, entries)
474472
endif
475473
endfor
476-
call xolox#misc#timer#stop("%s: Initialized cache of tagged files in %s", s:script, starttime)
474+
call xolox#misc#timer#stop("easytags.vim %s: Initialized cache of tagged files in %s.", g:easytags_version, starttime)
477475
endif
478476
endfunction
479477

plugin/easytags.vim

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
" Vim plug-in
22
" Author: Peter Odding <peter@peterodding.com>
3-
" Last Change: June 17, 2011
3+
" Last Change: June 18, 2011
44
" URL: http://peterodding.com/code/vim/easytags/
55
" Requires: Exuberant Ctags (http://ctags.sf.net)
6-
" License: MIT
7-
" Version: 2.4.2
86

97
" Support for automatic update using the GLVS plug-in.
108
" GetLatestVimScripts: 3114 1 :AutoInstall: easytags.zip
119

12-
" Don't source the plug-in when its already been loaded or &compatible is set.
10+
" Don't source the plug-in when it's already been loaded or &compatible is set.
1311
if &cp || exists('g:loaded_easytags')
1412
finish
1513
endif
1614

17-
let s:script = expand('<sfile>:p:~')
15+
let g:easytags_version = '2.4.3'
1816

1917
" Configuration defaults and initialization. {{{1
2018

@@ -126,19 +124,19 @@ if !s:InitEasyTags(55)
126124
finish
127125
endif
128126
if !exists('g:easytags_ctags_version') || empty(g:easytags_ctags_version)
129-
let s:msg = "%s: Plug-in not loaded because Exuberant Ctags isn't installed!"
127+
let s:msg = "easytags.vim %s: Plug-in not loaded because Exuberant Ctags isn't installed!"
130128
if executable('apt-get')
131129
let s:msg .= " On Ubuntu & Debian you can install Exuberant Ctags by"
132130
let s:msg .= " installing the package named `exuberant-ctags':"
133131
let s:msg .= " sudo apt-get install exuberant-ctags"
134132
else
135133
let s:msg .= " Please download & install Exuberant Ctags from http://ctags.sf.net"
136134
endif
137-
echomsg printf(s:msg, s:script)
135+
echomsg printf(s:msg, g:easytags_version)
138136
else
139-
let s:msg = "%s: Plug-in not loaded because Exuberant Ctags 5.5"
137+
let s:msg = "easytags.vim %s: Plug-in not loaded because Exuberant Ctags 5.5"
140138
let s:msg .= " or newer is required while you have version %s installed!"
141-
echomsg printf(s:msg, s:script, g:easytags_ctags_version)
139+
echomsg printf(s:msg, g:easytags_version, g:easytags_ctags_version)
142140
endif
143141
unlet s:msg
144142
finish

0 commit comments

Comments
 (0)