emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Eric Schulte" <schulte.eric@gmail.com>
To: Paul Sexton <psexton@xnet.co.nz>
Cc: emacs-orgmode@gnu.org
Subject: Re: Babel: replace inline block with evaluation result?
Date: Thu, 13 Jan 2011 14:21:34 -0700	[thread overview]
Message-ID: <87ipxsa45g.fsf@gmail.com> (raw)
In-Reply-To: loom.20110113T203704-955@post.gmane.org

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

  reply	other threads:[~2011-01-13 21:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-13 19:50 Babel: replace inline block with evaluation result? Paul Sexton
2011-01-13 21:21 ` Eric Schulte [this message]
2011-01-13 22:38   ` Paul Sexton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ipxsa45g.fsf@gmail.com \
    --to=schulte.eric@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=psexton@xnet.co.nz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).