My開発メモ

haskell-modeでエラー “error Mispaced t or ‘otherwise’ clause” (Emacs)

haskellのコードを書いて、それを Emacs で開くと、次のようなエラーが出た。

Warning (comp): ~/.emacs.d/elpa/haskell-mode-17.2/haskell-commands.el: Error: error Misplaced t or ‘otherwise’ clause

“emacs haskell-mode error misplaced t or otherwise”
で検索したら、以下のページがヒットした。

Correct parenthese matching error #1784

以下のようなことが書かれていて、修正前と修正後のコードが書かれていた。

The emacs upstream will raise an error now when otherwise or t clause is not the last clause in a cl-case. There is a such cl-case in haskell-commands.el which is apparently a typo and should be fixed.

emacs アップストリームは、otherwise または t 節が cl-case の最後の節ではない場合にエラーを発生させるようになりました。haskell-commands.el にはそのような cl-case がありますが、これは明らかにタイプミスであり、修正する必要があります。

以下のコードのパーレンがまちがい。

haskell-commands.el — 修正前
(let* (...)
  (cl-case 
    ...
    (otherwise
      (if ...
        ...
        (haskell-command-echo-or-present response)))          ; <==
    (haskell-utils-async-stop-watching-changes init-buffer))) ; <==

次のように修正する。

haskell-command.el — 修正コード(1)
(let* (...)
  (cl-case 
    ...
    (otherwise
      (if ...
        ...
        (haskell-command-echo-or-present response))))          ; <==
  (haskell-utils-async-stop-watching-changes init-buffer))     ; <==

しかし、”Instead now your PR results in this:” という言葉とともに
次の修正コードも提示されていた。

haskell-command.el — 修正コード(2)
(let* (...)
  (cl-case 
    ...
    (otherwise
      (if ...
        ...
        (haskell-command-echo-or-present response))               ; <==
      (haskell-utils-async-stop-watching-changes init-buffer))))  ; <==

どちらが適切なのかわからなかった。
両方試したが、どちらとも、以下のような警告が出た。

File mode specification error: (void-function turn-on-haskell-ghci)
(この警告の意味は、今のところよくわからない)

GitHubの当該のコードは、修正コード(1)と同じだった。

結局、修正コード(1) を採用し、バイトコンパイルした。

M-x byte-compile-file: haskell-commands.el

とりあえず、この状態でしばらく続けてみる。

カテゴリー: Emacs, Haskell, memo

タグ: haskell-mode, haskell-mode-error

カウント: 37