aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Odding <peter@peterodding.com>2013-05-20 06:00:17 +0200
committerPeter Odding <peter@peterodding.com>2013-05-20 06:00:17 +0200
commitc4997a1f0060f06428b451637e934bfa36afd561 (patch)
tree7cc3b5e8d7d78d78d0599e4c42877951d4f44fe3
parent37a9bf46a6ca2bb702c3cbaa7e6dad5cc1726409 (diff)
downloadvim-easytags-c4997a1f0060f06428b451637e934bfa36afd561.tar.gz
Add xolox#misc#timer#force() function
-rw-r--r--autoload/xolox/misc/compat.vim2
-rw-r--r--autoload/xolox/misc/msg.vim4
-rw-r--r--autoload/xolox/misc/timer.vim15
3 files changed, 12 insertions, 9 deletions
diff --git a/autoload/xolox/misc/compat.vim b/autoload/xolox/misc/compat.vim
index 3f3a42c..e6c9a0c 100644
--- a/autoload/xolox/misc/compat.vim
+++ b/autoload/xolox/misc/compat.vim
@@ -12,7 +12,7 @@
" scripts breaks backwards compatibility. This enables my Vim plug-ins to fail
" early when they detect an incompatible version, instead of breaking at the
" worst possible moments :-).
-let g:xolox#misc#compat#version = 7
+let g:xolox#misc#compat#version = 8
" Remember the directory where the miscellaneous scripts are loaded from
" so the user knows which plug-in to update if incompatibilities arise.
diff --git a/autoload/xolox/misc/msg.vim b/autoload/xolox/misc/msg.vim
index 38eb474..0104b67 100644
--- a/autoload/xolox/misc/msg.vim
+++ b/autoload/xolox/misc/msg.vim
@@ -1,7 +1,7 @@
" Functions to interact with the user.
"
" Author: Peter Odding <peter@peterodding.com>
-" Last Change: May 19, 2013
+" Last Change: May 20, 2013
" URL: http://peterodding.com/code/vim/misc/
if !exists('g:xolox_message_buffer')
@@ -32,8 +32,6 @@ function! xolox#misc#msg#debug(...) " {{{1
" increased verbosity by setting Vim's ['verbose'] [verbose] option to one
" (1) or higher. This function has the same argument handling as Vim's
" [printf()] [printf] function.
- "
- " [verbose]: http://vimdoc.sourceforge.net/htmldoc/options.html#'verbose'
if &vbs >= 1
call s:show_message('question', a:000)
endif
diff --git a/autoload/xolox/misc/timer.vim b/autoload/xolox/misc/timer.vim
index d7fc32d..31072f5 100644
--- a/autoload/xolox/misc/timer.vim
+++ b/autoload/xolox/misc/timer.vim
@@ -1,7 +1,7 @@
" Timing of long during operations.
"
" Author: Peter Odding <peter@peterodding.com>
-" Last Change: May 19, 2013
+" Last Change: May 20, 2013
" URL: http://peterodding.com/code/vim/misc/
if !exists('g:timer_enabled')
@@ -17,10 +17,7 @@ let s:has_reltime = has('reltime')
function! xolox#misc#timer#start() " {{{1
" Start a timer. This returns a list which can later be passed to
" `xolox#misc#timer#stop()`.
- if g:timer_enabled || &verbose >= g:timer_verbosity
- return s:has_reltime ? reltime() : [localtime()]
- endif
- return []
+ return s:has_reltime ? reltime() : [localtime()]
endfunction
function! xolox#misc#timer#stop(...) " {{{1
@@ -40,6 +37,14 @@ function! xolox#misc#timer#stop(...) " {{{1
endif
endfunction
+function! xolox#misc#timer#force(...) " {{{1
+ " Show a formatted message to the user. This function has the same argument
+ " handling as Vim's [printf()] [printf] function with one difference: At the
+ " point where you want the elapsed time to be embedded, you write `%s` and
+ " you pass the list returned by `xolox#misc#timer#start()` as an argument.
+ call call('xolox#misc#msg#info', map(copy(a:000), 's:convert_value(v:val)'))
+endfunction
+
function! s:convert_value(value) " {{{1
if type(a:value) != type([])
return a:value