2014-11-05 45 views
2

我希望GHCI有當地的cabal沙箱範圍,當我在emacs工作。 從bash中,語法如下:ghci cabal沙箱標誌Emacs Haskell劣勢

ghci -no-user-package-db -package-db .cabal-sandbox/*-packages.conf.d

我添加了標誌,以INF-haskell.el的haskell-program-name的定義中,如下所示:

(defcustom haskell-program-name 
    (or (cond 
    ((executable-find "hugs") "hugs \"+.\"") 
    ((executable-find "ghci") "ghci -no-user-package-db -package-db .cabal-sandbox/*-packages.conf.d")) 
    "hugs \"+.\"") 
    "The name of the command to start the inferior Haskell process. 
    The command can include arguments." 
    ;; Custom only supports the :options keyword for a few types, e.g. not 
    ;; for string. 
    ;; :options '("hugs \"+.\"" "ghci") 
     :group 'inferior-haskell 
     :type '(choice string (repeat string))) 

,但它不」 t似乎工作,即重新加載emacs後,檢查值C-h v haskell-program-name只顯示它等於"ghci",我需要的包當然不在範圍內。 任何指針?謝謝!

+3

您應該使用'cabal repl'而不是手動啓動帶有沙盒的ghci,並配置emacs以使用cabal repl('custom-set-variables'(haskell-process-type'cabal-repl))' – user2407038 2014-11-06 00:26:32

+0

Thanks for這個好主意,但這也意味着爲每一個小腳本建立一個cabal項目。我只想嘗試一些我無法在全球安裝的庫。 Cabal地獄,你知道 – ocramz 2014-11-06 18:55:47

回答

1

很多的戰鬥後,我們終於想通了:relevant Github issue

如果你有haskell-process-type設置爲auto,並擁有最新的(> = 1.20.x)cabal-install在你的路徑,運行C-c C-l將開啓emacs中的cabal repl(即使你沒有.cabal文件)並檢測你的沙箱。這可以讓你扔下沙箱,快速安裝一個庫,然後在emacs中交互式地玩弄它。

祝你好運!

+0

好主席先生,你是一位真正的紳士。我一回到箱子就會看到這個。 – ocramz 2015-01-06 11:49:17

+0

@ocramz好運? – 2015-01-10 22:05:46

+0

唉,沒有。我有cabal-install 1.20.0.3,這是我的'init.el'配置: (自動加載'ghc-init「ghc」 '鉤'haskell-mode-hook(lambda()(ghc-init))) (自定義設置變量'(haskell-process-type-'自動)) (add-hook'after-init- 'global-flycheck-mode) – ocramz 2015-01-13 21:16:00