inserting qualified module.
This commit is contained in:
parent
2e2e8a8b99
commit
40a81cad74
@ -184,7 +184,8 @@
|
||||
(ghc-ins-mod sym)))
|
||||
((string-match "Not in scope: `\\([^'\n\0]+\\)'" data)
|
||||
(let ((sym (match-string 1 data)))
|
||||
(if (y-or-n-p (format "Import module for %s?" sym))
|
||||
(if (or (string-match "\\." sym) ;; qualified
|
||||
(y-or-n-p (format "Import module for %s?" sym)))
|
||||
(ghc-ins-mod sym)
|
||||
(unless (re-search-forward "^$" nil t)
|
||||
(goto-char (point-max))
|
||||
|
@ -20,13 +20,20 @@
|
||||
(ghc-ins-mod expr)))
|
||||
|
||||
(defun ghc-ins-mod (expr)
|
||||
(let ((mods (ghc-function-to-modules 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))
|
||||
(if (null mods)
|
||||
(message "No module guessed")
|
||||
(let ((mod (ghc-completing-read "Module name (%s): " mods)))
|
||||
(save-excursion
|
||||
(ghc-goto-module-position)
|
||||
(insert "import " mod " (" (ghc-enclose expr) ")\n"))))))
|
||||
(if prefix
|
||||
(insert "import qualified " mod " as " prefix "\n")
|
||||
(insert "import " mod " (" (ghc-enclose expr) ")\n")))))))
|
||||
|
||||
(defun ghc-completing-read (fmt lst)
|
||||
(let* ((def (car lst))
|
||||
|
Loading…
Reference in New Issue
Block a user