Browse Source

ob-gnuplot: Fix error when table contains dates

* lisp/ob-gnuplot.el (org-babel-gnuplot-table-to-data): Dynamically
  bind `org-babel-gnuplot-timestamp-fmt' instead of making it
  buffer-local, since export takes place in another buffer anyway.

Thanks to Thomas Holst for reporting it.
http://permalink.gmane.org/gmane.emacs.orgmode/90709
Nicolas Goaziou 6 years ago
parent
commit
a927894d12
1 changed files with 8 additions and 10 deletions
  1. 8 10
      lisp/ob-gnuplot.el

+ 8 - 10
lisp/ob-gnuplot.el

@@ -64,7 +64,7 @@
     (term       . :any))
   "Gnuplot specific header args.")
 
-(defvar org-babel-gnuplot-timestamp-fmt nil)
+(defvar org-babel-gnuplot-timestamp-fmt nil) ; Dynamically scoped.
 
 (defvar *org-babel-gnuplot-missing* nil)
 
@@ -264,15 +264,13 @@ then create one.  Return the initialized session.  The current
   "Export TABLE to DATA-FILE in a format readable by gnuplot.
 Pass PARAMS through to `orgtbl-to-generic' when exporting TABLE."
   (with-temp-file data-file
-    (make-local-variable 'org-babel-gnuplot-timestamp-fmt)
-    (setq org-babel-gnuplot-timestamp-fmt (or
-                                           (plist-get params :timefmt)
-                                           "%Y-%m-%d-%H:%M:%S"))
-    (insert (orgtbl-to-generic
-	     table
-	     (org-combine-plists
-	      '(:sep "\t" :fmt org-babel-gnuplot-quote-tsv-field)
-	      params))))
+    (insert (let ((org-babel-gnuplot-timestamp-fmt
+		   (or (plist-get params :timefmt) "%Y-%m-%d-%H:%M:%S")))
+	      (orgtbl-to-generic
+	       table
+	       (org-combine-plists
+		'(:sep "\t" :fmt org-babel-gnuplot-quote-tsv-field)
+		params)))))
   data-file)
 
 (provide 'ob-gnuplot)