emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] Babel: replace inline block with evaluation result?


From: Eric Schulte
Subject: Re: [Orgmode] Babel: replace inline block with evaluation result?
Date: Thu, 13 Jan 2011 14:21:34 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Paul Sexton <address@hidden> 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.
> address@hidden
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode



reply via email to

[Prev in Thread] Current Thread [Next in Thread]