Merge pull request #206 from notogawa/display-minibuf
display error message to minibuffer when goto next/prev error.
This commit is contained in:
commit
2f7a36ecfc
@ -144,6 +144,19 @@
|
||||
(insert (overlay-get (car ovls) 'ghc-file) "\n\n")
|
||||
(mapc (lambda (x) (insert x "\n\n")) errs))))))
|
||||
|
||||
(defun ghc-display-errors-to-minibuf ()
|
||||
(interactive)
|
||||
(let* ((ovls (ghc-check-overlay-at (point)))
|
||||
(errs (mapcar (lambda (ovl) (overlay-get ovl 'ghc-msg)) ovls))
|
||||
(old-max-mini-window-height max-mini-window-height))
|
||||
(setq max-mini-window-height 0.95)
|
||||
(if (null ovls)
|
||||
(message "No errors or warnings")
|
||||
(progn
|
||||
(message "%s\n\n%s\n" (overlay-get (car ovls) 'ghc-file)
|
||||
(mapconcat (lambda (x) (replace-regexp-in-string "\0" "\n" x)) errs "\n"))))
|
||||
(setq old-max-mini-window-height)))
|
||||
|
||||
(defun ghc-check-overlay-at (p)
|
||||
(let ((ovls (overlays-at p)))
|
||||
(ghc-filter (lambda (ovl) (overlay-get ovl 'ghc-check)) ovls)))
|
||||
@ -153,22 +166,28 @@
|
||||
(defun ghc-goto-prev-error ()
|
||||
(interactive)
|
||||
(let* ((here (point))
|
||||
(ovls0 (ghc-check-overlay-at here))
|
||||
(end (if ovls0 (overlay-start (car ovls0)) here))
|
||||
(ovls1 (overlays-in (point-min) end))
|
||||
(ovls2 (ghc-filter (lambda (ovl) (overlay-get ovl 'ghc-check)) ovls1))
|
||||
(pnts (mapcar 'overlay-start ovls2)))
|
||||
(if pnts (goto-char (apply 'max pnts)))))
|
||||
(ovls0 (ghc-check-overlay-at here))
|
||||
(end (if ovls0 (overlay-start (car ovls0)) here))
|
||||
(ovls1 (overlays-in (point-min) end))
|
||||
(ovls2 (ghc-filter (lambda (ovl) (overlay-get ovl 'ghc-check)) ovls1))
|
||||
(pnts (mapcar 'overlay-start ovls2)))
|
||||
(if pnts (goto-char (apply 'max pnts))))
|
||||
(cond
|
||||
((eq ghc-display-error 'minibuffer) (ghc-display-errors-to-minibuf))
|
||||
((eq ghc-display-error 'other-buffer) (ghc-display-errors))))
|
||||
|
||||
(defun ghc-goto-next-error ()
|
||||
(interactive)
|
||||
(let* ((here (point))
|
||||
(ovls0 (ghc-check-overlay-at here))
|
||||
(beg (if ovls0 (overlay-end (car ovls0)) here))
|
||||
(ovls1 (overlays-in beg (point-max)))
|
||||
(ovls2 (ghc-filter (lambda (ovl) (overlay-get ovl 'ghc-check)) ovls1))
|
||||
(pnts (mapcar 'overlay-start ovls2)))
|
||||
(if pnts (goto-char (apply 'min pnts)))))
|
||||
(ovls0 (ghc-check-overlay-at here))
|
||||
(beg (if ovls0 (overlay-end (car ovls0)) here))
|
||||
(ovls1 (overlays-in beg (point-max)))
|
||||
(ovls2 (ghc-filter (lambda (ovl) (overlay-get ovl 'ghc-check)) ovls1))
|
||||
(pnts (mapcar 'overlay-start ovls2)))
|
||||
(if pnts (goto-char (apply 'min pnts))))
|
||||
(cond
|
||||
((eq ghc-display-error 'minibuffer) (ghc-display-errors-to-minibuf))
|
||||
((eq ghc-display-error 'other-buffer) (ghc-display-errors))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
12
elisp/ghc.el
12
elisp/ghc.el
@ -8,6 +8,16 @@
|
||||
;;
|
||||
;; (autoload 'ghc-init "ghc" nil t)
|
||||
;; (add-hook 'haskell-mode-hook (lambda () (ghc-init)))
|
||||
;;
|
||||
;; Or if you wish to display error each goto next/prev error,
|
||||
;; set ghc-display-error valiable.
|
||||
;;
|
||||
;; (autoload 'ghc-init "ghc" nil t)
|
||||
;; (setq ghc-display-error 'minibuffer) ; to minibuffer
|
||||
;; ; (setq ghc-display-error 'other-buffer) ; to other-buffer
|
||||
;; (add-hook 'haskell-mode-hook (lambda () (ghc-init)))
|
||||
|
||||
;;
|
||||
|
||||
;;; Code:
|
||||
|
||||
@ -56,6 +66,8 @@
|
||||
(defvar ghc-shallower-key "\C-c<")
|
||||
(defvar ghc-deeper-key "\C-c>")
|
||||
|
||||
(defvar ghc-display-error nil)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;
|
||||
;;; Initializer
|
||||
|
Loading…
Reference in New Issue
Block a user