Last active
August 29, 2015 13:58
-
-
Save notogawa/9970207 to your computer and use it in GitHub Desktop.
haskell-mode for ghc-mod < 4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; -*- mode: emacs-lisp; coding: utf-8-unix; indent-tabs-mode: nil -*- | |
(when (require 'haskell-mode nil t) | |
(when (require 'haskell-cabal nil t) | |
(autoload 'offside-trap-mode "mode/haskell/offside-trap/offside-trap.el") | |
(add-to-list 'auto-mode-alist '("\\.[hg]s$" . haskell-mode)) | |
(add-to-list 'auto-mode-alist '("\\.hi$" . haskell-mode)) | |
(add-to-list 'auto-mode-alist '("\\.l[hg]s$" . literate-haskell-mode)) | |
(add-to-list 'auto-mode-alist '("\\.cabal\\'" . haskell-cabal-mode)) | |
(add-to-list 'interpreter-mode-alist '("runghc" . haskell-mode)) ;; #!/usr/bin/env runghc 用 | |
(add-to-list 'interpreter-mode-alist '("runhaskell" . haskell-mode)) ;; #!/usr/bin/env runhaskell 用 | |
;; ghc-mod | |
(autoload 'ghc-init "ghc" nil t) | |
(add-hook | |
'haskell-mode-hook | |
(lambda () | |
(ghc-init) | |
(flymake-mode) | |
;; syntax-checkの異常終了でflymake-mode抜けしてしまうのを無視 | |
(defadvice flymake-post-syntax-check | |
(before flymake-force-check-was-interrupted) | |
(setq flymake-check-was-interrupted t)) | |
(ad-activate 'flymake-post-syntax-check) | |
;; ミニバッファにエラー内容を表示 | |
(defun ghc-flymake-display-errors-to-minibuffer () | |
(if (not (ghc-flymake-have-errs-p)) | |
(message "No errors or warnings") | |
(let ((title (ghc-flymake-err-title)) | |
(errs (ghc-flymake-err-list))) | |
(message "%s\n\n%s\n\n" title | |
(mapconcat (lambda (x) (replace-regexp-in-string "\0" "\n" x)) errs "\n"))))) | |
;; M-nで次のエラーに飛ぶと同時にミニバッファにエラー内容を表示 | |
(define-key haskell-mode-map ghc-next-key | |
'(lambda () | |
(interactive) | |
(flymake-goto-next-error) | |
(ghc-flymake-display-errors-to-minibuffer))) | |
;; M-pで前のエラーに飛ぶと同時にミニバッファにエラー内容を表示 | |
(define-key haskell-mode-map ghc-previous-key | |
'(lambda () | |
(interactive) | |
(flymake-goto-prev-error) | |
(ghc-flymake-display-errors-to-minibuffer))))) | |
(autoload 'haskell-mode | |
"haskell-mode" "Major mode for editing Haskell scripts." t) | |
(autoload 'literate-haskell-mode | |
"haskell-mode" "Major mode for editing literate Haskell scripts." t) | |
(add-hook 'haskell-mode-hook 'turn-on-font-lock) | |
(add-hook 'haskell-mode-hook 'turn-on-haskell-decl-scan) | |
(add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode) | |
(add-hook 'haskell-mode-hook 'turn-on-haskell-indent) | |
(add-hook 'haskell-mode-hook 'offside-trap-mode) | |
(add-hook | |
'haskell-mode-hook | |
'(lambda () | |
(setq indent-tabs-mode nil) | |
(setq auto-fill-mode nil))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment