diff --git a/elisp/ghc-comp.el b/elisp/ghc-comp.el index 5b68f74..ad61284 100644 --- a/elisp/ghc-comp.el +++ b/elisp/ghc-comp.el @@ -47,9 +47,16 @@ (defvar ghc-loaded-module nil) (defun ghc-comp-init () - (setq ghc-module-names (cons "hiding" (cons "qualified" (ghc-load-keyword "list")))) - (setq ghc-language-extensions (cons "LANGUAGE" (ghc-load-keyword "lang"))) - (setq ghc-keyword-Prelude (ghc-load-keyword "browse" "Prelude")) + (let* ((syms '(ghc-module-names + ghc-language-extensions + ghc-keyword-Prelude)) + (vals (ghc-read-lisp-list + (lambda () (call-process ghc-module-command nil t nil "-l" "boot")) + (length syms)))) + (ghc-set syms vals)) + (add-to-list 'ghc-module-names "qualified") + (add-to-list 'ghc-module-names "hiding") + (add-to-list 'ghc-language-extensions "LANGUAGE") (setq ghc-loaded-module '("Prelude")) (ghc-merge-keywords) (run-with-idle-timer ghc-idle-timer-interval 'repeat 'ghc-idle-timer)) diff --git a/elisp/ghc-func.el b/elisp/ghc-func.el index 38d6e89..788a815 100644 --- a/elisp/ghc-func.el +++ b/elisp/ghc-func.el @@ -41,6 +41,18 @@ (read (current-buffer)) (error ())))) +(defun ghc-read-lisp-list (func n) + (with-temp-buffer + (funcall func) + (goto-char (point-min)) + (condition-case nil + (let ((m (set-marker (make-marker) 1 (current-buffer))) + ret) + (dotimes (i n) + (setq ret (cons (read m) ret))) + (nreverse ret)) + (error ())))) + (defun ghc-extract-module () (interactive) (save-excursion @@ -51,10 +63,10 @@ (defun ghc-read-module-name (def) (read-from-minibuffer "Module name: " def ghc-input-map)) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defconst ghc-null 0) -(defconst ghc-newline 10) +(defun ghc-set (vars vals) + (dolist (var vars) + (if var (set var (car vals))) ;; var can be nil to skip + (setq vals (cdr vals)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;