* Babel: replace inline block with evaluation result?
@ 2011-01-13 19:50 Paul Sexton
2011-01-13 21:21 ` Eric Schulte
0 siblings, 1 reply; 3+ messages in thread
From: Paul Sexton @ 2011-01-13 19:50 UTC (permalink / raw)
To: emacs-orgmode
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.
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.
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.
Paul
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Babel: replace inline block with evaluation result?
2011-01-13 19:50 Babel: replace inline block with evaluation result? Paul Sexton
@ 2011-01-13 21:21 ` Eric Schulte
2011-01-13 22:38 ` Paul Sexton
0 siblings, 1 reply; 3+ messages in thread
From: Eric Schulte @ 2011-01-13 21:21 UTC (permalink / raw)
To: Paul Sexton; +Cc: emacs-orgmode
Paul Sexton <psexton@xnet.co.nz> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Babel: replace inline block with evaluation result?
2011-01-13 21:21 ` Eric Schulte
@ 2011-01-13 22:38 ` Paul Sexton
0 siblings, 0 replies; 3+ messages in thread
From: Paul Sexton @ 2011-01-13 22:38 UTC (permalink / raw)
To: emacs-orgmode
Eric Schulte <schulte.eric <at> gmail.com> writes:
>
> 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.
>
[snip - gmane web-thingy won't let me quote the function]
Thanks Eric!
I will try to come up with a minimal example of the error I talked
about.
Paul
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-01-13 22:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-13 19:50 Babel: replace inline block with evaluation result? Paul Sexton
2011-01-13 21:21 ` Eric Schulte
2011-01-13 22:38 ` Paul Sexton
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).