From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: Re: Using babel to generate a commit log Date: Wed, 30 Mar 2011 09:43:16 -0400 Message-ID: <8526.1301492596@alphaville.dokosmarshall.org> References: <814o6l9l9e.fsf@gmail.com> Reply-To: nicholas.dokos@hp.com Return-path: Received: from [140.186.70.92] (port=39803 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q4vgU-0007gk-8K for emacs-orgmode@gnu.org; Wed, 30 Mar 2011 09:43:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q4vgO-0002RD-6L for emacs-orgmode@gnu.org; Wed, 30 Mar 2011 09:43:41 -0400 Received: from vms173001pub.verizon.net ([206.46.173.1]:42562) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q4vgO-0002Qe-1j for emacs-orgmode@gnu.org; Wed, 30 Mar 2011 09:43:36 -0400 Received: from alphaville.dokosmarshall.org ([unknown] [173.76.32.106]) by vms173001.mailsrvcs.net (Sun Java(tm) System Messaging Server 7u2-7.02 32bit (built Apr 16 2009)) with ESMTPA id <0LIV00MR1I44R750@vms173001.mailsrvcs.net> for emacs-orgmode@gnu.org; Wed, 30 Mar 2011 08:43:22 -0500 (CDT) In-reply-to: Message from Luke Crook of "Wed, 30 Mar 2011 07:57:03 -0000." List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Luke Crook Cc: nicholas.dokos@hp.com, emacs-orgmode@gnu.org Luke Crook wrote: > Jambunathan K gmail.com> writes: > > > > > Luke Crook balooga.com> writes: > > > > > 2) I have to add at delay of at least 5 seconds (set-for 5 t) as vc-git > calls > > > "git log" as an asynchronous process. If not for the delay then babel > > > immediately returns an empty buffer and the "vc-call-backend" process never > > > completes. > > > > > > Is there a better way that I can accomplish (2) ? > > > > Quick hints if you are willing to settle for some hacks. > > > > In vc-do-command, you may have to set OKSTATUS to 0. Track > > `vc-disable-async-diff' in vc.el and vc-svn.el for possible hints. > > > > I changed my code to wait until the 'Git' process completes. Luckily "vc-call- > backend" returns the async process. > Oh, I missed that - thanks for pointing it out. > #+begin_src emacs-lisp :var limit="" :file test.log :exports results > ;; Most of this code is copied from vc.el vc-print-log > (when (vc-find-backend-function (vc-backend (buffer-file-name (current-buffer))) > 'print-log) > (let* ((limit (if (numberp limit) limit vc-log-show-limit)) > (vc-fileset (vc-deduce-fileset t)) ;FIXME: Why t? --Stef > (backend (car vc-fileset)) > (files (cadr vc-fileset))) > (with-temp-buffer > (let ((status (vc-call-backend backend > 'print-log > files > (current-buffer)))) > (while (not (eq 'exit (process-status status))) > (sit-for 1 t)) > (buffer-string))))) > #+end_src > ... or you could use a sentinel :-) One bit of defensive programming might be to check that status *is* a process before you do the wait: vc-do-command returns a real status in the synchronous case, so if you cut-n-paste this code with some other command that does not use async, it'll blow up. Nick