all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Achim Gratz <Stromeko@nexgo.de>
To: emacs-orgmode@gnu.org
Subject: Re: using gnuplot's "splot" and "every" commands on org-mode table data
Date: Sun, 12 May 2013 20:55:07 +0200	[thread overview]
Message-ID: <87hai858qc.fsf@Rainer.invalid> (raw)
In-Reply-To: 87y5bpocz9.fsf@gmail.com

[-- Attachment #1: Type: text/plain, Size: 799 bytes --]

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ob-sh-detect-tables-correctly-add-hlines-processing-.patch --]
[-- Type: text/x-patch, Size: 2589 bytes --]

From 06056792c96c4c5996db5dd13e857658e6d4a573 Mon Sep 17 00:00:00 2001
From: Achim Gratz <Stromeko@Stromeko.DE>
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


[-- Attachment #3: Type: text/plain, Size: 375 bytes --]


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

  parent reply	other threads:[~2013-05-12 18:55 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-01 14:39 using gnuplot's "splot" and "every" commands on org-mode table data Paul Stansell
2013-05-03 16:09 ` Eric Schulte
2013-05-06 18:57   ` Achim Gratz
2013-05-09 12:54     ` Eric S Fraga
2013-05-09 20:23       ` Achim Gratz
2013-05-09 20:42         ` Eric S Fraga
2013-05-11 10:39           ` Achim Gratz
2013-05-11 12:20             ` Rick Frankel
2013-05-21 12:36             ` Eric S Fraga
2013-05-07 17:14   ` Paul Stansell
2013-05-07 18:25     ` Eric Schulte
2013-05-07 18:39       ` Paul Stansell
2013-05-08 12:46         ` Eric Schulte
2013-05-08 15:48           ` Paul Stansell
2013-05-13 21:43             ` Eric Schulte
2013-05-17 15:00               ` Eric Schulte
2013-05-17 20:18                 ` Paul Stansell
2013-05-17 20:39                   ` Eric Schulte
2013-05-17 21:33                     ` Paul Stansell
2013-08-30 17:16                       ` Paul Stansell
2013-08-30 19:13                         ` Achim Gratz
2013-05-07 18:19   ` Paul Stansell
2013-05-08 12:41     ` Eric Schulte
2013-05-08 16:00       ` Paul Stansell
2013-05-12 18:55       ` Achim Gratz [this message]
2013-05-13 21:38         ` Eric Schulte
2013-05-14  7:06           ` Achim Gratz
2014-03-25 18:42           ` Achim Gratz
2013-05-11 10:51   ` Achim Gratz
2013-09-23 14:54   ` Paul Stansell
2013-09-23 23:32     ` Eric Schulte
2013-09-24 12:05       ` Paul Stansell
2013-09-25 18:21         ` Eric Schulte
2013-09-25 20:01           ` Paul Stansell

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87hai858qc.fsf@Rainer.invalid \
    --to=stromeko@nexgo.de \
    --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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.