From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: asynchronous code evaluation Date: Fri, 06 Sep 2013 11:54:56 -0600 Message-ID: <87a9jpq1hr.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51280) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VI0F5-0008IT-2L for emacs-orgmode@gnu.org; Fri, 06 Sep 2013 13:54:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VI0Ez-0004ab-U5 for emacs-orgmode@gnu.org; Fri, 06 Sep 2013 13:54:47 -0400 Received: from mail-pd0-x229.google.com ([2607:f8b0:400e:c02::229]:36579) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VI0Ez-0004aO-MO for emacs-orgmode@gnu.org; Fri, 06 Sep 2013 13:54:41 -0400 Received: by mail-pd0-f169.google.com with SMTP id r10so3572566pdi.0 for ; Fri, 06 Sep 2013 10:54:40 -0700 (PDT) In-Reply-To: (Johannes Rainer's message of "Wed, 4 Sep 2013 07:27:01 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Johannes Rainer Cc: emacs-orgmode@gnu.org Johannes Rainer writes: > hi all! > > I have some pretty calculation intense R code in a code block and when I > execute the code (C-c C-c) my emacs freezes and waits for the code to > finish. Is there a way to evaluate the code asynchronously, so that I could > edit the file (obviously not the code block itself) while the code is being > evaluated? > Hi Jo, This is not currently possible, but it would certainly be a nice feature and is something that has been requested before. This would require some general Org-mode support before any language specific code is written (ideally no language specific code would be required). For anyone who feels like tackling such a project the first step would be to look at `org-babel-comint-with-output' and `org-babel-eval'. I'm not sure what the best way is to wait until the external process returns to handle the code block results, I'd guess we'd either want to pass closures to those functions, or somehow yield while the external process runs. Some careful thought of the ramifications of asynchronous code block evaluation may be required. E.g., would every piece of code which calls a code block (from "C-c C-c" to :var resolution) need to be updated to call the code block in an asynchronous manner? Best, -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D