display error message to minibuffer when goto next/prev error.

This commit is contained in:
Noriyuki OHKAWA 2014-04-04 23:52:09 +09:00
parent 5ca0da14ec
commit a5c62acec9
2 changed files with 39 additions and 2 deletions

View File

@ -144,6 +144,18 @@
(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" (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)))
@ -160,6 +172,11 @@
(pnts (mapcar 'overlay-start ovls2)))
(if pnts (goto-char (apply 'max pnts)))))
(defun ghc-goto-and-display-prev-error ()
(interactive)
(ghc-goto-prev-error)
(ghc-display-errors-to-minibuf))
(defun ghc-goto-next-error ()
(interactive)
(let* ((here (point))
@ -170,6 +187,11 @@
(pnts (mapcar 'overlay-start ovls2)))
(if pnts (goto-char (apply 'min pnts)))))
(defun ghc-goto-and-display-next-error ()
(interactive)
(ghc-goto-next-error)
(ghc-display-errors-to-minibuf))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun ghc-check-insert-from-warning ()

View File

@ -8,6 +8,14 @@
;;
;; (autoload 'ghc-init "ghc" nil t)
;; (add-hook 'haskell-mode-hook (lambda () (ghc-init)))
;;
;; Or you wish to display error to minibuffer.
;;
;; (autoload 'ghc-init "ghc" nil t)
;; (setq ghc-display-error-to-minibuffer t)
;; (add-hook 'haskell-mode-hook (lambda () (ghc-init)))
;;
;;; Code:
@ -56,6 +64,8 @@
(defvar ghc-shallower-key "\C-c<")
(defvar ghc-deeper-key "\C-c>")
(defvar ghc-display-error-to-minibuffer nil)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Initializer
@ -74,8 +84,13 @@
(define-key haskell-mode-map ghc-info-key 'ghc-show-info)
(define-key haskell-mode-map ghc-expand-key 'ghc-expand-th)
(define-key haskell-mode-map ghc-import-key 'ghc-import-module)
(define-key haskell-mode-map ghc-previous-key 'ghc-goto-prev-error)
(define-key haskell-mode-map ghc-next-key 'ghc-goto-next-error)
(if ghc-display-error-to-minibuffer
(progn
(define-key haskell-mode-map ghc-previous-key 'ghc-goto-and-display-prev-error)
(define-key haskell-mode-map ghc-next-key 'ghc-goto-and-display-next-error))
(progn
(define-key haskell-mode-map ghc-previous-key 'ghc-goto-prev-error)
(define-key haskell-mode-map ghc-next-key 'ghc-goto-next-error)))
(define-key haskell-mode-map ghc-help-key 'ghc-display-errors)
(define-key haskell-mode-map ghc-insert-key 'ghc-insert-template)
(define-key haskell-mode-map ghc-sort-key 'ghc-sort-lines)