From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jambunathan K Subject: Re: Using babel to generate a commit log Date: Wed, 30 Mar 2011 11:56:37 +0530 Message-ID: <814o6l9l9e.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from [140.186.70.92] (port=35344 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q4orl-0003hW-AP for emacs-orgmode@gnu.org; Wed, 30 Mar 2011 02:26:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q4ork-0008TU-0F for emacs-orgmode@gnu.org; Wed, 30 Mar 2011 02:26:53 -0400 Received: from mail-iw0-f169.google.com ([209.85.214.169]:62107) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q4orj-0008TI-TI for emacs-orgmode@gnu.org; Wed, 30 Mar 2011 02:26:51 -0400 Received: by iwg8 with SMTP id 8so1185026iwg.0 for ; Tue, 29 Mar 2011 23:26:51 -0700 (PDT) In-Reply-To: (Luke Crook's message of "Wed, 30 Mar 2011 05:38:41 +0000 (UTC)") 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: emacs-orgmode@gnu.org Luke Crook writes: > I have written the following code that uses the Emacs vc-* commands to generate > a commit log. I would like the output of this code to be included when my file > is exported. > > #+begin_src emacs-lisp :var limit="" > ;; 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 > (vc-call-backend backend > 'print-log > files > (current-buffer)) > (sit-for 5 t) > (buffer-string)))) > #+end_src > > What is happening is; > > 1) The code between #+begin_src and #+end_src is exported and not the result > of evaluating the code (the commit log). > 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. > > How can I fix (1). > > 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. ,----[ C-h f vc-do-command RET ] | vc-do-command is an autoloaded Lisp function in `vc-dispatcher.el'. | | (vc-do-command BUFFER OKSTATUS COMMAND FILE-OR-LIST &rest FLAGS) | | Execute a slave command, notifying user and checking for errors. | Output from COMMAND goes to BUFFER, or the current buffer if | BUFFER is t. If the destination buffer is not already current, | set it up properly and erase it. The command is considered | successful if its exit status does not exceed OKSTATUS (if | OKSTATUS is nil, that means to ignore error status, if it is | `async', that means not to wait for termination of the | subprocess; if it is t it means to ignore all execution errors). | FILE-OR-LIST is the name of a working file; it may be a list of | files or be nil (to execute commands that don't expect a file | name or set of files). If an optional list of FLAGS is present, | that is inserted into the command line before the filename. | Return the return value of the slave command in the synchronous | case, and the process object in the asynchronous case. | | [back] `---- ,----[ C-h v vc-disable-async-diff RET ] | vc-disable-async-diff is a variable defined in `vc.el'. | Its value is nil | | Documentation: | VC sets this to t locally to disable some async diff operations. | Backends that offer asynchronous diffs should respect this variable | in their implementation of vc-BACKEND-diff. | | [back] `---- > > Thanks, > -Luke > > > > --