1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-22 07:09:47 +00:00

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.
This commit is contained in:
Eric Schulte 2011-06-01 18:52:33 -06:00
parent af677f6d06
commit fbfc2d1835

View File

@ -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)))