Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Define version as variable, include version in messages

  • Loading branch information...
commit 6c11e2791f8bdb8ce6e90482a09b99f2277e2a7b 1 parent 4be4d28
Peter Odding authored
14  autoload/xolox/reload.vim
... ...
@@ -1,10 +1,8 @@
1 1
 " Vim script
2  
-" Last Change: February 4, 2011
  2
+" Last Change: June 18, 2011
3 3
 " Author: Peter Odding
4 4
 " URL: http://peterodding.com/code/vim/reload/
5 5
 
6  
-let s:script = expand('<sfile>:t')
7  
-
8 6
 " Patterns to match various types of Vim script names. {{{1
9 7
 
10 8
 " Enable line continuation.
@@ -69,14 +67,14 @@ function! s:reload_plugin(start_time, filename, friendly_name) " {{{1
69 67
   call s:reload_message('plug-in', a:friendly_name)
70 68
   unlet! g:loaded_{fnamemodify(a:filename, ':t:r')}
71 69
   execute 'source' fnameescape(a:filename)
72  
-  return ["%s: Reloaded %s plug-in in %s.", s:script, a:friendly_name, a:start_time]
  70
+  return ["reload.vim %s: Reloaded %s plug-in in %s.", g:reload_version, a:friendly_name, a:start_time]
73 71
 endfunction
74 72
 
75 73
 if !exists('s:reload_script_active')
76 74
   function! s:reload_autoload(start_time, filename, friendly_name) " {{{1
77 75
     call s:reload_message('auto-load script', a:friendly_name)
78 76
     execute 'source' fnameescape(a:filename)
79  
-    return ["%s: Reloaded %s auto-load script in %s.", s:script, a:friendly_name, a:start_time]
  77
+    return ["reload.vim %s: Reloaded %s auto-load script in %s.", g:reload_version, a:friendly_name, a:start_time]
80 78
   endfunction
81 79
 endif
82 80
 
@@ -107,7 +105,7 @@ function! s:reload_buffers(start_time, filetype, friendly_name, script_type, var
107 105
   call winrestview(view_save)
108 106
   " Disable the SwapExists automatic command.
109 107
   unlet s:reloading_buffers
110  
-  return ["%s: Reloaded %s %s in %s.", s:script, a:script_type, a:friendly_name, a:start_time]
  108
+  return ["reload.vim %s: Reloaded %s %s in %s.", g:reload_version, a:script_type, a:friendly_name, a:start_time]
111 109
 endfunction
112 110
 
113 111
 function! xolox#reload#open_readonly() " {{{1
@@ -150,7 +148,7 @@ function! s:reload_colors(start_time, filename, friendly_name) " {{{1
150 148
     let escaped = fnameescape(colorscheme)
151 149
     execute 'colorscheme' escaped
152 150
     execute 'doautocmd colorscheme' escaped
153  
-    return ["%s: Reloaded %s color scheme in %s.", s:script, a:friendly_name, a:start_time]
  151
+    return ["reload.vim %s: Reloaded %s color scheme in %s.", g:reload_version, a:friendly_name, a:start_time]
154 152
   endif
155 153
 endfunction
156 154
 
@@ -190,7 +188,7 @@ function! s:normalize_path(path) " {{{2
190 188
 endfunction
191 189
 
192 190
 function! s:reload_message(scripttype, scriptname) " {{{2
193  
-  call xolox#misc#msg#info('%s: Reloading %s %s', s:script, a:scripttype, a:scriptname)
  191
+  call xolox#misc#msg#info('reload.vim %s: Reloading %s %s.', g:reload_version, a:scripttype, a:scriptname)
194 192
 endfunction
195 193
 
196 194
 " vim: ts=2 sw=2 et
28  doc/reload.txt
@@ -32,7 +32,7 @@ The directories listed above are Vim's defaults but you're free to change the
32 32
 Note that |vimrc| scripts are not reloaded because that seems to cause more
33 33
 trouble than it's worth...
34 34
 
35  
-==============================================================================
  35
+===============================================================================
36 36
                                                       *reload-install-first-use*
37 37
 Install & first use ~
38 38
 
@@ -49,9 +49,8 @@ all Vim scripts that it knows how to. If you like it this way then you don't
49 49
 need to configure anything! However if you don't like the automatic reloading
50 50
 then you'll need the following:
51 51
 
52  
-------------------------------------------------------------------------------
53  
-                                                      *g:reload_on_write-option*
54  
-The 'g:reload_on_write' option ~
  52
+-------------------------------------------------------------------------------
  53
+The *g:reload_on_write* option
55 54
 
56 55
 If you don't like automatic reloading because it slows Vim down or causes
57 56
 problems you can add the following line to your |vimrc| script:
@@ -61,11 +60,10 @@ problems you can add the following line to your |vimrc| script:
61 60
 This disables automatic reloading which means you'll have to reload scripts
62 61
 using the command discussed below.
63 62
 
64  
-------------------------------------------------------------------------------
65  
-                                                         *:reloadscript-command*
66  
-The ':ReloadScript' command ~
  63
+-------------------------------------------------------------------------------
  64
+The *:ReloadScript* command
67 65
 
68  
-You can execute the ':ReloadScript' command to reload the Vim script you're
  66
+You can execute the |:ReloadScript| command to reload the Vim script you're
69 67
 editing. If you provide a script name as argument to the command then that
70 68
 script will be reloaded instead, e.g.:
71 69
 >
@@ -75,7 +73,7 @@ If after executing this command you see Vim errors such as "Function already
75 73
 exists" (|E122|) or "Command already exists" (|E174|) then you'll need to change
76 74
 your Vim script(s) slightly to enable reloading, see below.
77 75
 
78  
-==============================================================================
  76
+===============================================================================
79 77
                                                  *things-that-prevent-reloading*
80 78
 Things that prevent reloading ~
81 79
 
@@ -83,7 +81,7 @@ If you want your Vim plug-ins and/or other scripts to be automatically
83 81
 reloaded they'll have to be written a certain way, though you can consider the
84 82
 following points good practice for Vim script writing anyway:
85 83
 
86  
-------------------------------------------------------------------------------
  84
+-------------------------------------------------------------------------------
87 85
 Use a bang in command and function definitions! ~
88 86
 
89 87
 Function and command definitions using Vim's |:command| and |:function| built-ins
@@ -100,7 +98,7 @@ complain that the command or function already exists:
100 98
     :function! MyFun()
101 99
     :endfunction
102 100
 
103  
-------------------------------------------------------------------------------
  101
+-------------------------------------------------------------------------------
104 102
                                            *reload-use-automatic-command-groups*
105 103
 Use automatic command groups ~
106 104
 
@@ -119,7 +117,7 @@ several times:
119 117
     :  autocmd! TabEnter * echomsg "Entered tab page"
120 118
     :augroup END
121 119
 
122  
-==============================================================================
  120
+===============================================================================
123 121
                                                            *reload-alternatives*
124 122
 Alternatives ~
125 123
 
@@ -134,7 +132,7 @@ scripts, but there are a few notable differences:
134 132
 
135 133
  - This plug-in can more or less reload itself ;-)
