ins-mod hack.
This commit is contained in:
parent
94be5c3760
commit
f5d3a9f650
@ -10,22 +10,27 @@
|
|||||||
|
|
||||||
(defvar ghc-hoogle-command "hoogle")
|
(defvar ghc-hoogle-command "hoogle")
|
||||||
|
|
||||||
|
(defvar ghc-hoogle-keywords '("data" "server" "combine" "convert" "test" "dump" "rank" "log"))
|
||||||
|
|
||||||
(defun ghc-insert-module ()
|
(defun ghc-insert-module ()
|
||||||
(interactive)
|
(interactive)
|
||||||
(if (not (ghc-which ghc-hoogle-command))
|
(if (not (ghc-which ghc-hoogle-command))
|
||||||
(message "%s not found" ghc-hoogle-command)
|
(message "\"%s\" not found" ghc-hoogle-command)
|
||||||
(let* ((expr0 (thing-at-point 'symbol))
|
(let* ((expr0 (thing-at-point 'symbol))
|
||||||
(expr (ghc-read-expression expr0))
|
(expr (ghc-read-expression expr0)))
|
||||||
(mods (ghc-function-to-modules expr))
|
(if (member expr ghc-hoogle-keywords)
|
||||||
(first (car mods))
|
(message "\"%s\" not allowed" expr)
|
||||||
|
(let ((mods (ghc-function-to-modules expr)))
|
||||||
|
(if (null mods)
|
||||||
|
(message "No module guessed")
|
||||||
|
(let* ((first (car mods))
|
||||||
(ini (cons first 0))
|
(ini (cons first 0))
|
||||||
(mod (if (= (length mods) 1)
|
(mod (if (= (length mods) 1)
|
||||||
first
|
first
|
||||||
(completing-read "Module name: " mods nil t ini))))
|
(completing-read "Module name: " mods nil t ini))))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(ghc-goto-module-position)
|
(ghc-goto-module-position)
|
||||||
(insert "import " mod "\n")
|
(insert "import " mod "\n")))))))))
|
||||||
(message "%s was inserted" mod)))))
|
|
||||||
|
|
||||||
(defun ghc-goto-module-position ()
|
(defun ghc-goto-module-position ()
|
||||||
(goto-char (point-max))
|
(goto-char (point-max))
|
||||||
|
Loading…
Reference in New Issue
Block a user