Closed jonasdiemer closed 11 years ago
Something like this might fix it (crude code, I have never written vim script before):
--- a/.vim/bundle/vim-easytags/autoload/xolox/easytags.vim Fri Oct 05 17:52:57 2012 +0200
+++ b/.vim/bundle/vim-easytags/autoload/xolox/easytags.vim Mon Oct 08 18:55:40 2012 +0200
@@ -34,6 +34,8 @@
endif
endfunction
+let s:CTR = 0
+
function! xolox#easytags#autoload(event) " {{{2
try
if a:event =~? 'cursorhold'
@@ -51,7 +53,12 @@
if xolox#misc#option#get('easytags_updatetime_autodisable', exists('g:loaded_neocomplcache'))
return
else
- call xolox#misc#msg#warn("easytags.vim %s: I'm being executed every %i milliseconds! Please :set updatetime=%i. To find where 'updatetime' was changed execute ':verb set ut?'", g:xolox#easytags#version, &updatetime, updatetime_min)
+ if s:CTR == 0
+ call xolox#misc#msg#warn("easytags.vim %s: I'm being executed every %i milliseconds! Please :set updatetime=%i. To find where 'updatetime' was changed execute ':verb set ut?'", g:xolox#easytags#version, s:CTR, updatetime_min)
+ let s:CTR = updatetime_min / &updatetime
+ else
+ let s:CTR = s:CTR - 1
+ endif
endif
endif
Great idea. I fixed up the code a bit, thanks for the prototype :-)
This patch will allow easytags to - if updatetime currently is lower than g:easytags_updatetime_min - wait an appropiate number of times before actually updating tags. I'm using it together with python-mode, which wants updatetime to be set around 1000ms to run optimally. Please test it with other plugins.
It will derive the amount of no-ops (waits) using the following formula:
update_waits = g:easytags_updatetime_min / &updatetime
It introduces two new global variables, one that must be set for the patch to work:
let g:easytags_updatetime_autoadjust (Set to 1 to automatically adjust waiting time, default 0) let g:easytags_updatetime_autoadjust_warning (Set to 0 to hide warning message, default 1)
diff --git a/autoload/xolox/easytags.vim b/autoload/xolox/easytags.vim
index 2088f48..4375ba4 100644
--- a/autoload/xolox/easytags.vim
+++ b/autoload/xolox/easytags.vim
@@ -51,10 +51,46 @@ function! xolox#easytags#autoload(event) " {{{2
if xolox#misc#option#get('easytags_updatetime_autodisable', exists('g:loaded_neocomplcache'))
return
else
- call xolox#misc#msg#warn("easytags.vim %s: I'm being executed every %i milliseconds! Please :set updatetime=%i. To find where 'updatetime' was changed execute ':verb set ut?'", g:xolox#easytags#version, &updatetime, updatetime_min)
+
+ " Automatically adjust our update time?
+ if xolox#misc#option#get('easytags_updatetime_autoadjust', 0)
+
+ " Is this the first time we have to skip update?
+ if !exists('b:easytags_updatetime_skip')
+ let b:easytags_updatetime_skipped = 0
+ try
+ let b:easytags_updatetime_skip = updatetime_min / &updatetime
+ catch
+ call xolox#misc#msg#warn('easytags.vim: Could not calc skip')
+ let b:easytags_updatetime_skip = 5
+ endtry
+ endif
+
+ " Have we waited enough times?
+ if b:easytags_updatetime_skipped < b:easytags_updatetime_skip
+ let b:easytags_updatetime_skipped += 1
+ if xolox#misc#option#get('easytags_updatetime_autoadjust_warning', 1)
+ call xolox#misc#msg#warn("easytags.vim %s: [%s] Delaying update to better match easytags_updatetime_min (%i) [#%i/%i] (Set easytags_updatetime_autoadjust_warning=0 to hide this message)", g:xolox#easytags#version, expand('%'), &updatetime, b:easytags_updatetime_skipped, b:easytags_updatetime_skip)
+ endif
+ return
+ endif
+ else
+
+ call xolox#misc#msg#warn("easytags.vim %s: I'm being executed every %i milliseconds! Please :set updatetime=%i. To find where 'updatetime' was changed execute ':verb set ut?'", g:xolox#easytags#version, &updatetime, updatetime_min)
+
+ endif
+
endif
endif
endif
+ if exists('b:easytags_updatetime_skip')
+ if xolox#misc#option#get('easytags_updatetime_autoadjust_warning', 1)
+ call xolox#misc#msg#warn("easytags.vim %s: [%s] Done waiting to match VIM updatetime. Will update for real", g:xolox#easytags#version, expand('%'))
+ endif
+ " Reset counters, we're done waiting for now
+ unlet b:easytags_updatetime_skipped
+ unlet b:easytags_updatetime_skip
+ endif
let do_update = xolox#misc#option#get('easytags_auto_update', 1)
let do_highlight = xolox#misc#option#get('easytags_auto_highlight', 1) && &eventignore !~? '\<syntax\>'
" Don't execute this function for unsupported file types (doesn't load
I commited a pull request #42.
Hi Jonas and Kim! As mentioned in the other issues / pull requests this should since have been fixed, so I'm closing this issue now.
Hi,
python-mode sets the update time to 1000 (1ms). Now I get all sorts of warnings from easytags. Sure I can adjust g:easytags_updatetime_min, but the help says that might break the plugin.
Since easytags is already noticing this, why don't you implement a workaround. I.e. you can check how often you are updated and only perform the actual work every n-th time (where n=g:easytags_updatetime_min/update_time)?
Regards Jonas