瀏覽代碼

babel: Ensure that result is a file link when that is intended

* lisp/ob.el (org-babel-execute-src-block): If ":results file" is in
effect, then ensure that the value of :file is returned as the result;
don't rely on language files for this.

Examples of languages that were not honouring :file are sh and
emacs-lisp.
Dan Davison 14 年之前
父節點
當前提交
d6599c5699
共有 1 個文件被更改,包括 12 次插入7 次删除
  1. 12 7
      lisp/ob.el

+ 12 - 7
lisp/ob.el

@@ -391,13 +391,18 @@ block."
 		(message "executing %s code block%s..."
 			 (capitalize lang)
 			 (if (nth 4 info) (format " (%s)" (nth 4 info)) ""))
-		(setq result (funcall cmd body params))
-		(if (eq (cdr (assoc :result-type params)) 'value)
-		    (setq result (if (and (or (member "vector" result-params)
-					      (member "table" result-params))
-					  (not (listp result)))
-				     (list (list result))
-				   result)))
+		(setq result
+		      ((lambda (result)
+			 (cond
+			  ((member "file" result-params)
+			   (cdr (assoc :file params)))
+			  ((and (eq (cdr (assoc :result-type params)) 'value)
+				(or (member "vector" result-params)
+				    (member "table" result-params))
+				(not (listp result)))
+			   (list (list result)))
+			  (t result)))
+		       (funcall cmd body params)))
 		(org-babel-insert-result
 		 result result-params info new-hash indent lang)
 		(run-hooks 'org-babel-after-execute-hook)