Skip to content

Commit 6c11e27

Browse files
committedJun 18, 2011
Define version as variable, include version in messages
·
0.6.170.6.2
1 parent 4be4d28 commit 6c11e27

File tree

3 files changed

+30
-26
lines changed

3 files changed

+30
-26
lines changed
 

‎autoload/xolox/reload.vim‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
" Vim script
2-
" Last Change: February 4, 2011
2+
" Last Change: June 18, 2011
33
" Author: Peter Odding
44
" URL: http://peterodding.com/code/vim/reload/
55

6-
let s:script = expand('<sfile>:t')
7-
86
" Patterns to match various types of Vim script names. {{{1
97

108
" Enable line continuation.
@@ -69,14 +67,14 @@ function! s:reload_plugin(start_time, filename, friendly_name) " {{{1
6967
call s:reload_message('plug-in', a:friendly_name)
7068
unlet! g:loaded_{fnamemodify(a:filename, ':t:r')}
7169
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]
7371
endfunction
7472

7573
if !exists('s:reload_script_active')
7674
function! s:reload_autoload(start_time, filename, friendly_name) " {{{1
7775
call s:reload_message('auto-load script', a:friendly_name)
7876
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]
8078
endfunction
8179
endif
8280

@@ -107,7 +105,7 @@ function! s:reload_buffers(start_time, filetype, friendly_name, script_type, var
107105
call winrestview(view_save)
108106
" Disable the SwapExists automatic command.
109107
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]
111109
endfunction
112110

113111
function! xolox#reload#open_readonly() " {{{1
@@ -150,7 +148,7 @@ function! s:reload_colors(start_time, filename, friendly_name) " {{{1
150148
let escaped = fnameescape(colorscheme)
151149
execute 'colorscheme' escaped
152150
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]
154152
endif
155153
endfunction
156154

@@ -190,7 +188,7 @@ function! s:normalize_path(path) " {{{2
190188
endfunction
191189

192190
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)
194192
endfunction
195193

196194
" vim: ts=2 sw=2 et

‎doc/reload.txt‎

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The directories listed above are Vim's defaults but you're free to change the
3232
Note that |vimrc| scripts are not reloaded because that seems to cause more
3333
trouble than it's worth...
3434

35-
==============================================================================
35+
===============================================================================
3636
*reload-install-first-use*
3737
Install & first use ~
3838

@@ -49,9 +49,8 @@ all Vim scripts that it knows how to. If you like it this way then you don't
4949
need to configure anything! However if you don't like the automatic reloading
5050
then you'll need the following:
5151

52-
------------------------------------------------------------------------------
53-
*g:reload_on_write-option*
54-
The 'g:reload_on_write' option ~
52+
-------------------------------------------------------------------------------
53+
The *g:reload_on_write* option
5554

5655
If you don't like automatic reloading because it slows Vim down or causes
5756
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:
6160
This disables automatic reloading which means you'll have to reload scripts
6261
using the command discussed below.
6362

64-
------------------------------------------------------------------------------
65-
*:reloadscript-command*
66-
The ':ReloadScript' command ~
63+
-------------------------------------------------------------------------------
64+
The *:ReloadScript* command
6765

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
6967
editing. If you provide a script name as argument to the command then that
7068
script will be reloaded instead, e.g.:
7169
>
@@ -75,15 +73,15 @@ If after executing this command you see Vim errors such as "Function already
7573
exists" (|E122|) or "Command already exists" (|E174|) then you'll need to change
7674
your Vim script(s) slightly to enable reloading, see below.
7775

78-
==============================================================================
76+
===============================================================================
7977
*things-that-prevent-reloading*
8078
Things that prevent reloading ~
8179

8280
If you want your Vim plug-ins and/or other scripts to be automatically
8381
reloaded they'll have to be written a certain way, though you can consider the
8482
following points good practice for Vim script writing anyway:
8583

86-
------------------------------------------------------------------------------
84+
-------------------------------------------------------------------------------
8785
Use a bang in command and function definitions! ~
8886

8987
Function and command definitions using Vim's |:command| and |:function| built-ins
@@ -100,7 +98,7 @@ complain that the command or function already exists:
10098
:function! MyFun()
10199
:endfunction
102100
103-
------------------------------------------------------------------------------
101+
-------------------------------------------------------------------------------
104102
*reload-use-automatic-command-groups*
105103
Use automatic command groups ~
106104

@@ -119,7 +117,7 @@ several times:
119117
: autocmd! TabEnter * echomsg "Entered tab page"
120118
:augroup END
121119
122-
==============================================================================
120+
===============================================================================
123121
*reload-alternatives*
124122
Alternatives ~
125123

@@ -134,7 +132,7 @@ scripts, but there are a few notable differences:
134132

135133
- This plug-in can more or less reload itself ;-)
136134

137-
==============================================================================
135+
===============================================================================
138136
*reload-contact*
139137
Contact ~
140138

@@ -143,14 +141,14 @@ contacted at peter@peterodding.com. The latest version is available at
143141
http://peterodding.com/code/vim/reload/ and http://github.com/xolox/vim-reload.
144142
If you like the plug-in please vote for it on Vim Online [3].
145143

146-
==============================================================================
144+
===============================================================================
147145
*reload-license*
148146
License ~
149147

150148
This software is licensed under the MIT license [4]. Copyright 2010 Peter
151149
Odding <peter@peterodding.com>.
152150

153-
==============================================================================
151+
===============================================================================
154152
*reload-references*
155153
References ~
156154

‎plugin/reload.vim‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
" Vim script
2-
" Last Change: May 25, 2011
2+
" Last Change: June 18, 2011
33
" Author: Peter Odding
44
" URL: http://peterodding.com/code/vim/reload/
5-
" License: MIT
6-
" Version: 0.6.1
75

86
" Support for automatic update using the GLVS plug-in.
97
" GetLatestVimScripts: 3148 1 :AutoInstall: reload.zip
108

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+
1116
if !exists('g:reload_on_write')
1217
let g:reload_on_write = 1
1318
endif
@@ -40,4 +45,7 @@ if !exists('s:auto_reload_active')
4045
endfunction
4146
endif
4247

48+
" Don't reload the plug-in once it has loaded successfully.
49+
let g:loaded_reload = 1
50+
4351
" vim: ts=2 sw=2 et

0 commit comments

Comments
 (0)
Please sign in to comment.