[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Run function in background.

From: Oleksandr Gavenko
Subject: Re: Run function in background.
Date: Wed, 01 Jun 2011 13:40:19 +0300
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20110414 Thunderbird/3.1.10

On 01.06.2011 13:19, Oleksandr Gavenko wrote:
I need use auto update for GNU Global:

$ global -u

There described how this done:

But this:

(defun gtags-root-dir ()
"Returns GTAGS root directory or nil if doesn't exist."
(if (zerop (call-process "global" nil t nil "-pr"))
(buffer-substring (point-min) (1- (point-max)))

(defun gtags-update ()
"Make GTAGS incremental update"
(call-process "global" nil nil nil "-u"))

(defun gtags-update-hook ()
(when (gtags-root-dir)

(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).

reply via email to

[Prev in Thread] Current Thread [Next in Thread]