From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: Re: Babel: replace inline block with evaluation result? Date: Thu, 13 Jan 2011 14:21:34 -0700 Message-ID: <87ipxsa45g.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from [140.186.70.92] (port=33242 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PdUec-0004T2-6n for emacs-orgmode@gnu.org; Thu, 13 Jan 2011 16:24:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PdUea-0002Iu-7Y for emacs-orgmode@gnu.org; Thu, 13 Jan 2011 16:24:22 -0500 Received: from mail-pv0-f169.google.com ([74.125.83.169]:56713) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PdUeZ-0002IX-VE for emacs-orgmode@gnu.org; Thu, 13 Jan 2011 16:24:20 -0500 Received: by pvc30 with SMTP id 30so425566pvc.0 for ; Thu, 13 Jan 2011 13:24:19 -0800 (PST) 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: Paul Sexton Cc: emacs-orgmode@gnu.org Paul Sexton writes: > I have an org-mode document that uses a lot of R code (via babel). I have found > that using inline code blocks, ie src_R{...}, within org tables works > "erratically", often either causing emacs to hang during latex export, or > producing a table where random cells containing 'nil' instead of the result I > get when I manually evaluate the inline code block via C-c C-c. > If you can find a minimal example which reliably reproduces this error please do share it on the list so we can try to put together a fix. > > I am therefore in the process of converting many of these tables back to 'plain' > org, ie replacing the inline code blocks with their results. > I guess the only other option may be to create the entire table from a code block, which is probably not practical. > > My question is: is there any way to automate this? Ideally I would like to press > a key with the cursor on an inline block, and have the block replaced with its > eval result, rather than have the result appear in the minibuffer. > The following function could be bound to a key, and should do the job if called with the point on the src_lang portion of the inline code block. #+begin_src emacs-lisp (defun replace-inline-block () (interactive) (if (save-excursion (re-search-backward "[ \f\t\n\r\v]" nil t) (looking-at org-babel-inline-src-block-regexp)) (replace-match ((lambda (el) (if (stringp el) el (format "%S" el))) (org-babel-execute-src-block)) nil nil nil 1) (error "not inside of an inline source block."))) #+end_src Cheers -- Eric > > Paul > > > > _______________________________________________ > Emacs-orgmode mailing list > Please use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode