Updating GNU Global GTAGS file when Emacs is idle

GNU Global is a very useful code navigation tool. In order for it to work well, it needs to be run regularly. Until now, I used the after-save-hook, to keep it up to date. However, when using emacs-eclim (also see Eclim), saving becomes so frequent that performance takes a massive hit. So I whipped up this small code snippet to run Global only when Emacs is idle for some number of seconds (default is 10):

(defcustom my-gtags-update-idle-time 10
"Number of idle seconds before an incremental gtags update is launched"
:group 'my-group ;; Put whatever customization group you like here
:type 'integer
(run-with-idle-timer my-gtags-update-idle-time t
(lambda ()
(if (not (minibufferp) )
(message "Running gtags...")

Leave a Reply

Your email address will not be published.