diff options
| author | Masaya Tojo <masaya@tojo.tokyo> | 2022-05-15 14:06:53 +0900 | 
|---|---|---|
| committer | Masaya Tojo <masaya@tojo.tokyo> | 2022-05-15 14:06:53 +0900 | 
| commit | d9f774d5b1fb3f8070f761791dd37b1a7e1e36a3 (patch) | |
| tree | 421eca17aa66279b70e5823f7e2dd1eeaf2df58b | |
| parent | b774aeff37f194ebab32c205c6889d4710e4cd0f (diff) | |
ob-acl2: Update.
| -rw-r--r-- | ob-acl2.el | 47 | 
1 files changed, 32 insertions, 15 deletions
@@ -3,9 +3,9 @@  ;; Copyright (C) Masaya Tojo <masaya@tojo.tokyo>  ;; Author: Masaya Tojo -;; Keywords: literate programming, reproducible research +;; Keywords: literate programming  ;; Homepage: https://git.tojo.tokyo/ob-acl2.git -;; Version: 0.01 +;; Version: 0.1.0  ;;; License: @@ -24,8 +24,9 @@  ;;; Commentary: -;; This is implemented by pouring expressions into a *shell* buffer, which is a standard ACL2 execution environment. Please run acl2 with *shell* before using it. - +;; This is implemented by pouring expressions into a *shell* buffer, +;; which is a standard ACL2 execution environment. +;; Must run acl2 with *shell* before using it.  ;;; Code:  (require 'ob) @@ -35,20 +36,36 @@  (defun org-babel-execute:acl2 (body params)    (let ((full-body (org-babel-expand-body:generic body params)) -        ;;; XXX: I'm using *shell* for now. -	(session (get-buffer "*shell*")) -	(pt (lambda () -	      (marker-position -	       (process-mark (get-buffer-process (current-buffer))))))) +        ;;; XXX: Using *shell* for now. +        (session (get-buffer "*shell*")) +        (pt (lambda () +              (marker-position +               (process-mark (get-buffer-process (current-buffer)))))) +        (ob-babel-p (lambda () +                      (goto-char (point-max)) +                      (forward-line -1) +                      (beginning-of-line) +                      (let ((line (thing-at-point 'line t))) +                        (goto-char (point-max)) +                        (and (< 9 (length line)) +                             (equal (substring line -9 -1) "OB-BABEL"))))))      (org-babel-acl2-clean-prompt       (org-babel-comint-in-buffer session         (let ((start (funcall pt))) -	 (with-temp-buffer -	   (insert full-body) -	   (comint-send-region session (point-min) (point-max)) -           (comint-send-string session "\n")) -	 (while (equal start (funcall pt)) (sleep-for 0.1)) -	 (buffer-substring start (funcall pt))))))) +         (with-temp-buffer +           (insert full-body) +           (comint-send-region session (point-min) (point-max)) +           (comint-send-string session "\n") +           (comint-send-string session "'ob-babel\n")) +         (while (or (equal start (funcall pt)) +                    (not (funcall ob-babel-p))) +           (sleep-for 0.1)) +         (goto-char (point-max)) +         (forward-line -1) +         (beginning-of-line) +         (let ((end (point))) +           (goto-char (point-max)) +           (buffer-substring start end)))))))  (provide 'ob-acl2)  | 
