]> code.delx.au - gnu-emacs/blobdiff - lisp/org/ob-sqlite.el
Merge from origin/emacs-25
[gnu-emacs] / lisp / org / ob-sqlite.el
index 84d4688ab38a6c063e3b5313431e8b5cf7d746a4..705d7cee7232b714f4e785293b8d6bf5496f0acd 100644 (file)
@@ -1,6 +1,6 @@
 ;;; ob-sqlite.el --- org-babel functions for sqlite database interaction
 
-;; Copyright (C) 2010-2013 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2016 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
@@ -114,23 +114,22 @@ This function is called by `org-babel-execute-src-block'."
 
 (defun org-babel-sqlite-expand-vars (body vars)
   "Expand the variables held in VARS in BODY."
+  ;; FIXME: Redundancy with org-babel-sql-expand-vars!
   (mapc
    (lambda (pair)
      (setq body
           (replace-regexp-in-string
-           (format "\$%s" (car pair))
-           ((lambda (val)
-              (if (listp val)
-                  ((lambda (data-file)
-                     (with-temp-file data-file
-                       (insert (orgtbl-to-csv
-                                val '(:fmt (lambda (el) (if (stringp el)
-                                                            el
-                                                          (format "%S" el)))))))
-                     data-file)
-                   (org-babel-temp-file "sqlite-data-"))
-                (if (stringp val) val (format "%S" val))))
-            (cdr pair))
+           (format "$%s" (car pair))
+           (let ((val (cdr pair)))
+              (if (listp val)
+                  (let ((data-file (org-babel-temp-file "sqlite-data-")))
+                    (with-temp-file data-file
+                      (insert (orgtbl-to-csv
+                               val '(:fmt (lambda (el) (if (stringp el)
+                                                      el
+                                                    (format "%S" el)))))))
+                    data-file)
+                (if (stringp val) val (format "%S" val))))
            body)))
    vars)
   body)