Skip to content

Commit 8fb0c85

Browse files
committed
Clear inclusion guard based on basename of script file
1 parent 5fc2712 commit 8fb0c85

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Note that [vimrc scripts][vimrc] are not reloaded because that seems to cause mo
1818

1919
## Install & first use
2020

21-
Unzip the most recent [ZIP archive](http://peterodding.com/code/vim/downloads/reload) file inside your Vim profile directory (usually this is `~/.vim` on UNIX and `%USERPROFILE%\vimfiles` on Windows), restart Vim and try it out: Edit any Vim script that's already loaded and check that the script is reloaded when you save it (the reload.vim plug-in will print a message to confirm when a script is reloaded).
21+
Unzip the most recent [ZIP archive](http://peterodding.com/code/vim/downloads/reload) file inside your Vim profile directory (usually this is `~/.vim` on UNIX and `%USERPROFILE%\vimfiles` on Windows), restart Vim and execute the command `:helptags ~/.vim/doc` (use `:helptags ~\vimfiles\doc` instead on Windows). Now try it out: Edit any Vim script that's already loaded (you can check using the [:scriptnames command][scriptnames]) and confirm that the script is reloaded when you save it (the reload.vim plug-in will print a message to confirm when a script is reloaded).
2222

2323
Out of the box the [reload.vim][reload] plug-in is configured to automatically reload all Vim scripts that it knows how to. If you like it this way then you don't need to configure anything! However if you don't like the automatic reloading then you'll need the following:
2424

@@ -76,9 +76,7 @@ The [ReloadScript](http://www.vim.org/scripts/script.php?script_id=1904) plug-in
7676

7777
* This plug-in focuses on automatic reloading (I'm lazy) while the other one requires manual reloading;
7878

79-
* This plug-in doesn't clear inclusion guard variables while the other one does;
80-
81-
* This plug-in will *never* [:source](http://vimdoc.sourceforge.net/htmldoc/repeat.html#:source) a file that hasn't already been loaded by Vim -- it checks using Vim's [:scriptnames](http://vimdoc.sourceforge.net/htmldoc/repeat.html#:scriptnames) command;
79+
* This plug-in will *never* [:source](http://vimdoc.sourceforge.net/htmldoc/repeat.html#:source) a file that hasn't already been loaded by Vim -- it checks using Vim's [:scriptnames][scriptnames] command;
8280

8381
* This plug-in can more or less reload itself ;-)
8482

@@ -94,6 +92,7 @@ This software is licensed under the [MIT license](http://en.wikipedia.org/wiki/M
9492

9593
[autocmd]: http://vimdoc.sourceforge.net/htmldoc/autocmd.html#:autocmd
9694
[reload]: http://github.com/xolox/vim-reload/blob/master/reload.vim
95+
[scriptnames]: http://vimdoc.sourceforge.net/htmldoc/repeat.html#:scriptnames
9796
[update]: http://vimdoc.sourceforge.net/htmldoc/editing.html#:update
9897
[vim]: http://www.vim.org/
9998
[vimrc]: http://vimdoc.sourceforge.net/htmldoc/starting.html#vimrc

autoload.vim

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
" Vim script
2-
" Last Change: July 13, 2010
2+
" Last Change: July 15, 2010
33
" Author: Peter Odding
44
" URL: http://peterodding.com/code/vim/reload/
55

@@ -52,6 +52,11 @@ endif
5252

5353
function! s:reload_plugin(start_time, filename, friendly_name) " {{{1
5454
call s:reload_message('plug-in', a:friendly_name)
55+
" Clear include guard so full plug-in can be reloaded?
56+
let variable = 'g:loaded_' . fnamemodify(a:filename, ':t:r')
57+
if exists(variable)
58+
execute 'unlet' variable
59+
endif
5560
execute 'source' fnameescape(a:filename)
5661
let msg = "%s: Reloaded %s plug-in in %s."
5762
call xolox#timer#stop(msg, s:script, a:friendly_name, a:start_time)

reload.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
" Vim script
2-
" Last Change: July 13, 2010
2+
" Last Change: July 15, 2010
33
" Author: Peter Odding
44
" URL: http://peterodding.com/code/vim/reload/
55
" License: MIT
6-
" Version: 0.3
6+
" Version: 0.4
77

88
" Support for automatic update using the GLVS plug-in.
99
" GetLatestVimScripts: 3148 1 :AutoInstall: reload.zip

0 commit comments

Comments
 (0)