Skip to content

Commit ad9a68f

Browse files
committed
[Emacs] apply from haskell/haskell-mode#1605
1 parent 57bbc71 commit ad9a68f

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

.emacs.rc/haskell-mode-rc.el

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,55 @@
33
(add-hook 'haskell-mode-hook 'haskell-indent-mode)
44
(add-hook 'haskell-mode-hook 'interactive-haskell-mode)
55
(add-hook 'haskell-mode-hook 'haskell-doc-mode)
6+
7+
(defun haskell-process-load-complete (session process buffer reload module-buffer &optional cont)
8+
"Handle the complete loading response. BUFFER is the string of
9+
text being sent over the process pipe. MODULE-BUFFER is the
10+
actual Emacs buffer of the module being loaded."
11+
(when (get-buffer (format "*%s:splices*" (haskell-session-name session)))
12+
(with-current-buffer (haskell-interactive-mode-splices-buffer session)
13+
(erase-buffer)))
14+
(let* ((ok (cond
15+
((haskell-process-consume
16+
process
17+
"Ok, \\(?:[0-9]+\\) modules? loaded\\.$")
18+
t)
19+
((haskell-process-consume
20+
process
21+
"Ok, \\(?:[a-z]+\\) module loaded\\.$") ;; for ghc 8.4
22+
t)
23+
((haskell-process-consume
24+
process
25+
"Failed, \\(?:[0-9]+\\) modules? loaded\\.$")
26+
nil)
27+
((haskell-process-consume
28+
process
29+
"Ok, modules loaded: \\(.+\\)\\.$")
30+
t)
31+
((haskell-process-consume
32+
process
33+
"Failed, modules loaded: \\(.+\\)\\.$")
34+
nil)
35+
(t
36+
(error (message "Unexpected response from haskell process.")))))
37+
(modules (haskell-process-extract-modules buffer))
38+
(cursor (haskell-process-response-cursor process))
39+
(warning-count 0))
40+
(haskell-process-set-response-cursor process 0)
41+
(haskell-check-remove-overlays module-buffer)
42+
(while
43+
(haskell-process-errors-warnings module-buffer session process buffer)
44+
(setq warning-count (1+ warning-count)))
45+
(haskell-process-set-response-cursor process cursor)
46+
(if (and (not reload)
47+
haskell-process-reload-with-fbytecode)
48+
(haskell-process-reload-with-fbytecode process module-buffer)
49+
(haskell-process-import-modules process (car modules)))
50+
(if ok
51+
(haskell-mode-message-line (if reload "Reloaded OK." "OK."))
52+
(haskell-interactive-mode-compile-error session "Compilation failed."))
53+
(when cont
54+
(condition-case-unless-debug e
55+
(funcall cont ok)
56+
(error (message "%S" e))
57+
(quit nil)))))

0 commit comments

Comments
 (0)