Function: org-babel-import-elisp-from-file

org-babel-import-elisp-from-file is a byte-compiled function defined in ob-core.el.gz.

Signature

(org-babel-import-elisp-from-file FILE-NAME &optional SEPARATOR)

Documentation

Read the results located at FILE-NAME into an elisp table.

If the table is trivial, then return it as a scalar.

Source Code

;; Defined in /usr/src/emacs/lisp/org/ob-core.el.gz
(defun org-babel-import-elisp-from-file (file-name &optional separator)
  "Read the results located at FILE-NAME into an elisp table.
If the table is trivial, then return it as a scalar."
  (let ((result
	 (with-temp-buffer
	   (condition-case err
	       (progn
		 (insert-file-contents file-name)
		 (delete-file file-name)
		 (let ((pmax (point-max)))
		   ;; If the file was empty, don't bother trying to
		   ;; convert the table.
		   (when (> pmax 1)
		     (org-table-convert-region (point-min) pmax separator)
		     (delq nil
			   (mapcar (lambda (row)
				     (and (not (eq row 'hline))
					  (mapcar #'org-babel-string-read row)))
				   (org-table-to-lisp))))))
	     (error
	      (display-warning 'org-babel
			       (format "Error reading results: %S" err)
			       :error)
	      nil)))))
    (pcase result
      (`((,scalar)) scalar)
      (`((,_ ,_ . ,_)) result)
      (`(,scalar) scalar)
      (_ result))))