From 406a402fd9833628257c586fb07679a99f459619 Mon Sep 17 00:00:00 2001 From: Kirill Ignatiev Date: Wed, 21 Jan 2015 17:59:53 -0500 Subject: [PATCH 1/2] Don't start haskell process in completion function It is somewhat intrusive, because it happens the moment you open a new file without a session attached. --- haskell.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/haskell.el b/haskell.el index 80ad3585b..eb40e9285 100644 --- a/haskell.el +++ b/haskell.el @@ -57,9 +57,9 @@ (defun haskell-process-completions-at-point () "A completion-at-point function using the current haskell process." - (let ((process (haskell-process)) - (symbol (symbol-at-point))) - (when (and process symbol) + (when (haskell-session-maybe) + (let ((process (haskell-process)) + (symbol (symbol-at-point))) (cl-destructuring-bind (start . end) (bounds-of-thing-at-point 'symbol) (let ((completions (haskell-process-get-repl-completions process From 0acebe27b664603ef81ec7f6bbb4e20cf05bc057 Mon Sep 17 00:00:00 2001 From: Kirill Ignatiev Date: Wed, 21 Jan 2015 18:28:02 -0500 Subject: [PATCH 2/2] Allow module name completion in import statements --- haskell.el | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/haskell.el b/haskell.el index eb40e9285..c2df62781 100644 --- a/haskell.el +++ b/haskell.el @@ -58,13 +58,25 @@ (defun haskell-process-completions-at-point () "A completion-at-point function using the current haskell process." (when (haskell-session-maybe) - (let ((process (haskell-process)) - (symbol (symbol-at-point))) - (cl-destructuring-bind (start . end) (bounds-of-thing-at-point 'symbol) - (let ((completions (haskell-process-get-repl-completions - process - (symbol-name symbol)))) - (list start end completions)))))) + (let ((process (haskell-process)) symbol) + (cond + ;; ghci can complete module names, but it needs the "import " + ;; string at the beginning + ((looking-back (rx line-start + "import" (1+ space) + (? "qualified" (1+ space)) + (group (? (char upper) ; modid + (* (char alnum ?' ?.)))))) + (let ((text (match-string-no-properties 0)) + (start (match-beginning 1)) + (end (match-end 1))) + (list start end + (haskell-process-get-repl-completions process text)))) + ((setq symbol (symbol-at-point)) + (cl-destructuring-bind (start . end) (bounds-of-thing-at-point 'symbol) + (let ((completions (haskell-process-get-repl-completions + process (symbol-name symbol)))) + (list start end completions)))))))) ;;;###autoload (defun haskell-interactive-mode-return ()