Skip to content

Commit a41e809

Browse files
committed
ensure run-expr uses *haskell* buffer
Previously, it would run `(goto-char (point-max)) (insert "\n")` in whatever buffer you are currently in.
1 parent 4cec530 commit a41e809

File tree

1 file changed

+29
-28
lines changed

1 file changed

+29
-28
lines changed

haskell-repl.el

+29-28
Original file line numberDiff line numberDiff line change
@@ -70,34 +70,35 @@
7070
"Run the given expression."
7171
(let ((session (haskell-interactive-session))
7272
(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))))))))
101102

102103
(defun haskell-interactive-mode-expr-result (state response)
103104
"Print the result of evaluating the expression."

0 commit comments

Comments
 (0)