notogawa 2014-04-05 09:53:28 +09:00
parent a5c62acec9
commit 86feaea7c5
2 changed files with 27 additions and 33 deletions

View File

@ -153,7 +153,8 @@
(if (null ovls) (if (null ovls)
(message "No errors or warnings") (message "No errors or warnings")
(progn (progn
(message "%s\n" (mapconcat (lambda (x) (replace-regexp-in-string "\0" "\n" x)) errs "\n")))) (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))) (setq old-max-mini-window-height)))
(defun ghc-check-overlay-at (p) (defun ghc-check-overlay-at (p)
@ -165,32 +166,28 @@
(defun ghc-goto-prev-error () (defun ghc-goto-prev-error ()
(interactive) (interactive)
(let* ((here (point)) (let* ((here (point))
(ovls0 (ghc-check-overlay-at here)) (ovls0 (ghc-check-overlay-at here))
(end (if ovls0 (overlay-start (car ovls0)) here)) (end (if ovls0 (overlay-start (car ovls0)) here))
(ovls1 (overlays-in (point-min) end)) (ovls1 (overlays-in (point-min) end))
(ovls2 (ghc-filter (lambda (ovl) (overlay-get ovl 'ghc-check)) ovls1)) (ovls2 (ghc-filter (lambda (ovl) (overlay-get ovl 'ghc-check)) ovls1))
(pnts (mapcar 'overlay-start ovls2))) (pnts (mapcar 'overlay-start ovls2)))
(if pnts (goto-char (apply 'max pnts))))) (if pnts (goto-char (apply 'max pnts))))
(cond
(defun ghc-goto-and-display-prev-error () ((eq ghc-display-error 'minibuffer) (ghc-display-errors-to-minibuf))
(interactive) ((eq ghc-display-error 'other-buffer) (ghc-display-errors))))
(ghc-goto-prev-error)
(ghc-display-errors-to-minibuf))
(defun ghc-goto-next-error () (defun ghc-goto-next-error ()
(interactive) (interactive)
(let* ((here (point)) (let* ((here (point))
(ovls0 (ghc-check-overlay-at here)) (ovls0 (ghc-check-overlay-at here))
(beg (if ovls0 (overlay-end (car ovls0)) here)) (beg (if ovls0 (overlay-end (car ovls0)) here))
(ovls1 (overlays-in beg (point-max))) (ovls1 (overlays-in beg (point-max)))
(ovls2 (ghc-filter (lambda (ovl) (overlay-get ovl 'ghc-check)) ovls1)) (ovls2 (ghc-filter (lambda (ovl) (overlay-get ovl 'ghc-check)) ovls1))
(pnts (mapcar 'overlay-start ovls2))) (pnts (mapcar 'overlay-start ovls2)))
(if pnts (goto-char (apply 'min pnts))))) (if pnts (goto-char (apply 'min pnts))))
(cond
(defun ghc-goto-and-display-next-error () ((eq ghc-display-error 'minibuffer) (ghc-display-errors-to-minibuf))
(interactive) ((eq ghc-display-error 'other-buffer) (ghc-display-errors))))
(ghc-goto-next-error)
(ghc-display-errors-to-minibuf))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View File

@ -9,10 +9,12 @@
;; (autoload 'ghc-init "ghc" nil t) ;; (autoload 'ghc-init "ghc" nil t)
;; (add-hook 'haskell-mode-hook (lambda () (ghc-init))) ;; (add-hook 'haskell-mode-hook (lambda () (ghc-init)))
;; ;;
;; Or you wish to display error to minibuffer. ;; Or if you wish to display error each goto next/prev error,
;; set ghc-display-error valiable.
;; ;;
;; (autoload 'ghc-init "ghc" nil t) ;; (autoload 'ghc-init "ghc" nil t)
;; (setq ghc-display-error-to-minibuffer 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))) ;; (add-hook 'haskell-mode-hook (lambda () (ghc-init)))
;; ;;
@ -64,7 +66,7 @@
(defvar ghc-shallower-key "\C-c<") (defvar ghc-shallower-key "\C-c<")
(defvar ghc-deeper-key "\C-c>") (defvar ghc-deeper-key "\C-c>")
(defvar ghc-display-error-to-minibuffer nil) (defvar ghc-display-error nil)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; ;;;
@ -84,13 +86,8 @@
(define-key haskell-mode-map ghc-info-key 'ghc-show-info) (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-expand-key 'ghc-expand-th)
(define-key haskell-mode-map ghc-import-key 'ghc-import-module) (define-key haskell-mode-map ghc-import-key 'ghc-import-module)
(if ghc-display-error-to-minibuffer (define-key haskell-mode-map ghc-previous-key 'ghc-goto-prev-error)
(progn (define-key haskell-mode-map ghc-next-key 'ghc-goto-next-error)
(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-help-key 'ghc-display-errors)
(define-key haskell-mode-map ghc-insert-key 'ghc-insert-template) (define-key haskell-mode-map ghc-insert-key 'ghc-insert-template)
(define-key haskell-mode-map ghc-sort-key 'ghc-sort-lines) (define-key haskell-mode-map ghc-sort-key 'ghc-sort-lines)