diff options
author | Eric Schulte <schulte.eric@gmail.com> | 2010-10-29 19:18:28 -0600 |
---|---|---|
committer | Eric Schulte <schulte.eric@gmail.com> | 2010-10-29 19:18:28 -0600 |
commit | 598be4a4a488e19965db1730a059ef4679e8bf99 (patch) | |
tree | b70e7b25d850a6d122a562f2d26ed606ed03777e | |
parent | 421405df194187bbbd636a7482be44120c24bba1 (diff) | |
download | org-mode-598be4a4a488e19965db1730a059ef4679e8bf99.tar.gz |
ob-calc: added to org-src-lang-modes, safer evaluation, better error messages
* lisp/ob-calc.el (org-babel-execute:calc): safer evaluation and
hopefully better error messages
* lisp/org-src.el (org-src-lang-modes): mapping calc blocks to
fundamental mode
-rw-r--r-- | lisp/ob-calc.el | 15 | ||||
-rw-r--r-- | lisp/org-src.el | 3 |
2 files changed, 13 insertions, 5 deletions
diff --git a/lisp/ob-calc.el b/lisp/ob-calc.el index e5ef5a9..5571286 100644 --- a/lisp/ob-calc.el +++ b/lisp/ob-calc.el @@ -45,10 +45,17 @@ (when (> (length line) 0) (if (string= "'" (substring line 0 1)) (funcall (lookup-key calc-mode-map (substring line 1)) nil) - (calc-push-list (list ((lambda (res) - (if (numberp res) res (math-read-number res))) - (calc-eval line))))))) - (split-string (org-babel-expand-body:calc body params) "[\n\r]")) + (calc-push-list + (list ((lambda (res) + (cond + ((numberp res) res) + ((listp res) (error "calc error \"%s\" on input \"%s\"" + (cadr res) line)) + (t res)) + (if (numberp res) res (math-read-number res))) + (calc-eval line))))))) + (mapcar #'org-babel-trim + (split-string (org-babel-expand-body:calc body params) "[\n\r]"))) (save-excursion (set-buffer (get-buffer "*Calculator*")) (calc-eval (calc-top 1)))) diff --git a/lisp/org-src.el b/lisp/org-src.el index 88780d5..97bf6b2 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -153,7 +153,8 @@ but which mess up the display of a snippet in Org exported files.") (defcustom org-src-lang-modes '(("ocaml" . tuareg) ("elisp" . emacs-lisp) ("ditaa" . artist) - ("asymptote" . asy) ("dot" . fundamental) ("sqlite" . sql)) + ("asymptote" . asy) ("dot" . fundamental) ("sqlite" . sql) + ("calc" . fundamental)) "Alist mapping languages to their major mode. The key is the language name, the value is the string that should be inserted as the name of the major mode. For many languages this is |