Luke Crook <l...@balooga.com> wrote: > Jambunathan K <kjambunathan <at> gmail.com> writes: > > > > > Luke Crook <luke <at> 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