forked from mirrors/org-mode
error behavior for forth code blocks
* lisp/ob-forth.el (org-babel-forth-session-execute): Add error handling for the forth interpreter using `org-babel-eval-error-notify'.
This commit is contained in:
parent
385746d69c
commit
f85aeea69f
|
@ -50,7 +50,7 @@ This function is called by `org-babel-execute-src-block'"
|
||||||
(defun org-babel-forth-session-execute (body params)
|
(defun org-babel-forth-session-execute (body params)
|
||||||
(require 'forth-mode)
|
(require 'forth-mode)
|
||||||
(let ((proc (forth-proc))
|
(let ((proc (forth-proc))
|
||||||
(forth-rx (concat " " (regexp-opt (list "ok" "compiled")) "\n"))
|
(rx " \\(\n:\\|compiled\n\\\|ok\n\\)")
|
||||||
(result-start))
|
(result-start))
|
||||||
(with-current-buffer (process-buffer (forth-proc))
|
(with-current-buffer (process-buffer (forth-proc))
|
||||||
(mapcar (lambda (line)
|
(mapcar (lambda (line)
|
||||||
|
@ -59,11 +59,21 @@ This function is called by `org-babel-execute-src-block'"
|
||||||
(comint-send-string proc (concat line "\n"))
|
(comint-send-string proc (concat line "\n"))
|
||||||
;; wait for forth to say "ok"
|
;; wait for forth to say "ok"
|
||||||
(while (not (progn (goto-char result-start)
|
(while (not (progn (goto-char result-start)
|
||||||
(re-search-forward forth-rx nil t)))
|
(re-search-forward rx nil t)))
|
||||||
(accept-process-output proc 0.01))
|
(accept-process-output proc 0.01))
|
||||||
(unless (string= "compiled" (match-string 1))
|
(let ((case (match-string 1)))
|
||||||
(buffer-substring (+ result-start 1 (length line))
|
(cond
|
||||||
(match-beginning 0))))
|
((string= "ok\n" case)
|
||||||
|
;; Collect intermediate output.
|
||||||
|
(buffer-substring (+ result-start 1 (length line))
|
||||||
|
(match-beginning 0)))
|
||||||
|
((string= "compiled\n" case))
|
||||||
|
;; Ignore partial compilation.
|
||||||
|
((string= "\n:" case)
|
||||||
|
;; Report errors.
|
||||||
|
(org-babel-eval-error-notify 1
|
||||||
|
(buffer-substring
|
||||||
|
(+ (match-beginning 0) 1) (point-max))) nil))))
|
||||||
(split-string (org-babel-trim
|
(split-string (org-babel-trim
|
||||||
(org-babel-expand-body:generic
|
(org-babel-expand-body:generic
|
||||||
body params))
|
body params))
|
||||||
|
|
Loading…
Reference in a new issue