Browse Source

org-plot: Run `org-plot/gnuplot-script' in org buf

* lisp/org-plot.el (org-plot/gnuplot): Instead of running
`org-plot/gnuplot-script' in a temp buffer, run it in the original Org
buffer to preserve file-local variables in the event the user has
configured `org-plot/gnuplot-term-extra' or
`org-plot/gnuplot-script-preamble' to functions that reply on local
variables.
TEC 2 years ago
parent
commit
4197fcc641
1 changed files with 7 additions and 5 deletions
  1. 7 5
      lisp/org-plot.el

+ 7 - 5
lisp/org-plot.el

@@ -667,7 +667,8 @@ line directly before or after the table."
 	   (num-cols (length (if (eq (nth 0 table) 'hline) (nth 1 table)
 	   (num-cols (length (if (eq (nth 0 table) 'hline) (nth 1 table)
 			       (nth 0 table))))
 			       (nth 0 table))))
 	   (type (assoc (plist-get params :plot-type)
 	   (type (assoc (plist-get params :plot-type)
-			org-plot/preset-plot-types)))
+			org-plot/preset-plot-types))
+           gnuplot-script)
 
 
       (unless type
       (unless type
 	(user-error "Org-plot type `%s' is undefined" (plist-get params :plot-type)))
 	(user-error "Org-plot type `%s' is undefined" (plist-get params :plot-type)))
@@ -701,16 +702,17 @@ line directly before or after the table."
 				  ind-column))
 				  ind-column))
 		 (plist-put params :textind t))))) ; ind holds text
 		 (plist-put params :textind t))))) ; ind holds text
       ;; Write script.
       ;; Write script.
+      (setq gnuplot-script
+            (org-plot/gnuplot-script
+             table data-file num-cols params (plist-get params :script)))
       (with-temp-buffer
       (with-temp-buffer
 	(if (plist-get params :script)	; user script
 	(if (plist-get params :script)	; user script
-	    (progn (insert
-		    (org-plot/gnuplot-script table data-file num-cols params t))
-		   (insert "\n")
+	    (progn (insert gnuplot-script "\n")
 		   (insert-file-contents (plist-get params :script))
 		   (insert-file-contents (plist-get params :script))
 		   (goto-char (point-min))
 		   (goto-char (point-min))
 		   (while (re-search-forward "\\$datafile" nil t)
 		   (while (re-search-forward "\\$datafile" nil t)
 		     (replace-match data-file nil nil)))
 		     (replace-match data-file nil nil)))
-	  (insert (org-plot/gnuplot-script table data-file num-cols params)))
+	  (insert gnuplot-script))
 	;; Graph table.
 	;; Graph table.
 	(gnuplot-mode)
 	(gnuplot-mode)
         (condition-case nil
         (condition-case nil