From mboxrd@z Thu Jan 1 00:00:00 1970 From: James TD Smith Subject: [PATCH 9/9] Some bugfixes for org-plot. Date: Sat, 20 Sep 2008 22:09:27 +0100 Message-ID: <20080920210927.19759.90423.stgit@nyarlathotep.internal.mohorovi.cc> References: <20080920210101.19759.15959.stgit@nyarlathotep.internal.mohorovi.cc> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kh9hr-0004KJ-MV for emacs-orgmode@gnu.org; Sat, 20 Sep 2008 17:09:31 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kh9hq-0004JY-6R for emacs-orgmode@gnu.org; Sat, 20 Sep 2008 17:09:31 -0400 Received: from [199.232.76.173] (port=60177 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kh9hp-0004JQ-R9 for emacs-orgmode@gnu.org; Sat, 20 Sep 2008 17:09:29 -0400 Received: from 81-86-40-42.dsl.pipex.com ([81.86.40.42]:55923 helo=yog-sothoth.mohorovi.cc) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Kh9hp-0002Et-9W for emacs-orgmode@gnu.org; Sat, 20 Sep 2008 17:09:29 -0400 Received: from nyarlathotep.internal.mohorovi.cc (Debian-exim@nyarlathotep.internal.mohorovi.cc [10.0.0.5]) by yog-sothoth.mohorovi.cc (8.14.2/8.14.2) with ESMTP id m8KL9ReI017687 for ; Sat, 20 Sep 2008 22:09:27 +0100 (BST) (envelope-from ahktenzero@mohorovi.cc) Received: from [127.0.0.1] (helo=nyarlathotep.internal.mohorovi.cc ident=ahktenzero) by nyarlathotep.internal.mohorovi.cc with esmtp (Exim 4.69) (envelope-from ) id 1Kh9hn-0005s6-4U for emacs-orgmode@gnu.org; Sat, 20 Sep 2008 22:09:27 +0100 In-Reply-To: <20080920210101.19759.15959.stgit@nyarlathotep.internal.mohorovi.cc> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org * Handle tables where the first line is an hline. * Put commas at the end of the line in generated scripts --- lisp/org-plot.el | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lisp/org-plot.el b/lisp/org-plot.el index 874790c..f8e268d 100644 --- a/lisp/org-plot.el +++ b/lisp/org-plot.el @@ -218,7 +218,7 @@ NUM-COLS controls the number of columns plotted in a 2-d plot." (format "\"%s\" %d" (cdr pair) (car pair))) y-labels ", ")))) (case type ;; plot command - ('2d (dotimes (col num-cols) + ('2d (dotimes (col num-cols) (unless (and (equal type '2d) (or (and ind (equal (+ 1 col) ind)) (and deps (not (member (+ 1 col) deps))))) @@ -239,11 +239,11 @@ NUM-COLS controls the number of columns plotted in a 2-d plot." (setq plot-lines (list (format "'%s' with %s title ''" data-file with))))) (add-to-script - (concat plot-cmd " " (mapconcat 'identity (reverse plot-lines) "\\\n ,"))) + (concat plot-cmd " " (mapconcat 'identity (reverse plot-lines) ",\\\n "))) script))) ;;----------------------------------------------------------------------------- -;; facad functions +;; facade functions ;;;###autoload (defun org-plot/gnuplot (&optional params) "Plot table using gnuplot. Gnuplot options can be specified with PARAMS. @@ -255,11 +255,11 @@ line directly before or after the table." (delete-other-windows) (when (get-buffer "*gnuplot*") ;; reset *gnuplot* if it already running (save-excursion - (set-buffer "*gnuplot*") (goto-char (point-max)) + (set-buffer "*gnuplot*") (goto-char (point-max)) (gnuplot-delchar-or-maybe-eof nil))) (org-plot/goto-nearest-table) ;; set default options - (mapc + (mapc (lambda (pair) (unless (plist-member params (car pair)) (setf params (plist-put params (car pair) (cdr pair))))) @@ -267,7 +267,8 @@ line directly before or after the table." ;; collect table and table information (let* ((data-file (make-temp-file "org-plot")) (table (org-table-to-lisp)) - (num-cols (length (first table)))) + (num-cols (length (if (eq (first table) 'hline) (second table) + (first table))))) (while (equal 'hline (first table)) (setf table (cdr table))) (when (equal (second table) 'hline) (setf params (plist-put params :labels (first table))) ;; headers to labels