diff --git a/elisp/ghc-comp.el b/elisp/ghc-comp.el index 6ffc2ec..a5fc466 100644 --- a/elisp/ghc-comp.el +++ b/elisp/ghc-comp.el @@ -162,6 +162,13 @@ ;;; Loading keywords ;;; +(add-hook 'find-file-hook 'ghc-load-module-buffer) + +(defun ghc-load-module-buffer () + (interactive) + (when (eq major-mode 'haskell-mode) + (mapc 'ghc-load-module (ghc-gather-import-modules-buffer)))) + (defun ghc-load-module (mod) (when (and (member mod ghc-module-names) (not (member mod ghc-loaded-module))) @@ -176,11 +183,6 @@ (uniq-sorted (sort (ghc-uniq-lol keywords) 'string<))) (setq ghc-merged-keyword uniq-sorted))) -(defun ghc-import-module () - (interactive) - (ghc-load-module (ghc-read-module-name (ghc-extract-module))) - (ghc-merge-keywords)) - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Background Idle Timer diff --git a/elisp/ghc-func.el b/elisp/ghc-func.el index 824b184..aa2aebc 100644 --- a/elisp/ghc-func.el +++ b/elisp/ghc-func.el @@ -42,8 +42,8 @@ (interactive) (save-excursion (beginning-of-line) - (if (looking-at "^import +\\(qualified +\\)?\\([^ (\n]+\\)") - (match-string-no-properties 2)))) + (if (looking-at "^\\(import\\|module\\) +\\(qualified +\\)?\\([^ (\n]+\\)") + (match-string-no-properties 3)))) (defun ghc-read-module-name (def) (read-from-minibuffer "Module name: " def ghc-input-map)) diff --git a/elisp/ghc.el b/elisp/ghc.el index 76eda8b..e7f6f01 100644 --- a/elisp/ghc.el +++ b/elisp/ghc.el @@ -27,7 +27,7 @@ (defvar ghc-completion-key "\e\t") (defvar ghc-document-key "\e\C-d") -(defvar ghc-import-key "\e\C-e") +(defvar ghc-import-key "\e\C-m") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; @@ -40,6 +40,6 @@ (unless ghc-initialized (define-key haskell-mode-map ghc-completion-key 'ghc-complete) (define-key haskell-mode-map ghc-document-key 'ghc-browse-document) - (define-key haskell-mode-map ghc-import-key 'ghc-import-module) + (define-key haskell-mode-map ghc-import-key 'ghc-load-module-buffer) (ghc-comp-init) (setq ghc-initialized t)))