|
3 | 3 | (add-hook 'haskell-mode-hook 'haskell-indent-mode)
|
4 | 4 | (add-hook 'haskell-mode-hook 'interactive-haskell-mode)
|
5 | 5 | (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