Skip to content

Commit e6150b6

Browse files
committed
haskell-goto-{prev,next}-error: steal from ghc-mod
1 parent 024df72 commit e6150b6

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

haskell-load.el

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,33 @@ actual Emacs buffer of the module being loaded."
294294
(defvar haskell-check-warning-fringe (propertize "?" 'display '(left-fringe question-mark)))
295295
(defvar haskell-check-hole-fringe (propertize "_" 'display '(left-fringe horizontal-bar)))
296296

297+
(defun haskell-check-overlay-p (ovl)
298+
(overlay-get ovl 'haskell-check))
299+
297300
(defun haskell-check-remove-overlays (buffer)
298301
(with-current-buffer buffer
299302
(remove-overlays (point-min) (point-max) 'haskell-check t)))
300303

304+
(defun haskell-goto-prev-error ()
305+
(interactive)
306+
(let* ((here (point))
307+
(ovls0 (remove-if-not 'haskell-check-overlay-p (overlays-at here)))
308+
(end (if ovls0 (overlay-start (car ovls0)) here))
309+
(ovls1 (overlays-in (point-min) end))
310+
(ovls2 (remove-if-not 'haskell-check-overlay-p ovls1))
311+
(pnts (mapcar 'overlay-start ovls2)))
312+
(if pnts (goto-char (apply 'max pnts)))))
313+
314+
(defun haskell-goto-next-error ()
315+
(interactive)
316+
(let* ((here (point))
317+
(ovls0 (remove-if-not 'haskell-check-overlay-p (overlays-at here)))
318+
(beg (if ovls0 (overlay-end (car ovls0)) here))
319+
(ovls1 (overlays-in beg (point-max)))
320+
(ovls2 (remove-if-not 'haskell-check-overlay-p ovls1))
321+
(pnts (mapcar 'overlay-start ovls2)))
322+
(if pnts (goto-char (apply 'min pnts)))))
323+
301324
(defun haskell-check-paint-overlay (buffer error-from-this-file-p line msg file err hole coln)
302325
(with-current-buffer buffer
303326
(let (beg end)

0 commit comments

Comments
 (0)