summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKDr2 <killy.draw@gmail.com>2014-05-21 05:47:44 (GMT)
committer Bastien Guerry <bzg@altern.org>2014-05-22 11:14:30 (GMT)
commit21d6d7c3a0b08382e4dfc5d7300f61ba5afe6f12 (patch)
tree0264e9b025bb2ead17f876d39e4c75e87fc4c4f3
parent92d84410efeef733725d397fc3719cf02ea75816 (diff)
downloadorg-mode-21d6d7c3a0b08382e4dfc5d7300f61ba5afe6f12.zip
org-mode-21d6d7c3a0b08382e4dfc5d7300f61ba5afe6f12.tar.gz
lisp/ob-scheme.el: Fix scheme code blocks execution error in batch mode
* ob-scheme.el (org-babel-scheme-capture-current-message) (org-babel-scheme-execute-with-geiser): Capture scheme code results via `current-message' both in interactive mode and non interactive mode. `org-babel-scheme-execute-with-geiser' uses `current-message' to get the results of scheme code blocks, but `current-message' always returns nil in batch mode, and this patch fixes this.
-rw-r--r--lisp/ob-scheme.el23
1 files changed, 20 insertions, 3 deletions
diff --git a/lisp/ob-scheme.el b/lisp/ob-scheme.el
index b7117e9..2095534 100644
--- a/lisp/ob-scheme.el
+++ b/lisp/ob-scheme.el
@@ -118,6 +118,22 @@ org-babel-scheme-execute-with-geiser will use a temporary session."
(name))))
result))
+(defmacro org-babel-scheme-capture-current-message (&rest body)
+ "Capture current message in both interactive and noninteractive mode"
+ `(if noninteractive
+ (let ((original-message (symbol-function 'message))
+ (current-message nil))
+ (unwind-protect
+ (progn
+ (defun message (&rest args)
+ (setq current-message (apply original-message args)))
+ ,@body
+ current-message)
+ (fset 'message original-message)))
+ (progn
+ ,@body
+ (current-message))))
+
(defun org-babel-scheme-execute-with-geiser (code output impl repl)
"Execute code in specified REPL. If the REPL doesn't exist, create it
using the given scheme implementation.
@@ -142,10 +158,11 @@ is true; otherwise returns the last value."
(current-buffer)))))
(setq geiser-repl--repl repl-buffer)
(setq geiser-impl--implementation nil)
- (geiser-eval-region (point-min) (point-max))
+ (setq result (org-babel-scheme-capture-current-message
+ (geiser-eval-region (point-min) (point-max))))
(setq result
- (if (equal (substring (current-message) 0 3) "=> ")
- (replace-regexp-in-string "^=> " "" (current-message))
+ (if (and (stringp result) (equal (substring result 0 3) "=> "))
+ (replace-regexp-in-string "^=> " "" result)
"\"An error occurred.\""))
(when (not repl)
(save-current-buffer (set-buffer repl-buffer)