Fix failing test
* lisp/ob-core.el (org-babel-import-elisp-from-file): Refactor code. Fix error when `org-table-to-lisp' return value contains `hline'.
This commit is contained in:
parent
1334572582
commit
318d5bab64
|
@ -2946,24 +2946,24 @@ Otherwise return nil."
|
||||||
(defun org-babel-import-elisp-from-file (file-name &optional separator)
|
(defun org-babel-import-elisp-from-file (file-name &optional separator)
|
||||||
"Read the results located at FILE-NAME into an elisp table.
|
"Read the results located at FILE-NAME into an elisp table.
|
||||||
If the table is trivial, then return it as a scalar."
|
If the table is trivial, then return it as a scalar."
|
||||||
(let (result)
|
|
||||||
(save-window-excursion
|
(save-window-excursion
|
||||||
|
(let ((result
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(condition-case err
|
(condition-case err
|
||||||
(progn
|
(progn
|
||||||
(org-table-import file-name separator)
|
(org-table-import file-name separator)
|
||||||
(delete-file file-name)
|
(delete-file file-name)
|
||||||
(setq result (mapcar (lambda (row)
|
(delq nil
|
||||||
(mapcar #'org-babel-string-read row))
|
(mapcar (lambda (row)
|
||||||
|
(and (not (eq row 'hline))
|
||||||
|
(mapcar #'org-babel-string-read row)))
|
||||||
(org-table-to-lisp))))
|
(org-table-to-lisp))))
|
||||||
(error (message "Error reading results: %s" err) nil)))
|
(error (message "Error reading results: %s" err) nil)))))
|
||||||
(if (null (cdr result)) ;; if result is trivial vector, then scalarize it
|
(pcase result
|
||||||
(if (consp (car result))
|
(`((,scalar)) scalar)
|
||||||
(if (null (cdr (car result)))
|
(`((,_ ,_ . ,_)) result)
|
||||||
(caar result)
|
(`(,scalar) scalar)
|
||||||
result)
|
(_ result)))))
|
||||||
(car result))
|
|
||||||
result))))
|
|
||||||
|
|
||||||
(defun org-babel-string-read (cell)
|
(defun org-babel-string-read (cell)
|
||||||
"Strip nested \"s from around strings."
|
"Strip nested \"s from around strings."
|
||||||
|
|
Loading…
Reference in New Issue