From: Eric Schulte <schulte.eric@gmail.com>
To: Rainer M Krug <Rainer@krugs.de>
Cc: emacs-orgmode@gnu.org, Charles Berry <ccberry@ucsd.edu>
Subject: Re: [BABEL] BUG Re: Omitting try/catch blocks from tangled R code?
Date: Sun, 30 Mar 2014 08:19:37 -0600 [thread overview]
Message-ID: <87fvlzg45i.fsf@gmail.com> (raw)
In-Reply-To: <m2bnwqvh8i.fsf@krugs.de> (Rainer M. Krug's message of "Fri, 28 Mar 2014 09:51:09 +0100")
[-- Attachment #1: Type: text/plain, Size: 921 bytes --]
>
> Apologies - I am still struggling with encryption......
>
> So here is my example:
>
> --8<---------------cut here---------------start------------->8---
> #+TITLE: single_to_multi
> #+DATE: <2013-10-15 Tue>
> #+AUTHOR: Rainer M. Krug
> #+EMAIL: Rainer@krugs.de
>
> ≈* Load R packages and data
> #+BEGIN_SRC R
> cat("Loading Data\n")
> #+END_SRC
> --8<---------------cut here---------------end--------------->8---
>
> I am using only org loaded and R enabled.
>
> C-c C-c on the block produces the error
>
> emacs version:
> GNU Emacs 24.3.1 (x86_64-apple-darwin13.0.0, Carbon Version 1.6.0
> AppKit 1265) of 2014-02-13 on Rainers-MacBook-Pro-2.local
>
> org version:
> Org-mode version 8.2.5h (release_8.2.5h-837-gb296cc @
> /Users/rainerkrug/.emacs.d/org-mode/lisp/)
>
Thanks, a fixed version of the patch is attached. If this works please
let me know and I'll apply.
Best,
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-only-wrap-R-code-graphics-file-on-execution.patch --]
[-- Type: text/x-diff, Size: 2788 bytes --]
From d67248db79faf19e1bdcac0230c37670b6115bdd Mon Sep 17 00:00:00 2001
From: Eric Schulte <schulte.eric@gmail.com>
Date: Sun, 23 Mar 2014 20:01:37 -0600
Subject: [PATCH] only wrap R code graphics-file on execution
Move this out of the expand-body function so that it is *never*
applied to tangled code.
---
lisp/ob-R.el | 40 +++++++++++++++++++++-------------------
1 file changed, 21 insertions(+), 19 deletions(-)
diff --git a/lisp/ob-R.el b/lisp/ob-R.el
index 62aa7f2..780d99f 100644
--- a/lisp/ob-R.el
+++ b/lisp/ob-R.el
@@ -97,24 +97,15 @@ this variable.")
"Expand BODY according to PARAMS, return the expanded body."
(let ((graphics-file
(or graphics-file (org-babel-R-graphical-output-file params))))
- (mapconcat
- #'identity
- (let ((inside
- (append
- (when (cdr (assoc :prologue params))
- (list (cdr (assoc :prologue params))))
- (org-babel-variable-assignments:R params)
- (list body)
- (when (cdr (assoc :epilogue params))
- (list (cdr (assoc :epilogue params)))))))
- (if graphics-file
- (append
- (list (org-babel-R-construct-graphics-device-call
- graphics-file params))
- inside
- (list "},error=function(e){plot(x=-1:1, y=-1:1, type='n', xlab='', ylab='', axes=FALSE); text(x=0, y=0, labels=e$message, col='red'); paste('ERROR', e$message, sep=' : ')}); dev.off()"))
- inside))
- "\n")))
+ (mapconcat #'identity
+ (append
+ (when (cdr (assoc :prologue params))
+ (list (cdr (assoc :prologue params))))
+ (org-babel-variable-assignments:R params)
+ (list body)
+ (when (cdr (assoc :epilogue params))
+ (list (cdr (assoc :epilogue params)))))
+ "\n")))
(defun org-babel-execute:R (body params)
"Execute a block of R code.
@@ -127,7 +118,18 @@ This function is called by `org-babel-execute-src-block'."
(colnames-p (cdr (assoc :colnames params)))
(rownames-p (cdr (assoc :rownames params)))
(graphics-file (org-babel-R-graphical-output-file params))
- (full-body (org-babel-expand-body:R body params graphics-file))
+ (full-body
+ (let ((inside
+ (list (org-babel-expand-body:R body params graphics-file))))
+ (mapconcat #'identity
+ (if graphics-file
+ (append
+ (list (org-babel-R-construct-graphics-device-call
+ graphics-file params))
+ inside
+ (list "},error=function(e){plot(x=-1:1, y=-1:1, type='n', xlab='', ylab='', axes=FALSE); text(x=0, y=0, labels=e$message, col='red'); paste('ERROR', e$message, sep=' : ')}); dev.off()"))
+ inside)
+ "\n")))
(result
(org-babel-R-evaluate
session full-body result-type result-params
--
1.9.1
[-- Attachment #3: Type: text/plain, Size: 63 bytes --]
--
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D
next prev parent reply other threads:[~2014-03-30 14:19 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-07 6:18 Omitting try/catch blocks from tangled R code? John Hendy
2014-02-07 8:26 ` [BABEL] BUG " Rainer M Krug
2014-02-07 16:47 ` Eric Schulte
2014-02-07 19:22 ` Rainer M Krug
2014-03-12 1:13 ` John Hendy
2014-03-17 15:00 ` Eric Schulte
2014-03-17 17:11 ` John Hendy
2014-03-17 17:44 ` Eric Schulte
2014-03-18 8:44 ` Rainer M Krug
2014-03-18 21:56 ` John Hendy
2014-03-19 19:07 ` Charles Berry
2014-03-20 4:57 ` Eric Schulte
2014-03-20 9:22 ` Rainer M Krug
2014-03-24 2:03 ` Eric Schulte
2014-03-24 10:22 ` Rainer M Krug
2014-03-24 13:16 ` Eric Schulte
2014-03-25 9:37 ` Rainer M Krug
2014-03-26 20:17 ` Eric Schulte
2014-03-28 8:32 ` Rainer M Krug
2014-03-28 8:51 ` Rainer M Krug
2014-03-30 14:19 ` Eric Schulte [this message]
2014-03-31 7:52 ` Rainer M Krug
2014-04-02 23:09 ` Eric Schulte
2014-04-07 7:59 ` Rainer M Krug
2014-04-11 2:35 ` Eric Schulte
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=87fvlzg45i.fsf@gmail.com \
--to=schulte.eric@gmail.com \
--cc=Rainer@krugs.de \
--cc=ccberry@ucsd.edu \
--cc=emacs-orgmode@gnu.org \
/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).