emacs22でhaskell-mode2.4を動かす

先日の emacsのhaskellモードでC-cC-lで自動的にmainを評価し、更にカーソルを編集バッファにとどまらせる - 計算機と戯れる日々haskell-mode-2.3でやったみたいだ。
どうも最新は2.4になってる。
http://www.iro.umontreal.ca/~monnier/elisp/#haskell-mode

ということでそのまま差し替えてみたのだが変わっている点は

  • C-cC-lでソースをロードした後カーソルがソースのウィンドウのまま
  • 変数haskell-ghci-commandにmainをいれておいても自動実行しない

これは困った。調べてみたところ haskell- ghci.elには差分が存在しない。
そしてhaskell-mode.elに以下の記述を発見した。

!     ;; I think it makes sense to bind inferior-haskell-load-and-run to C-c
!     ;; C-r, but since it used to be bound to `reload' until june 2007, I'm
!     ;; going to leave it out for now.
!     ;; (define-key map [?\C-c ?\C-r] 'inferior-haskell-load-and-run)

C-cC-lをinferior-haskell-load-and-runに割り当てればいいい事がわかったので

$ diff -c haskell-site-file.el.orig haskell-site-file.el
*** haskell-site-file.el.orig   2007-12-16 17:43:16.000000000 +0900
--- haskell-site-file.el        2007-12-16 17:43:35.000000000 +0900
***************
*** 217,222 ****
--- 217,228 ----

  \(fn &optional RELOAD)" t nil)

+ (autoload 'inferior-haskell-load-and-run "inf-haskell" "\
+ Pass the current buffer's file to the inferior haskell process.
+ If prefix arg \\[universal-argument] is given, just reload the previous file.
+
+ \(fn &optional RELOAD)" t nil)
+
  (autoload 'inferior-haskell-type "inf-haskell" "\
  Query the haskell process for the type of the given expression.
  If optional argument `insert-value' is non-nil, insert the type above point
$ diff -c haskell-mode.el.orig haskell-mode.el
*** haskell-mode.el.orig        2007-12-16 17:21:34.000000000 +0900
--- haskell-mode.el     2007-12-16 17:40:45.000000000 +0900
***************
*** 260,266 ****
      ;; (define-key map [?\C-x ?\C-e] 'inferior-haskell-send-last-sexp)
      ;; (define-key map [?\C-c ?\C-r] 'inferior-haskell-send-region)
      (define-key map [?\C-c ?\C-z] 'switch-to-haskell)
!     (define-key map [?\C-c ?\C-l] 'inferior-haskell-load-file)
      ;; I think it makes sense to bind inferior-haskell-load-and-run to C-c
      ;; C-r, but since it used to be bound to `reload' until june 2007, I'm
      ;; going to leave it out for now.
--- 260,267 ----
      ;; (define-key map [?\C-x ?\C-e] 'inferior-haskell-send-last-sexp)
      ;; (define-key map [?\C-c ?\C-r] 'inferior-haskell-send-region)
      (define-key map [?\C-c ?\C-z] 'switch-to-haskell)
!     ;(define-key map [?\C-c ?\C-l] 'inferior-haskell-load-file)
!     (define-key map [?\C-c ?\C-l] 'inferior-haskell-load-and-run)
      ;; I think it makes sense to bind inferior-haskell-load-and-run to C-c
      ;; C-r, but since it used to be bound to `reload' until june 2007, I'm
      ;; going to leave it out for now.

どうも作者自身がinferior-haskell-load-and-runを既に使ってないみたい。なので*.hsを読んだだけの状態ではload-and-runがautoloadされていない。
ローカルマップのキーバインドの差し替え方法がわからなかったのでhaskell-mode.elの方は.emacsで解決できるかも。

あと inf-haskell.el:(defvar inferior-haskell-run-command ":main") の記述があるので
.emacsは以下の記述のみで良くなった。

(load "~/lib/emacs/haskell-mode/haskell-site-file")
(add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indent)
(add-hook 'haskell-mode-hook 'font-lock-mode)
(add-hook 'haskell-mode-hook 'turn-on-haskell-ghci