From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aaron Ecay Subject: Re: org tables into R? Date: Mon, 05 Jan 2015 23:27:38 -0500 Message-ID: <87r3v8v8hx.fsf@gmail.com> References: <874ms6w0it.fsf@gmail.com> <87zj9xa1ni.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46498) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y8Lk9-0001UQ-H1 for emacs-orgmode@gnu.org; Mon, 05 Jan 2015 23:27:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y8Lk5-000811-Eh for emacs-orgmode@gnu.org; Mon, 05 Jan 2015 23:27:45 -0500 Received: from mail-qc0-x22b.google.com ([2607:f8b0:400d:c01::22b]:49138) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y8Lk5-00080w-9N for emacs-orgmode@gnu.org; Mon, 05 Jan 2015 23:27:41 -0500 Received: by mail-qc0-f171.google.com with SMTP id r5so16693324qcx.30 for ; Mon, 05 Jan 2015 20:27:40 -0800 (PST) In-Reply-To: <87zj9xa1ni.fsf@nicolasgoaziou.fr> 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: Nicolas Goaziou Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Nicolas, 2015ko urtarrilak 5an, Nicolas Goaziou-ek idatzi zuen: >=20 > Hello, >=20 > Aaron Ecay writes: >=20 >> Recently(-ish), Nicolas updated the org-table functions to use the >> export framework. One of the drawbacks of this approach (as you have >> brought to our attention) is that export filters are invoked. This >> should probably be disabled. >=20 > Indeed. I removed user-defined filters and hooks. Thank you. >=20 >> Another drawback is the detection of unexpanded macros (which will be >> triggered e.g. if a tabular babel result has macro-like {{{text}}} in >> it). A proof-of-concept patch for this is attached. >=20 > I don't think it needs to be fixed: macro would then be silently > dropped, which is a step backwards.=20 You are correct about the silent dropping of macro-like text. However, with current master that case gives an undefined macro error, which is even worse. Try this (in emacs -Q with org and ESS in the load-path) to see it: #+name: foo #+begin_src R c("foo","{{{bar}}}") #+end_src > OTOH "ob-R.el" should consider using ":raw t" parameter for its table > conversion function. I think :raw is needed in =E2=80=98org-babel-insert-result=E2=80=99 in addi= tion to my previous patch. New patch attached. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-babel-fix-macros-in-tabular-output.patch >From 4d2985ba88d2ba0c35ff715a7285469e8040d4b0 Mon Sep 17 00:00:00 2001 From: Aaron Ecay Date: Sun, 4 Jan 2015 18:14:26 -0500 Subject: [PATCH] [babel] fix macros in tabular output * lisp/ox.el (org-export-as): Support :sloppy-macros plist entry. * lisp/org-table.el (orgtbl-to-generic): Use it. * lisp/ob-R.el (org-babel-R-assign-elisp): * lisp/ob-core.el (org-babel-insert-result): Use :raw argument to org-table conversion. --- lisp/ob-R.el | 2 +- lisp/ob-core.el | 2 +- lisp/org-table.el | 2 +- lisp/ox.el | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lisp/ob-R.el b/lisp/ob-R.el index 2470b4f..6f76aa5 100644 --- a/lisp/ob-R.el +++ b/lisp/ob-R.el @@ -239,7 +239,7 @@ This function is called by `org-babel-execute-src-block'." (min (if lengths (apply 'min lengths) 0))) ;; Ensure VALUE has an orgtbl structure (depth of at least 2). (unless (listp (car value)) (setq value (list value))) - (let ((file (orgtbl-to-tsv value '(:fmt org-babel-R-quote-tsv-field))) + (let ((file (orgtbl-to-tsv value '(:raw t :fmt org-babel-R-quote-tsv-field))) (header (if (or (eq (nth 1 value) 'hline) colnames-p) "TRUE" "FALSE")) (row-names (if rownames-p "1" "NULL"))) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 93fcb2a..9ff83f2 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -2213,7 +2213,7 @@ code ---- the results are extracted in the syntax of the source (lambda (el) (or (listp el) (eq el 'hline))) result) result (list result)) - '(:fmt (lambda (cell) (format "%s" cell)))) "\n")) + '(:raw t :fmt (lambda (cell) (format "%s" cell)))) "\n")) (goto-char beg) (when (org-at-table-p) (org-table-align))) ((and (listp result) (not (funcall proper-list-p result))) (insert (format "%s\n" result))) diff --git a/lisp/org-table.el b/lisp/org-table.el index 6b33eda..7a53d7a 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -4834,7 +4834,7 @@ This may be either a string or a function of two arguments: (table-cell . ,(org-table--to-generic-cell params)) ;; Section. Return contents to avoid garbage around table. (section . (lambda (s c i) c)))) - 'body-only (org-combine-plists params '(:with-tables t)))))) + 'body-only (org-combine-plists params '(:with-tables t :sloppy-macros t)))))) (defun org-table--generic-apply (value name &optional with-cons &rest args) (cond ((null value) nil) diff --git a/lisp/ox.el b/lisp/ox.el index f47baef..0fcfc04 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -2885,7 +2885,8 @@ Return code as a string." (cons "email" (or (plist-get info :email) "")) (cons "title" (org-element-interpret-data (plist-get info :title)))) - 'finalize) + (unless (plist-get info :sloppy-macros) + 'finalize)) ;; Parse buffer. (setq tree (org-element-parse-buffer nil visible-only)) ;; Handle left-over uninterpreted elements or objects in -- 2.2.1 --=-=-= Content-Type: text/plain There are several usages of orgtbl-to-* functions in babel (R, awk, gnuplot, shell, sqlite, sql). Org-plot also uses one. The attached patch adds :raw to the ob-R call, but if I understand correctly probably all of them should add it. Should I do that? Thanks, -- Aaron Ecay --=-=-=--