From 27c29aa6a6b558b2f917a0c661fb4804bcdeb05e Mon Sep 17 00:00:00 2001
From: Peter Odding <peter@peterodding.com>
Date: Sun, 22 Jun 2014 03:22:36 +0200
Subject: Support for synchronous + asynchronous tags file updates (huge
 refactoring)

See also pull request #49 for my previous and failed attempt:
  https://github.com/xolox/vim-easytags/pull/49
---
 plugin/easytags.vim | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

(limited to 'plugin')

diff --git a/plugin/easytags.vim b/plugin/easytags.vim
index 5b22d23..a20b85c 100644
--- a/plugin/easytags.vim
+++ b/plugin/easytags.vim
@@ -1,6 +1,6 @@
 " Vim plug-in
 " Author: Peter Odding <peter@peterodding.com>
-" Last Change: August 19, 2013
+" Last Change: June 22, 2014
 " URL: http://peterodding.com/code/vim/easytags/
 " Requires: Exuberant Ctags (http://ctags.sf.net)
 
@@ -41,12 +41,12 @@ if !exists('g:easytags_by_filetype')
 endif
 
 if !exists('g:easytags_events')
-  let g:easytags_events = []
+  let g:easytags_events = ['BufWritePost']
   if !exists('g:easytags_on_cursorhold') || g:easytags_on_cursorhold
     call extend(g:easytags_events, ['CursorHold', 'CursorHoldI'])
   endif
   if exists('g:easytags_always_enabled') && g:easytags_always_enabled
-    call extend(g:easytags_events, ['BufReadPost', 'BufWritePost', 'FocusGained', 'ShellCmdPost', 'ShellFilterPost'])
+    call extend(g:easytags_events, ['BufReadPost', 'FocusGained', 'ShellCmdPost', 'ShellFilterPost'])
   endif
 endif
 
@@ -99,7 +99,7 @@ call xolox#easytags#register(1)
 
 command! -bar -bang -nargs=* -complete=file UpdateTags call xolox#easytags#update(0, <q-bang> == '!', [<f-args>])
 command! -bar HighlightTags call xolox#easytags#highlight()
-command! -bang TagsByFileType call xolox#easytags#by_filetype(<q-bang> == '!')
+command! -bang TagsByFileType call xolox#easytags#update#convert_by_filetype(<q-bang> == '!')
 
 " Automatic commands. {{{1
 
@@ -111,7 +111,9 @@ augroup PluginEasyTags
   autocmd VimEnter * call xolox#easytags#register(1)
   " Define the automatic commands to perform updating/highlighting.
   for s:eventname in g:easytags_events
-    execute 'autocmd' s:eventname '* call xolox#easytags#autoload(' string(s:eventname) ')'
+    if s:eventname !~? 'cursorhold'
+      execute 'autocmd' s:eventname '* call xolox#easytags#autoload(' string(s:eventname) ')'
+    endif
   endfor
   " Define an automatic command to register file type specific tags files?
   if !empty(g:easytags_by_filetype)
@@ -122,6 +124,13 @@ augroup PluginEasyTags
   autocmd BufReadPost * unlet! b:easytags_last_highlighted
 augroup END
 
+" Use vim-misc to register an event handler for Vim's CursorHold and
+" CursorHoldI events which is rate limited so that our event handler is never
+" called more than once every interval.
+if index(g:easytags_events, 'CursorHold') >= 0
+  call xolox#misc#cursorhold#register({'function': 'xolox#easytags#autoload', 'arguments': ['CursorHold'], 'interval': xolox#misc#option#get('easytags_updatetime_min', 4000)/1000})
+endif
+
 " }}}1
 
 " Make sure the plug-in is only loaded once.
-- 
cgit v1.2.3


From 6c7a66349ec7c1c92cb5f77afd44330189815d46 Mon Sep 17 00:00:00 2001
From: Peter Odding <peter@peterodding.com>
Date: Sun, 29 Jun 2014 19:54:08 +0200
Subject: Disable automatic tags file updates during :vimgrep

This change is related to pull request #83 however that pull request
wasn't merged here (and won't be merged at all) because it was based on
the old/dead `async-cleanup' feature branch (see pull request #49 on
GitHub) instead of the new `async-take-two' feature branch (see pull
request #84 on GitHub). This change set implements the equivalent on the
new feature branch (without introducing another option).
---
 plugin/easytags.vim | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

(limited to 'plugin')

diff --git a/plugin/easytags.vim b/plugin/easytags.vim
index a20b85c..4da7962 100644
--- a/plugin/easytags.vim
+++ b/plugin/easytags.vim
@@ -1,6 +1,6 @@
 " Vim plug-in
 " Author: Peter Odding <peter@peterodding.com>
-" Last Change: June 22, 2014
+" Last Change: June 29, 2014
 " URL: http://peterodding.com/code/vim/easytags/
 " Requires: Exuberant Ctags (http://ctags.sf.net)
 
@@ -122,6 +122,11 @@ augroup PluginEasyTags
   " After reloading a buffer the dynamic syntax highlighting is lost. The
   " following code makes sure the highlighting is refreshed afterwards.
   autocmd BufReadPost * unlet! b:easytags_last_highlighted
+  " During :vimgrep each searched buffer triggers an asynchronous tags file
+  " update resulting in races for the tags file. To avoid this we temporarily
+  " disable automatic tags file updates during :vimgrep.
+  "autocmd QuickFixCmdPre *vimgrep* call xolox#easytags#disable_automatic_updates()
+  "autocmd QuickFixCmdPost *vimgrep* call xolox#easytags#restore_automatic_updates()
 augroup END
 
 " Use vim-misc to register an event handler for Vim's CursorHold and
-- 
cgit v1.2.3


From f651375c7333efda6a768472e1a804f20fa69115 Mon Sep 17 00:00:00 2001
From: Peter Odding <peter@peterodding.com>
Date: Sun, 29 Jun 2014 21:44:34 +0200
Subject: Actually enable the automatic commands introduced in 6c7a66349ec :-)

---
 plugin/easytags.vim | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'plugin')

diff --git a/plugin/easytags.vim b/plugin/easytags.vim
index 4da7962..324fa81 100644
--- a/plugin/easytags.vim
+++ b/plugin/easytags.vim
@@ -125,8 +125,8 @@ augroup PluginEasyTags
   " During :vimgrep each searched buffer triggers an asynchronous tags file
   " update resulting in races for the tags file. To avoid this we temporarily
   " disable automatic tags file updates during :vimgrep.
-  "autocmd QuickFixCmdPre *vimgrep* call xolox#easytags#disable_automatic_updates()
-  "autocmd QuickFixCmdPost *vimgrep* call xolox#easytags#restore_automatic_updates()
+  autocmd QuickFixCmdPre *vimgrep* call xolox#easytags#disable_automatic_updates()
+  autocmd QuickFixCmdPost *vimgrep* call xolox#easytags#restore_automatic_updates()
 augroup END
 
 " Use vim-misc to register an event handler for Vim's CursorHold and
-- 
cgit v1.2.3