From fbfc2d1835fd414e13a5a9d33c72cedf64eb9b08 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Wed, 1 Jun 2011 18:52:33 -0600 Subject: [PATCH] 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. --- lisp/ob-lisp.el | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lisp/ob-lisp.el b/lisp/ob-lisp.el index a7c4ec576..4baf60309 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)))