Function: org-babel-gnuplot-process-vars

org-babel-gnuplot-process-vars is a byte-compiled function defined in ob-gnuplot.el.gz.

Signature

(org-babel-gnuplot-process-vars PARAMS)

Documentation

Extract variables from PARAMS and process the variables.

Dumps all vectors into files and returns an association list of variable names and the related value to be used in the gnuplot code.

Source Code

;; Defined in /usr/src/emacs/lisp/org/ob-gnuplot.el.gz
(defun org-babel-gnuplot-process-vars (params)
  "Extract variables from PARAMS and process the variables.
Dumps all vectors into files and returns an association list
of variable names and the related value to be used in the gnuplot
code."
  (let ((*org-babel-gnuplot-missing* (cdr (assq :missing params))))
    (mapcar
     (lambda (pair)
       (cons
	(car pair) ;; variable name
	(let* ((val (cdr pair)) ;; variable value
	       (lp  (proper-list-p val)))
	  (if lp
	      (org-babel-gnuplot-table-to-data
	       (let* ((first  (car val))
		      (tablep (or (listp first) (symbolp first))))
		 (if tablep val (mapcar 'list val)))
               ;; Make temporary file name stable with respect to data.
               ;; If we do not do it, :cache argument becomes useless.
               (org-babel-temp-stable-file (cons val params) "gnuplot-")
               params)
	    (if (and (stringp val)
		     (file-remote-p val)  ;; check if val is a remote file
		     (file-exists-p val)) ;; call to file-exists-p is slow, maybe remove it
		(let* ((local-name (concat ;; create a unique filename to avoid multiple downloads
				    (org-babel-temp-directory)
				    "/gnuplot/"
				    (file-remote-p val 'host)
				    (org-babel-local-file-name val))))
		  (if (and (file-exists-p local-name) ;; only download file if remote is newer
			   (file-newer-than-file-p local-name val))
		      local-name
		    (make-directory (file-name-directory local-name) t)
		    (copy-file val local-name t)
		    ))
	      val
	      )))))
     (org-babel--get-vars params))))