branch: elpa/haskell-mode
commit a41e809986cb31422a4945e15c6683bb1b744c66
Author: Zaz Brown <zazbr...@zazbrown.com>
Commit: Zaz Brown <zazbr...@zazbrown.com>

    ensure run-expr uses *haskell* buffer
    
    Previously, it would run `(goto-char (point-max)) (insert "\n")` in
    whatever buffer you are currently in.
---
 haskell-repl.el | 57 +++++++++++++++++++++++++++++----------------------------
 1 file changed, 29 insertions(+), 28 deletions(-)

diff --git a/haskell-repl.el b/haskell-repl.el
index 58be6a239b..8ce30dfe19 100644
--- a/haskell-repl.el
+++ b/haskell-repl.el
@@ -70,34 +70,35 @@
   "Run the given expression."
   (let ((session (haskell-interactive-session))
         (process (haskell-interactive-process)))
-    (haskell-process-queue-command
-     process
-     (make-haskell-command
-      :state (list session process expr 0)
-      :go (lambda (state)
-            (goto-char (point-max))
-            (insert "\n")
-            (setq haskell-interactive-mode-result-end
-                  (point-max))
-            (haskell-process-send-string (cadr state)
-                                         (haskell-interactive-mode-multi-line 
(cl-caddr state)))
-            (haskell-process-set-evaluating (cadr state) t))
-      :live (lambda (state buffer)
-              (unless (and (string-prefix-p ":q" (cl-caddr state))
-                           (string-prefix-p (cl-caddr state) ":quit"))
-                (let* ((cursor (cl-cadddr state))
-                       (next (replace-regexp-in-string
-                              haskell-process-prompt-regex
-                              ""
-                              (substring buffer cursor))))
-                  (haskell-interactive-mode-eval-result (car state) next)
-                  (setf (cl-cdddr state) (list (length buffer)))
-                  nil)))
-      :complete
-      (lambda (state response)
-        (haskell-process-set-evaluating (cadr state) nil)
-        (unless (haskell-interactive-mode-trigger-compile-error state response)
-          (haskell-interactive-mode-expr-result state response)))))))
+    (with-current-buffer (haskell-session-interactive-buffer session)
+      (haskell-process-queue-command
+       process
+       (make-haskell-command
+        :state (list session process expr 0)
+        :go (lambda (state)
+              (goto-char (point-max))
+              (insert "\n")
+              (setq haskell-interactive-mode-result-end
+                    (point-max))
+              (haskell-process-send-string (cadr state)
+                                           
(haskell-interactive-mode-multi-line (cl-caddr state)))
+              (haskell-process-set-evaluating (cadr state) t))
+        :live (lambda (state buffer)
+                (unless (and (string-prefix-p ":q" (cl-caddr state))
+                             (string-prefix-p (cl-caddr state) ":quit"))
+                  (let* ((cursor (cl-cadddr state))
+                         (next (replace-regexp-in-string
+                                haskell-process-prompt-regex
+                                ""
+                                (substring buffer cursor))))
+                    (haskell-interactive-mode-eval-result (car state) next)
+                    (setf (cl-cdddr state) (list (length buffer)))
+                    nil)))
+        :complete
+        (lambda (state response)
+          (haskell-process-set-evaluating (cadr state) nil)
+          (unless (haskell-interactive-mode-trigger-compile-error state 
response)
+            (haskell-interactive-mode-expr-result state response))))))))
 
 (defun haskell-interactive-mode-expr-result (state response)
   "Print the result of evaluating the expression."

Reply via email to