136 134
 
137  
-==============================================================================
  135
+===============================================================================
138 136
                                                                 *reload-contact*
139 137
 Contact ~
140 138
 
@@ -143,14 +141,14 @@ contacted at peter@peterodding.com. The latest version is available at
143 141
 http://peterodding.com/code/vim/reload/ and http://github.com/xolox/vim-reload.
144 142
 If you like the plug-in please vote for it on Vim Online [3].
145 143
 
146  
-==============================================================================
  144
+===============================================================================
147 145
                                                                 *reload-license*
148 146
 License ~
149 147
 
150 148
 This software is licensed under the MIT license [4]. Copyright 2010 Peter
151 149
 Odding <peter@peterodding.com>.
152 150
 
153  
-==============================================================================
  151
+===============================================================================
154 152
                                                              *reload-references*
155 153
 References ~
156 154
 
14  plugin/reload.vim
... ...
@@ -1,13 +1,18 @@
1 1
 " Vim script
2  
-" Last Change: May 25, 2011
  2
+" Last Change: June 18, 2011
3 3
 " Author: Peter Odding
4 4
 " URL: http://peterodding.com/code/vim/reload/
5  
-" License: MIT
6  
-" Version: 0.6.1
7 5
 
8 6
 " Support for automatic update using the GLVS plug-in.
9 7
 " GetLatestVimScripts: 3148 1 :AutoInstall: reload.zip
10 8
 
  9
+" Don't source the plug-in when it's already been loaded or &compatible is set.
  10
+if &cp || exists('g:loaded_reload')
  11
+  finish
  12
+endif
  13
+
  14
+let g:reload_version = '0.6.2'
  15
+
11 16
 if !exists('g:reload_on_write')
12 17
   let g:reload_on_write = 1
13 18
 endif
@@ -40,4 +45,7 @@ if !exists('s:auto_reload_active')
40 45
   endfunction
41 46
 endif
42 47
 
  48
+" Don't reload the plug-in once it has loaded successfully.
  49
+let g:loaded_reload = 1
  50
+
43 51
 " vim: ts=2 sw=2 et

0 notes on commit 6c11e27

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