emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/org 9623da4408 2/2: ob-gnuplot: Fix wrong table convers


From: ELPA Syncer
Subject: [elpa] externals/org 9623da4408 2/2: ob-gnuplot: Fix wrong table conversion when first column has ?-
Date: Fri, 14 Jan 2022 08:57:41 -0500 (EST)

branch: externals/org
commit 9623da44081520fa8519064003a84249a710ec6f
Author: Ihor Radchenko <yantar92@gmail.com>
Commit: Ihor Radchenko <yantar92@gmail.com>

    ob-gnuplot: Fix wrong table conversion when first column has ?-
    
    * lisp/ob-gnuplot.el (org-babel-gnuplot-table-to-data): Revert to
    using ascii exporter.
    * lisp/ox-ascii.el (org-ascii-table-cell): Do not throw error when
    CONTENTS is wider than initial cell value.
---
 lisp/ob-gnuplot.el | 25 ++++++++++---------------
 lisp/ox-ascii.el   |  6 +++++-
 2 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/lisp/ob-gnuplot.el b/lisp/ob-gnuplot.el
index 69a5f5f91b..895738822d 100644
--- a/lisp/ob-gnuplot.el
+++ b/lisp/ob-gnuplot.el
@@ -129,6 +129,7 @@ code."
            (title (cdr (assq :title params)))
            (lines (cdr (assq :line params)))
            (sets (cdr (assq :set params)))
+           (missing (cdr (assq :missing params)))
            (x-labels (cdr (assq :xlabels params)))
            (y-labels (cdr (assq :ylabels params)))
            (timefmt (cdr (assq :timefmt params)))
@@ -138,6 +139,7 @@ code."
                           (file-name-directory (buffer-file-name))))
           (add-to-body (lambda (text) (setq body (concat text "\n" body)))))
       ;; append header argument settings to body
+      (when missing (funcall add-to-body (format "set datafile missing '%s'" 
missing)))
       (when title (funcall add-to-body (format "set title '%s'" title)))
       (when lines (mapc (lambda (el) (funcall add-to-body el)) lines))
       (when sets
@@ -288,21 +290,14 @@ Pass PARAMS through to `orgtbl-to-generic' when exporting 
TABLE."
   (with-temp-file data-file
     (insert (let ((org-babel-gnuplot-timestamp-fmt
                   (or (plist-get params :timefmt) "%Y-%m-%d-%H:%M:%S")))
-              (replace-regexp-in-string
-               ;; org export backend adds "|" at the beginning/end of
-               ;; the table lines.  Strip those.
-               "^|\\(.+\\)|$"
-               "\\1"
-              (orgtbl-to-generic
-               table
-               (org-combine-plists
-                '( :sep "\t" :fmt org-babel-gnuplot-quote-tsv-field
-                    ;; Two setting below are needed to make :fmt work.
-                    :raw t
-                    ;; Use `org', not `ascii' because `ascii' may
-                    ;; sometimes mishandle quoted strings.
-                    :backend org)
-                params))))))
+             (orgtbl-to-generic
+              table
+              (org-combine-plists
+               '( :sep "\t" :fmt org-babel-gnuplot-quote-tsv-field
+                   ;; Two setting below are needed to make :fmt work.
+                   :raw t
+                   :backend ascii)
+               params)))))
   data-file)
 
 (provide 'ob-gnuplot)
diff --git a/lisp/ox-ascii.el b/lisp/ox-ascii.el
index 7f3448ce91..7e68daac7c 100644
--- a/lisp/ox-ascii.el
+++ b/lisp/ox-ascii.el
@@ -1929,7 +1929,11 @@ a communication channel."
               (org-export-table-cell-alignment table-cell info)))))
       (setq contents
            (concat data
-                   (make-string (- width (string-width (or data ""))) ?\s))))
+                    ;; FIXME: If CONTENTS was transformed by filters,
+                    ;; the whole width calculation can be wrong.
+                    ;; At least, make sure that we do not throw error
+                    ;; when CONTENTS is larger than width.
+                   (make-string (max 0 (- width (string-width (or data "")))) 
?\s))))
     ;; Return cell.
     (concat (format " %s " contents)
            (when (memq 'right (org-export-table-cell-borders table-cell info))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]