Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure run-expr uses *haskell* buffer #1861

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 29 additions & 28 deletions haskell-repl.el
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down