document DECIDE
[screamer.git] / iscream.el
blobaafd01d699294ec90c73f993c004fd4f54864048
1 (require 'ilisp)
2 (require 'bridge)
3 (provide 'emacs-eval)
5 (defvar *lisp-eval-buffer* "")
6 (defvar *backtrack-locations* nil)
7 (defvar *y-or-n-p-map* nil)
9 (add-hook
10 'clisp-hook
11 '(lambda ()
12 (add-hook 'ilisp-init-hook '(lambda () (install-bridge)))))
14 (setq bridge-hook
15 '(lambda ()
16 (setq bridge-source-insert nil)
17 (setq bridge-destination-insert nil)
18 (setq bridge-handlers '((".*" . catch-lisp-eval)))))
20 (defun catch-lisp-eval (process string)
21 (if string
22 (setq *lisp-eval-buffer* (concat *lisp-eval-buffer* string))
23 (let ((buffer (current-buffer))
24 (eval-string *lisp-eval-buffer*))
25 (setq *lisp-eval-buffer* "")
26 (condition-case err
27 (eval (read eval-string))
28 (error (message "Bridge Error: %s on eval of: %s" err eval-string)))
29 (set-buffer buffer))))
31 (defun y-or-n-p-begin ()
32 (if (not *y-or-n-p-map*)
33 (let ((map (make-keymap)))
34 (fillarray map 'y-or-n-p-send-char)
35 (define-key map "\C-g" 'interactive-keys-ilisp)
36 (setq *y-or-n-p-map* map)))
37 (use-local-map *y-or-n-p-map*))
39 (defun y-or-n-p-end ()
40 (use-local-map ilisp-mode-map))
42 (defun y-or-n-p-send-char ()
43 (interactive)
44 (goto-char (point-max))
45 (process-send-string (ilisp-process) (make-string 1 last-input-char)))
47 (defun push-end-marker ()
48 (end-of-buffer)
49 (setq *backtrack-locations* (cons (point) *backtrack-locations*)))
51 (defun pop-end-marker ()
52 (if *backtrack-locations*
53 (let ((location (car *backtrack-locations*)))
54 (setq *backtrack-locations* (cdr *backtrack-locations*))
55 (end-of-buffer)
56 (delete-region location (point)))))