On 01.06.2011 13:19, Oleksandr Gavenko wrote:
I need use auto update for GNU Global:
$ global -u
There described how this done:
http://www.emacswiki.org/emacs/GnuGlobal
But this:
(defun gtags-root-dir ()
"Returns GTAGS root directory or nil if doesn't exist."
(with-temp-buffer
(if (zerop (call-process "global" nil t nil "-pr"))
(buffer-substring (point-min) (1- (point-max)))
nil)))
(defun gtags-update ()
"Make GTAGS incremental update"
(call-process "global" nil nil nil "-u"))
(defun gtags-update-hook ()
(when (gtags-root-dir)
(gtags-update)))
(add-hook 'after-save-hook #'gtags-update-hook)
cause freezing Emacs for about 2-3 sec. How run this in background
so I can still complete Emacs editing?
Write sh script and start-process-shell-command for asynchronous job?
I write:
(defun gtags-update ()
(start-process-shell-command "/bin/sh" nil "if global -pr; then
global -u; fi")
)
(add-hook 'after-save-hook #'gtags-update)
; (remove-hook 'after-save-hook #'gtags-update)
Seems this help but how in general case when I need run elisp code
in background (synchronization issue is not essential).