Skip to content

Commit ccbb6eb

Browse files
committed
Add *project:splices* buffer for -ddump-splices
1 parent e0ddd49 commit ccbb6eb

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

haskell-interactive-mode.el

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,14 +1057,31 @@ don't care when the thing completes as long as it's soonish."
10571057
'read-only t
10581058
'rear-nonsticky t))))))
10591059

1060+
(defun haskell-interactive-mode-splices-buffer (session)
1061+
"Get the splices buffer for the current session."
1062+
(get-buffer-create (haskell-interactive-mode-splices-buffer-name session)))
1063+
1064+
(defun haskell-interactive-mode-splices-buffer-name (session)
1065+
(format "*%s:splices*" (haskell-session-name session)))
1066+
10601067
(defun haskell-interactive-mode-compile-splice (session message)
10611068
"Echo a compiler splice."
1062-
(with-current-buffer (haskell-session-interactive-buffer session)
1063-
(setq next-error-last-buffer (current-buffer))
1064-
(save-excursion
1065-
(haskell-interactive-mode-goto-end-point)
1066-
(insert (haskell-fontify-as-mode message 'haskell-mode)
1067-
"\n"))))
1069+
(with-current-buffer (haskell-interactive-mode-splices-buffer session)
1070+
(unless (eq major-mode 'haskell-mode)
1071+
(haskell-mode))
1072+
(let* ((parts (split-string message "\n ======>\n"))
1073+
(file-and-decl-lines (split-string (nth 0 parts) "\n"))
1074+
(file (nth 0 file-and-decl-lines))
1075+
(decl (mapconcat #'identity (cdr file-and-decl-lines) "\n"))
1076+
(output (nth 1 parts)))
1077+
(insert "-- " file "\n")
1078+
(let ((start (point)))
1079+
(insert decl "\n")
1080+
(indent-rigidly start (point) -4))
1081+
(insert "-- =>\n")
1082+
(let ((start (point)))
1083+
(insert output "\n")
1084+
(indent-rigidly start (point) -4)))))
10681085

10691086
(defun haskell-interactive-mode-insert-garbage (session message)
10701087
"Echo a read only piece of text before the prompt."

haskell-load.el

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ changed. Restarts the process if that is the case."
8282
"Handle the complete loading response. BUFFER is the string of
8383
text being sent over the process pipe. MODULE-BUFFER is the
8484
actual Emacs buffer of the module being loaded."
85+
(when (get-buffer (format "*%s:splices*" (haskell-session-name session)))
86+
(with-current-buffer (haskell-interactive-mode-splices-buffer session)
87+
(erase-buffer)))
8588
(cond ((haskell-process-consume process "Ok, modules loaded: \\(.+\\)\\.$")
8689
(let* ((modules (haskell-process-extract-modules buffer))
8790
(cursor (haskell-process-response-cursor process)))

0 commit comments

Comments
 (0)