Browse Source

Merge branch 'master' of orgmode.org:org-mode

Carsten Dominik 14 years ago
parent
commit
cf708c72e5
2 changed files with 23 additions and 12 deletions
  1. 2 2
      doc/org.texi
  2. 21 10
      lisp/ob-lisp.el

+ 2 - 2
doc/org.texi

@@ -10221,9 +10221,9 @@ For example the @code{#+ATTR_LaTeX:} line below is exported as the
 @example
 #+ATTR_LaTeX: placement=[<options>]\footnotesize
 
-\begin{figure}[<options>]\footnotesize
+\begin@{figure@}[<options>]\footnotesize
 ...
-\end{figure}
+\end@{figure@}
 @end example
 
 If you would like to let text flow around the image, add the word @samp{wrap}

+ 21 - 10
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)))
@@ -64,17 +70,22 @@
   "Execute a block of Common Lisp code with Babel."
   (require 'slime)
   (org-babel-reassemble-table
-   (with-temp-buffer
-     (insert (org-babel-expand-body:lisp body params))
-     ((lambda (result)
-	(if (member "output" (cdr (assoc :result-params params)))
-	    (car result)
-	    (condition-case nil
-		(read (org-bable-lisp-vector-to-list (cadr result)))
-	      (error (cadr result)))))
+   ((lambda (result)
+      (if (member "output" (cdr (assoc :result-params params)))
+	  (car result)
+	(condition-case nil
+	    (read (org-bable-lisp-vector-to-list (cadr result)))
+	  (error (cadr result)))))
+    (with-temp-buffer
+      (insert (org-babel-expand-body:lisp body params))
       (slime-eval `(swank:eval-and-grab-output
-		    ,(format "(progn %s)" (buffer-substring-no-properties
-					   (point-min) (point-max))))
+		    ,(let ((dir (if (assoc :dir params)
+					    (cdr (assoc :dir params))
+					  default-directory)))
+		       (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)))