トップ «前の日記(2007-10-31) 最新 次の日記(2007-11-23)» 編集

follow ikegami__ at http://twitter.com

イネムリネズミ日記

いけがみを召喚するには、出現予定を参考にしてください。三週間前までにメールをくだされば、日程を追加するなどしてスケジュールに組み込むことができるかもしれません。勉強会や個人的な会合、中途採用面接などに応じます。日記に書かないことはこちら

2003|04|05|06|07|11|12|
2004|01|02|03|04|05|06|07|10|11|
2005|01|02|03|04|05|06|07|08|11|
2006|09|10|11|12|
2007|01|02|03|04|05|06|07|08|09|10|11|12|
2008|01|02|03|04|05|06|07|08|09|10|11|12|
2009|01|02|03|04|05|06|07|08|09|11|12|
2010|03|04|12|
2011|02|03|04|06|08|09|10|

2007-11-08 小春日和 [長年日記]

_ Emacs flymake-mode for Haskell

[2007-11-11] The setting is improved and works well. Please refer to EmacsWiki:FlymakeHaskell. The following description was OBSOLETED!.

flymake is a great tool for hacking which enables on-the-fly syntax checks of the files being edited using the external syntax check tool (usually the compiler).

Here is an extension of flymake for Haskell using ghc. Happy Haskell hacking as you like!

(require 'flymake)
  
;; flymake for Haskell
(defun flymake-Haskell-init ()
  (flymake-simple-make-init-impl
    'flymake-create-temp-with-folder-structure nil nil
    buffer-file-name
    'flymake-get-Haskell-cmdline))
(defun flymake-get-Haskell-cmdline (source base-dir)
  (list "ghc" (list "--make" "-fno-code" (concat "-i" base-dir) source)))          
(push '(".+\\.hs$" flymake-Haskell-init)
  flymake-allowed-file-name-masks)
(push '(".+\\.lhs$" flymake-Haskell-init)
  flymake-allowed-file-name-masks)
(push '("^\\(.*\\):\\([0-9]+\\):\\([0-9]+\\): \\(.*\\)$" 1 2 3 4)
  flymake-err-line-patterns)

[2007-11-08 22:30] After announcement on Haskell-Cafe, Thomas Schilling suggested to add the '-fno-code' flag to speed-up type checking. He also considered about the multi-line pattern matching problem on Emacs. Thanks Thomas! His advice has been already included in the above snippet.

Flymake displays warning/error messages at the pop-up window. If you do not use XEmacs, then try credmp's flymake-display-err-minibuf. I like the following setting.

(add-hook
 'haskell-mode-hook
 '(lambda () 
    (define-key haskell-mode-map "\C-cd" 
      'credmp/flymake-display-err-minibuf)))

TODO:

  • display warnings with -Wall option. Because some errors have several lines, we need a new buffer to show them.

P.S.

I'm not an expert in emacsen and referred to EmacsWiki: MultilineRegexp. However, the following setting does not work. Could you modify the above code and put into EmacsWiki: FlymakeHaskell, please?

(push
  '("^\\(.*\.hs\\|\.lhs\\):\\([0-9]+\\):\\([0-9]+\\):\\(\\(.*\n?\\)*\\)" 
   1 2 3 4) flymake-err-line-patterns)

The above demo video was created with the first implementation. The speed for type checking is now improved by Thomas's suggestion. I'm satisfied very much.


出現予定(召喚方法 ikegami@madscientist.jp):

RSS feed を再開しました。RSS の思想を尊重するために全文配信はしません、あしからず。