From mboxrd@z Thu Jan 1 00:00:00 1970 From: Charles Berry Subject: Re: [PATCH] -for review- Tangling with variable transfer of variables Date: Thu, 19 Jun 2014 23:23:56 +0000 (UTC) Message-ID: References: <87zjh8bo8s.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38823) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wxlgo-0004IK-Mq for emacs-orgmode@gnu.org; Thu, 19 Jun 2014 19:24:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wxlgh-0006Py-6G for emacs-orgmode@gnu.org; Thu, 19 Jun 2014 19:24:18 -0400 Received: from plane.gmane.org ([80.91.229.3]:39771) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wxlgh-0006Pu-0G for emacs-orgmode@gnu.org; Thu, 19 Jun 2014 19:24:11 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Wxlgf-0001dG-FV for emacs-orgmode@gnu.org; Fri, 20 Jun 2014 01:24:09 +0200 Received: from 137.110.38.64 ([137.110.38.64]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 20 Jun 2014 01:24:09 +0200 Received: from ccberry by 137.110.38.64 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 20 Jun 2014 01:24:09 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Aaron Ecay 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