Emacsのhaskell-modeでGHCi使用時にエラー行だけじゃなくエラー箇所に飛ぶパッチ
Haskell Modeでは、C-c C-rやC-c C-nでエラーの行に飛んでくれるけど、どうせなら行頭でなくてエラーの桁まで飛んで欲しい。パッチというほどの修正じゃないけど。
--- haskell-ghci.el.orig 2006-05-18 07:03:25.000000000 +0900 +++ haskell-ghci.el 2007-04-07 11:47:50.203125000 +0900 @@ -295,20 +295,24 @@ (progn (pop-to-buffer haskell-ghci-process-buffer) (goto-char haskell-ghci-error-pos) (if (re-search-forward - "^[^\/]*\\([^:\n]+\\):\\([0-9]+\\)" nil t) + "^[^\/]*\\([^:\n]+\\):\\([0-9]+\\):\\([0-9]+\\)" nil t) (let ((efile (buffer-substring (match-beginning 1) (match-end 1))) (eline (string-to-int (buffer-substring (match-beginning 2) - (match-end 2))))) - + (match-end 2)))) + (ecol (string-to-int + (buffer-substring (match-beginning 3) + (match-end 3))))) + (recenter 2) (setq haskell-ghci-error-pos (point)) - (message "GHCi error on line %d of %s." - eline (file-name-nondirectory efile)) + (message "GHCi error on line %d, column %d of %s." + eline ecol (file-name-nondirectory efile)) (if (file-exists-p efile) (progn (find-file-other-window efile) (goto-line eline) + (move-to-column ecol) (recenter)))) ;; We got an error without a file and line number, so put the
これは、GHCiのエラーメッセージが
/tmp/Hoge.hs:1:9: Not a constructor: `forall'
のように、桁(この場合9)まで出る前提だけど、ほんとにいつも出るんでしょうかね。
※元ファイルのインデントにタブがあったのがスペースになってるので、patchコマンドでは-lしてください。