在cabal-repl和ghci之间切换haskell-process-type

时间:2014-12-05 09:52:31

标签: haskell emacs haskell-mode

我可以在活动的haskell会话期间或开始新会话时切换haskell-process-type吗?

2 个答案:

答案 0 :(得分:2)

是的,只需在缓冲区中输入以下内容,然后C-x C-e输入(假设cabal-repl是您的默认值)。

(setq haskell-process-type 'ghci)

在我的.emacs我实际上有这个让这很容易,因为我经常这样做:

(define-key haskell-mode-map (kbd "C-c h t") 
  (lambda () (interactive)
    (progn
      (setq haskell-process-type 'ghci)
      (message "Now in ghci mode."))))

然后另一个C-c C-l将使用正确的模式加载交互式缓冲区。

编辑:立即使用haskell-mode-map

答案 1 :(得分:2)

最后我延长了化石师的答案!

切换流程类型的功能:

(defvar haskell-process-use-ghci nil)

(defun haskell-process-toggle ()
  "Toggle GHCi process between cabal and ghci"
  (interactive)
  (if haskell-process-use-ghci
      (progn (setq haskell-process-type 'cabal-repl)
             (setq haskell-process-use-ghci nil)
             (message "Using cabal repl"))
    (progn (setq haskell-process-type 'ghci)
           (setq haskell-process-use-ghci t)
           (message "Using GHCi"))))

和haskell模式特定的键绑定:

(define-key haskell-mode-map (kbd "C-c C-h C-t") 'haskell-process-toggle)