From mboxrd@z Thu Jan 1 00:00:00 1970 From: Achim Gratz Subject: Re: using gnuplot's "splot" and "every" commands on org-mode table data Date: Sun, 12 May 2013 20:55:07 +0200 Message-ID: <87hai858qc.fsf@Rainer.invalid> References: <87k3ncxeqt.fsf@gmail.com> <87y5bpocz9.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:43668) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UbbQa-0005IH-Rv for emacs-orgmode@gnu.org; Sun, 12 May 2013 14:55:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UbbQZ-0007ev-3j for emacs-orgmode@gnu.org; Sun, 12 May 2013 14:55:24 -0400 Received: from plane.gmane.org ([80.91.229.3]:60616) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UbbQY-0007eF-Oc for emacs-orgmode@gnu.org; Sun, 12 May 2013 14:55:23 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UbbQW-0005a7-2V for emacs-orgmode@gnu.org; Sun, 12 May 2013 20:55:20 +0200 Received: from pd9eb481b.dip0.t-ipconnect.de ([217.235.72.27]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 12 May 2013 20:55:20 +0200 Received: from Stromeko by pd9eb481b.dip0.t-ipconnect.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 12 May 2013 20:55:20 +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 --=-=-= Content-Type: text/plain Eric Schulte writes: > This does look like a bug to me. Can you isolate "where" the value of > data in your example is first assigned the wrong value? The error lies in how ob-sh tries to determine if it needs to process a table or a vector and then forgets to check for 'hline, thus ending up in the vector branch with the table data. > Thanks for reporting. I will save your example for when I next have > development time. Here's a suggestion for a quick fix. I've also implemented :hlines processing for ob-sh (it was ignoring that header arg unconditionally) and added an experimental header arg :hline-string to control how hlines get actually exported. BTW, trailing blank lines in the output get swallowed when re-importing to Org, I'm not sure if that is supposed to happen or not. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-ob-sh-detect-tables-correctly-add-hlines-processing-.patch >From 06056792c96c4c5996db5dd13e857658e6d4a573 Mon Sep 17 00:00:00 2001 From: Achim Gratz Date: Sun, 12 May 2013 20:36:51 +0200 Subject: [PATCH] ob-sh: detect tables correctly, add :hlines processing and :hline-string header arg * lisp/ob-sh.el (org-babel-variable-assignments:sh): Check for ":hlines yes" and use header arg :hlines-string if defined (default to "hline") and add this to the call of `org-babel-sh-var-to-sh'. (org-babel-sh-var-to-sh, org-babel-sh-var-to-string): Add additional optional string argument `hline' and use it for the :hline parameter in the call to `orgtbl-to-generic'. Thanks to Paul Stansell for pointing out the error. --- lisp/ob-sh.el | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lisp/ob-sh.el b/lisp/ob-sh.el index f11b799..72f3c19 100644 --- a/lisp/ob-sh.el +++ b/lisp/ob-sh.el @@ -88,26 +88,31 @@ (defun org-babel-load-session:sh (session body params) (defun org-babel-variable-assignments:sh (params) "Return list of shell statements assigning the block's variables." - (let ((sep (cdr (assoc :separator params)))) + (let ((sep (cdr (assoc :separator params))) + (hline (when (string= "yes" (cdr (assoc :hlines params))) + (or (cdr (assoc :hline-string params)) + "hline")))) (mapcar (lambda (pair) (format "%s=%s" (car pair) - (org-babel-sh-var-to-sh (cdr pair) sep))) + (org-babel-sh-var-to-sh (cdr pair) sep hline))) (mapcar #'cdr (org-babel-get-header params :var))))) -(defun org-babel-sh-var-to-sh (var &optional sep) +(defun org-babel-sh-var-to-sh (var &optional sep hlines) "Convert an elisp value to a shell variable. Convert an elisp var into a string of shell commands specifying a var of the same value." - (format org-babel-sh-var-quote-fmt (org-babel-sh-var-to-string var sep))) + (format org-babel-sh-var-quote-fmt (org-babel-sh-var-to-string var sep hline))) -(defun org-babel-sh-var-to-string (var &optional sep) +(defun org-babel-sh-var-to-string (var &optional sep hline) "Convert an elisp value to a string." (let ((echo-var (lambda (v) (if (stringp v) v (format "%S" v))))) (cond - ((and (listp var) (listp (car var))) - (orgtbl-to-generic var (list :sep (or sep "\t") :fmt echo-var))) + ((and (listp var) (or (listp (car var)) 'hline)) + (orgtbl-to-generic var (list :sep (or sep "\t") + :fmt echo-var + :hline hline))) ((listp var) (mapconcat echo-var var "\n")) (t (funcall echo-var var))))) -- 1.8.2.2 --=-=-= Content-Type: text/plain Giving ob-gnuplot (and possible ob-awk, which also uses orgtbl-to-generic) a similar treatment would allow to do this directly without going through ob.sh of course. Regards, Achim. -- +<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+ Factory and User Sound Singles for Waldorf Q+, Q and microQ: http://Synth.Stromeko.net/Downloads.html#WaldorfSounds --=-=-=--