Skip to content

Commit 024df72

Browse files
committed
haskell-load | haskell-process-errors-warnings: overlay painting
1 parent f669ef0 commit 024df72

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

haskell-load.el

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ actual Emacs buffer of the module being loaded."
9292
(cursor (haskell-process-response-cursor process))
9393
(warning-count 0))
9494
(haskell-process-set-response-cursor process 0)
95+
(haskell-check-remove-overlays module-buffer)
9596
(while (haskell-process-errors-warnings module-buffer session process buffer)
9697
(setq warning-count (1+ warning-count)))
9798
(haskell-process-set-response-cursor process cursor)
@@ -293,6 +294,10 @@ actual Emacs buffer of the module being loaded."
293294
(defvar haskell-check-warning-fringe (propertize "?" 'display '(left-fringe question-mark)))
294295
(defvar haskell-check-hole-fringe (propertize "_" 'display '(left-fringe horizontal-bar)))
295296

297+
(defun haskell-check-remove-overlays (buffer)
298+
(with-current-buffer buffer
299+
(remove-overlays (point-min) (point-max) 'haskell-check t)))
300+
296301
(defun haskell-check-paint-overlay (buffer error-from-this-file-p line msg file err hole coln)
297302
(with-current-buffer buffer
298303
(let (beg end)
@@ -330,7 +335,6 @@ messages in the interactive buffer or if CONT is specified,
330335
passes the error onto that.
331336
332337
When MODULE-BUFFER is non-NIL, paint error overlays."
333-
(message "hpew 0")
334338
(cond
335339
((haskell-process-consume
336340
process
@@ -364,20 +368,24 @@ When MODULE-BUFFER is non-NIL, paint error overlays."
364368
(- (haskell-process-response-cursor process) 1))
365369
(let* ((buffer (haskell-process-response process))
366370
(file (match-string 1 buffer))
367-
(location (match-string 2 buffer))
371+
(location-raw (match-string 2 buffer))
368372
(error-msg (match-string 3 buffer))
369373
(warning (string-match "^Warning:" error-msg))
370374
(splice (string-match "^Splicing " error-msg))
375+
(errorp (not warning))
376+
;; XXX: extract hole information, pass down to H-C-P-O
371377
(final-msg (format "%s:%s: %s"
372378
(haskell-session-strip-dir session file)
373-
location
374-
error-msg)))
379+
location-raw
380+
error-msg))
381+
(location (haskell-process-parse-error (concat file ":" location-raw ": x")))
382+
(line (plist-get location :line))
383+
(col1 (plist-get location :col)))
384+
(when module-buffer
385+
(haskell-check-paint-overlay module-buffer (string= (file-truename (buffer-file-name module-buffer)) (file-truename file))
386+
line error-msg file errorp nil col1))
375387
(if return-only
376-
(let* ((location (haskell-process-parse-error (concat file ":" location ": x")))
377-
(file (plist-get location :file))
378-
(line (plist-get location :line))
379-
(col1 (plist-get location :col)))
380-
(list :file file :line line :col col1 :msg error-msg :type (if warning 'warning 'error)))
388+
(list :file file :line line :col col1 :msg error-msg :type (if warning 'warning 'error))
381389
(progn (funcall (cond (warning
382390
'haskell-interactive-mode-compile-warning)
383391
(splice

0 commit comments

Comments
 (0)