emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Charles Berry <ccberry@ucsd.edu>
To: emacs-orgmode@gnu.org
Subject: Re: [PATCH] -for review- Tangling with variable transfer of variables
Date: Thu, 19 Jun 2014 23:23:56 +0000 (UTC)	[thread overview]
Message-ID: <loom.20140620T002034-706@post.gmane.org> (raw)
In-Reply-To: 87zjh8bo8s.fsf@gmail.com

Aaron Ecay <aaronecay <at> gmail.com> writes:

> 
> Hi Rainer,
> 
> I have not tested the patch (I rarely use :var), but here are some
> comments from reading the patch.
> 
[snip]
> 
> >  	      (header (if (or (eq (nth 1 value) 'hline) colnames-p)
> >  			  "TRUE" "FALSE"))
> >  	      (row-names (if rownames-p "1" "NULL")))
> >  	  (if (= max min)
> > -	      (format "%s <- read.table(\"%s\",
> > +	      (format "%s <- read.table(textConnection('%s'),
> 
> This will fail if ‘file’ contains an apostrophe character.  I guess you
> need to escape apostrophes in ‘file’.
> 

There are a bunch of issues with the textConnection - the point Aaron
makes, the nasty name (try showConnections() to see), and close()-ing it.

I think you need something more like this:

====
                 (header (if (or (eq (nth 1 value) 'hline) colnames-p)
                              "TRUE" "FALSE"))
                  (row-names (if rownames-p "1" "NULL")))
              (if (= max min)
                  (format "
    %s <- 
        local({con.object <- 
    %S
    con <- textConnection(con.object)
    res <- read.table(con,
                      header=%s,
                      row.names=%s,
                      sep=\"\\t\",
                      as.is=TRUE)
    close(con)
    res})" 
                  name file header row-names)

====

Notes: %S handles Aaron's quoting issue.
       local() keeps unwanted objects out of user's way.
       This worked on a couple of simple tests

If you have `:session :results output' headers your session
transcript will have `file' dumped into it, which might be an annoyance.

HTH,

Chuck

  reply	other threads:[~2014-06-19 23:24 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-19 20:19 [PATCH] -for review- Tangling with variable transfer of variables Rainer M Krug
2014-06-19 21:09 ` Aaron Ecay
2014-06-19 23:23   ` Charles Berry [this message]
2014-06-20 13:15     ` Rainer M Krug
2014-06-20 20:34       ` Rainer M Krug
2014-06-21 19:44         ` Charles C. Berry
2014-06-22  3:39           ` Aaron Ecay
2014-06-23 10:46             ` Rainer M Krug
2014-06-23  8:57           ` Rainer M Krug
2014-06-23  9:14           ` Rainer M Krug
2014-06-23 17:56             ` Charles C. Berry
2014-06-24 12:08               ` Rainer M Krug
2014-06-23 10:45           ` Rainer M Krug
2014-06-23 18:25             ` Charles C. Berry
2014-06-24 12:28               ` Rainer M Krug
2014-06-20 13:07   ` Rainer M Krug

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=loom.20140620T002034-706@post.gmane.org \
    --to=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).