|
70 | 70 | "Run the given expression." |
71 | 71 | (let ((session (haskell-interactive-session)) |
72 | 72 | (process (haskell-interactive-process))) |
73 | | - (haskell-process-queue-command |
74 | | - process |
75 | | - (make-haskell-command |
76 | | - :state (list session process expr 0) |
77 | | - :go (lambda (state) |
78 | | - (goto-char (point-max)) |
79 | | - (insert "\n") |
80 | | - (setq haskell-interactive-mode-result-end |
81 | | - (point-max)) |
82 | | - (haskell-process-send-string (cadr state) |
83 | | - (haskell-interactive-mode-multi-line (cl-caddr state))) |
84 | | - (haskell-process-set-evaluating (cadr state) t)) |
85 | | - :live (lambda (state buffer) |
86 | | - (unless (and (string-prefix-p ":q" (cl-caddr state)) |
87 | | - (string-prefix-p (cl-caddr state) ":quit")) |
88 | | - (let* ((cursor (cl-cadddr state)) |
89 | | - (next (replace-regexp-in-string |
90 | | - haskell-process-prompt-regex |
91 | | - "" |
92 | | - (substring buffer cursor)))) |
93 | | - (haskell-interactive-mode-eval-result (car state) next) |
94 | | - (setf (cl-cdddr state) (list (length buffer))) |
95 | | - nil))) |
96 | | - :complete |
97 | | - (lambda (state response) |
98 | | - (haskell-process-set-evaluating (cadr state) nil) |
99 | | - (unless (haskell-interactive-mode-trigger-compile-error state response) |
100 | | - (haskell-interactive-mode-expr-result state response))))))) |
| 73 | + (with-current-buffer (haskell-session-interactive-buffer session) |
| 74 | + (haskell-process-queue-command |
| 75 | + process |
| 76 | + (make-haskell-command |
| 77 | + :state (list session process expr 0) |
| 78 | + :go (lambda (state) |
| 79 | + (goto-char (point-max)) |
| 80 | + (insert "\n") |
| 81 | + (setq haskell-interactive-mode-result-end |
| 82 | + (point-max)) |
| 83 | + (haskell-process-send-string (cadr state) |
| 84 | + (haskell-interactive-mode-multi-line (cl-caddr state))) |
| 85 | + (haskell-process-set-evaluating (cadr state) t)) |
| 86 | + :live (lambda (state buffer) |
| 87 | + (unless (and (string-prefix-p ":q" (cl-caddr state)) |
| 88 | + (string-prefix-p (cl-caddr state) ":quit")) |
| 89 | + (let* ((cursor (cl-cadddr state)) |
| 90 | + (next (replace-regexp-in-string |
| 91 | + haskell-process-prompt-regex |
| 92 | + "" |
| 93 | + (substring buffer cursor)))) |
| 94 | + (haskell-interactive-mode-eval-result (car state) next) |
| 95 | + (setf (cl-cdddr state) (list (length buffer))) |
| 96 | + nil))) |
| 97 | + :complete |
| 98 | + (lambda (state response) |
| 99 | + (haskell-process-set-evaluating (cadr state) nil) |
| 100 | + (unless (haskell-interactive-mode-trigger-compile-error state response) |
| 101 | + (haskell-interactive-mode-expr-result state response)))))))) |
101 | 102 |
|
102 | 103 | (defun haskell-interactive-mode-expr-result (state response) |
103 | 104 | "Print the result of evaluating the expression." |
|
0 commit comments