Skip to content
This repository
Browse code

Define version as variable, include version in messages

  • Loading branch information...
commit e454233ca5289444deaf2f6525af76b995fd9717 1 parent 27b9aa3
Peter Odding authored June 18, 2011
50  autoload/xolox/easytags.vim
... ...
@@ -1,10 +1,8 @@
1 1
 " Vim script
2 2
 " Author: Peter Odding <peter@peterodding.com>
3  
-" Last Change: June 14, 2011
  3
+" Last Change: June 18, 2011
4 4
 " URL: http://peterodding.com/code/vim/easytags/
5 5
 
6  
-let s:script = 'easytags.vim'
7  
-
8 6
 " Public interface through (automatic) commands. {{{1
9 7
 
10 8
 function! xolox#easytags#register(global) " {{{2
@@ -59,7 +57,7 @@ function! xolox#easytags#autoload() " {{{2
59 57
       let b:easytags_last_highlighted = localtime()
60 58
     endif
61 59
   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)
63 61
   endtry
64 62
 endfunction
65 63
 
@@ -76,14 +74,14 @@ function! xolox#easytags#update(silent, filter_tags, filenames) " {{{2
76 74
     if !firstrun
77 75
       let num_filtered = s:filter_merge_tags(a:filter_tags, tagsfile, output)
78 76
       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)
81 79
       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)
84 82
       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)
87 85
       endif
88 86
     endif
89 87
     " When :UpdateTags was executed manually we'll refresh the dynamic
@@ -93,7 +91,7 @@ function! xolox#easytags#update(silent, filter_tags, filenames) " {{{2
93 91
     endif
94 92
     return 1
95 93
   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)
97 95
   endtry
98 96
 endfunction
99 97
 
@@ -169,7 +167,7 @@ endfunction
169 167
 function! s:run_ctags(starttime, cfile, tagsfile, firstrun, cmdline) " {{{3
170 168
   let lines = []
171 169
   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)
173 171
     try
174 172
       let lines = xolox#shell#execute(a:cmdline, 1)
175 173
     catch /^Vim\%((\a\+)\)\=:E117/
@@ -183,9 +181,9 @@ function! s:run_ctags(starttime, cfile, tagsfile, firstrun, cmdline) " {{{3
183 181
     endtry
184 182
     if a:firstrun
185 183
       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)
187 185
       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)
189 187
       endif
190 188
     endif
191 189
   endif
@@ -280,8 +278,8 @@ function! xolox#easytags#highlight() " {{{2
280 278
             try
281 279
               execute command
282 280
             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)
285 283
             endtry
286 284
           endif
287 285
         endif
@@ -291,12 +289,12 @@ function! xolox#easytags#highlight() " {{{2
291 289
       if bufname == ''
292 290
         let bufname = 'unnamed buffer #' . bufnr('%')
293 291
       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)" : "")
296 294
       return 1
297 295
     endif
298 296
   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)
300 298
   endtry
301 299
 endfunction
302 300
 
@@ -312,8 +310,8 @@ function! xolox#easytags#by_filetype(undo) " {{{2
312 310
       let [headers, entries] = xolox#easytags#read_tagsfile(global_tagsfile)
313 311
       call s:save_by_filetype(headers, entries)
314 312
       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)
317 315
     else
318 316
       let headers = []
319 317
       let all_entries = []
@@ -322,10 +320,10 @@ function! xolox#easytags#by_filetype(undo) " {{{2
322 320
         call extend(all_entries, entries)
323 321
       endfor
324 322
       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)
326 324
     endif
327 325
   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)
329 327
   endtry
330 328
 endfunction
331 329
 
@@ -369,8 +367,8 @@ function! xolox#easytags#supported_filetypes() " {{{2
369 367
       endif
370 368
     endtry
371 369
     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)
374 372
   endif
375 373
   return s:supported_filetypes
376 374
 endfunction
@@ -473,7 +471,7 @@ function! s:cache_tagged_files() " {{{3
473 471
         call s:cache_tagged_files_in(fname, ftime, entries)
474 472
       endif
475 473
     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)
477 475
   endif
478 476
 endfunction
479 477
 
16  plugin/easytags.vim
... ...
@@ -1,20 +1,18 @@
1 1
 " Vim plug-in
2 2
 " Author: Peter Odding <peter@peterodding.com>
3  
-" Last Change: June 17, 2011
  3
+" Last Change: June 18, 2011
4 4
 " URL: http://peterodding.com/code/vim/easytags/
5 5
 " Requires: Exuberant Ctags (http://ctags.sf.net)
6  
-" License: MIT
7  
-" Version: 2.4.2
8 6
 
9 7
 " Support for automatic update using the GLVS plug-in.
10 8
 " GetLatestVimScripts: 3114 1 :AutoInstall: easytags.zip
11 9
 
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.
13 11
 if &cp || exists('g:loaded_easytags')
14 12
   finish
15 13
 endif
16 14
 
17  
-let s:script = expand('<sfile>:p:~')
  15
+let g:easytags_version = '2.4.3'
18 16
 
19 17
 " Configuration defaults and initialization. {{{1
20 18
 
@@ -126,7 +124,7 @@ if !s:InitEasyTags(55)
126 124
     finish
127 125
   endif
128 126
   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!"
130 128
     if executable('apt-get')
131 129
       let s:msg .= " On Ubuntu & Debian you can install Exuberant Ctags by"
132 130
       let s:msg .= " installing the package named `exuberant-ctags':"
@@ -134,11 +132,11 @@ if !s:InitEasyTags(55)
134 132
     else
135 133
       let s:msg .= " Please download & install Exuberant Ctags from http://ctags.sf.net"
136 134
     endif
137  
-    echomsg printf(s:msg, s:script)
  135
+    echomsg printf(s:msg, g:easytags_version)
138 136
   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"
140 138
     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)
142 140
   endif
143 141
   unlet s:msg
144 142
   finish

0 notes on commit e454233

Please sign in to comment.
Something went wrong with that request. Please try again.