From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Oleksandr Gavenko Newsgroups: gmane.emacs.help Subject: Re: Run function in background. Date: Wed, 01 Jun 2011 13:40:19 +0300 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1306924911 30775 80.91.229.12 (1 Jun 2011 10:41:51 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 1 Jun 2011 10:41:51 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jun 01 12:41:46 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QRiry-00083B-ND for geh-help-gnu-emacs@m.gmane.org; Wed, 01 Jun 2011 12:41:46 +0200 Original-Received: from localhost ([::1]:40392 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QRirx-0007fP-GP for geh-help-gnu-emacs@m.gmane.org; Wed, 01 Jun 2011 06:41:45 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:55383) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QRiqh-0007fB-2n for help-gnu-emacs@gnu.org; Wed, 01 Jun 2011 06:40:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QRiqf-0000Ok-Qh for help-gnu-emacs@gnu.org; Wed, 01 Jun 2011 06:40:27 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:47405) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QRiqf-0000OU-KI for help-gnu-emacs@gnu.org; Wed, 01 Jun 2011 06:40:25 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1QRiqe-0007QM-Ff for help-gnu-emacs@gnu.org; Wed, 01 Jun 2011 12:40:24 +0200 Original-Received: from 91.193.68.214 ([91.193.68.214]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 01 Jun 2011 12:40:24 +0200 Original-Received: from gavenko by 91.193.68.214 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 01 Jun 2011 12:40:24 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 45 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 91.193.68.214 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 80.91.229.12 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org X-Spam-Report: 5.4 points; * -0.0 SPF_PASS SPF: sender matches SPF record * 4.0 RCVD_NUMERIC_HELO Received: contains an IP address used for HELO * -2.6 BAYES_00 BODY: Bayesian spam probability is 0 to 1% * [score: 0.0000] * 4.0 RCVD_IN_SBL RBL: Received via a relay in Spamhaus SBL * [91.193.68.214 listed in zen.spamhaus.org] Xref: news.gmane.org gmane.emacs.help:81272 Archived-At: 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).