summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Schulte <schulte.eric@gmail.com>2011-06-01 18:52:33 -0600
committerEric Schulte <schulte.eric@gmail.com>2011-06-01 18:52:33 -0600
commitfbfc2d1835fd414e13a5a9d33c72cedf64eb9b08 (patch)
tree1f0a6549e5b88979cbe55a667c6ebf32c9413e84
parentaf677f6d0667bacba72defeaee7e76557e68f8c8 (diff)
downloadorg-mode-fbfc2d1835fd414e13a5a9d33c72cedf64eb9b08.tar.gz
ob-lisp: more general handling of the default-directory value in lisp code
Once again, thanks to Mark Cox for raising these issues. * lisp/ob-lisp.el (org-babel-lisp-dir-fmt): Defcustom for use in changing how/if the current directory is represented to lisp code. (org-babel-execute:lisp): More general handling of the default directory value.
-rw-r--r--lisp/ob-lisp.el16
1 files changed, 11 insertions, 5 deletions
diff --git a/lisp/ob-lisp.el b/lisp/ob-lisp.el
index a7c4ec5..4baf603 100644
--- a/lisp/ob-lisp.el
+++ b/lisp/ob-lisp.el
@@ -41,6 +41,12 @@
(defvar org-babel-default-header-args:lisp '())
(defvar org-babel-header-arg-names:lisp '(package))
+(defcustom org-babel-lisp-dir-fmt
+ "(let ((*default-pathname-defaults* #P%S)) %%s)"
+ "Format string used to wrap code bodies to set the current directory.
+For example a value of \"(progn ;; %s\\n %%s)\" would ignore the
+current directory string.")
+
(defun org-babel-expand-body:lisp (body params)
"Expand BODY according to PARAMS, return the expanded body."
(let* ((vars (mapcar #'cdr (org-babel-get-header params :var)))
@@ -73,13 +79,13 @@
(with-temp-buffer
(insert (org-babel-expand-body:lisp body params))
(slime-eval `(swank:eval-and-grab-output
- ,(format "(let ((*default-pathname-defaults* %S)) %s)"
- (let ((dir (if (assoc :dir params)
+ ,(let ((dir (if (assoc :dir params)
(cdr (assoc :dir params))
default-directory)))
- (when dir (concat "#P" dir)))
- (buffer-substring-no-properties
- (point-min) (point-max))))
+ (format
+ (if dir (format org-babel-lisp-dir-fmt dir) "(progn %s)")
+ (buffer-substring-no-properties
+ (point-min) (point-max)))))
(cdr (assoc :package params)))))
(org-babel-pick-name (cdr (assoc :colname-names params))
(cdr (assoc :colnames params)))