Skip to content

Commit 94e35ec

Browse files
committed
overlays: refactor message type handling a little
1 parent e7c54bf commit 94e35ec

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

haskell-load.el

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ actual Emacs buffer of the module being loaded."
339339
(if ovl-at (overlay-end ovl-at) (point)) (point-max))
340340
ovl-at))))
341341

342-
(defun haskell-check-paint-overlay (buffer error-from-this-file-p line msg file err hole coln)
342+
(defun haskell-check-paint-overlay (buffer error-from-this-file-p line msg file type hole coln)
343343
(with-current-buffer buffer
344344
(let (beg end)
345345
(goto-char (point-min))
@@ -350,7 +350,7 @@ actual Emacs buffer of the module being loaded."
350350
(forward-line (1- line))
351351
(forward-char (1- coln))
352352
(setq beg (point))
353-
(if hole
353+
(if (eq type 'hole)
354354
(forward-char (length hole))
355355
(skip-chars-forward "^[:space:]" (line-end-position)))
356356
(setq end (point)))
@@ -364,9 +364,10 @@ actual Emacs buffer of the module being loaded."
364364
(overlay-put ovl 'haskell-msg msg)
365365
(overlay-put ovl 'help-echo msg)
366366
(overlay-put ovl 'haskell-hole hole)
367-
(cl-destructuring-bind (face fringe) (cond (err (list 'haskell-error-face haskell-check-error-fringe))
368-
(hole (list 'haskell-hole-face haskell-check-hole-fringe))
369-
(t (list 'haskell-warning-face haskell-check-warning-fringe)))
367+
(cl-destructuring-bind (face fringe) (cl-case type
368+
(warning (list 'haskell-warning-face haskell-check-warning-fringe))
369+
(hole (list 'haskell-hole-face haskell-check-hole-fringe))
370+
(error (list 'haskell-error-face haskell-check-error-fringe)))
370371
(overlay-put ovl 'before-string fringe)
371372
(overlay-put ovl 'face face))))))
372373

@@ -411,9 +412,10 @@ When MODULE-BUFFER is non-NIL, paint error overlays."
411412
(file (match-string 1 buffer))
412413
(location-raw (match-string 2 buffer))
413414
(error-msg (match-string 3 buffer))
414-
(warning (string-match "^Warning:" error-msg))
415-
(splice (string-match "^Splicing " error-msg))
416-
(errorp (not warning))
415+
(type (cond ((string-match "^Warning:" error-msg) 'warning)
416+
((string-match "^Splicing " error-msg) 'splice)
417+
(t 'error)))
418+
(critical (not (eq type 'warning)))
417419
;; XXX: extract hole information, pass down to H-C-P-O
418420
(final-msg (format "%s:%s: %s"
419421
(haskell-session-strip-dir session file)
@@ -424,16 +426,15 @@ When MODULE-BUFFER is non-NIL, paint error overlays."
424426
(col1 (plist-get location :col)))
425427
(when module-buffer
426428
(haskell-check-paint-overlay module-buffer (string= (file-truename (buffer-file-name module-buffer)) (file-truename file))
427-
line error-msg file errorp nil col1))
429+
line error-msg file type nil col1))
428430
(if return-only
429-
(list :file file :line line :col col1 :msg error-msg :type (if warning 'warning 'error))
430-
(progn (funcall (cond (warning
431-
'haskell-interactive-mode-compile-warning)
432-
(splice
433-
'haskell-interactive-mode-compile-splice)
434-
(t 'haskell-interactive-mode-compile-error))
431+
(list :file file :line line :col col1 :msg error-msg :type type)
432+
(progn (funcall (cl-case type
433+
(warning 'haskell-interactive-mode-compile-warning)
434+
(splice 'haskell-interactive-mode-compile-splice)
435+
(error 'haskell-interactive-mode-compile-error))
435436
session final-msg)
436-
(unless warning
437+
(when critical
437438
(haskell-mode-message-line final-msg))
438439
(haskell-process-trigger-suggestions
439440
session

0 commit comments

Comments
 (0)