From ef266374c0cf388c9a0d8737f9f5bcd7bf16a6e2 Mon Sep 17 00:00:00 2001 From: Kazu Yamamoto Date: Mon, 31 Mar 2014 16:04:44 +0900 Subject: [PATCH] defining ghc-preferred-modules. --- elisp/ghc-ins-mod.el | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/elisp/ghc-ins-mod.el b/elisp/ghc-ins-mod.el index ce657f0..f4dc16a 100644 --- a/elisp/ghc-ins-mod.el +++ b/elisp/ghc-ins-mod.el @@ -19,13 +19,25 @@ (expr (ghc-read-expression expr0))) (ghc-ins-mod expr))) +(defvar ghc-preferred-modules '("Control.Applicative" + "Data.ByteString" + "Data.Text" + "Text.Parsec")) + +(defun ghc-reorder-modules (mods) + (catch 'loop + (dolist (pmod ghc-preferred-modules) + (if (member pmod mods) + (throw 'loop (cons pmod (delete pmod mods))))) + mods)) + (defun ghc-ins-mod (expr) (let (prefix fun mods) (if (not (string-match "^\\([^.]+\\)\\\.\\([^.]+\\)$" expr)) (setq fun expr) (setq prefix (match-string 1 expr)) (setq fun (match-string 2 expr))) - (setq mods (ghc-function-to-modules fun)) + (setq mods (ghc-reorder-modules (ghc-function-to-modules fun))) (if (null mods) (message "No module guessed") (let* ((key (or prefix fun))