ESC C-e to process the module.
This commit is contained in:
parent
35f60507c6
commit
e9c4ec4e4b
@ -131,26 +131,44 @@
|
||||
(defun ghc-completion-start-point ()
|
||||
(save-excursion
|
||||
(let ((beg (save-excursion (beginning-of-line) (point))))
|
||||
(if (search-backward " " beg t)
|
||||
(if (re-search-backward "[ (,`]" beg t)
|
||||
(1+ (point))
|
||||
beg))))
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;
|
||||
;;; Loading keywords
|
||||
;;;
|
||||
|
||||
(defun ghc-load-module (mod)
|
||||
(when (and (member mod ghc-module-names)
|
||||
(not (member mod ghc-loaded-module)))
|
||||
(let ((keywords (ghc-load-keyword "browse" mod)))
|
||||
(when (or (consp keywords) (null keywords))
|
||||
(set (intern (concat ghc-keyword-prefix mod)) keywords)
|
||||
(setq ghc-loaded-module (cons mod ghc-loaded-module))))))
|
||||
|
||||
(defun ghc-merge-keywords ()
|
||||
(let* ((modkeys (mapcar 'ghc-module-keyword ghc-loaded-module))
|
||||
(keywords (cons ghc-reserved-keyword modkeys))
|
||||
(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
|
||||
;;;
|
||||
|
||||
(defun ghc-idle-timer ()
|
||||
(let ((mods (ghc-gather-import-modules))
|
||||
keywords)
|
||||
(dolist (mod mods)
|
||||
(when (and (member mod ghc-module-names)
|
||||
(not (member mod ghc-loaded-module)))
|
||||
(setq keywords (ghc-load-keyword "browse" mod))
|
||||
(when (or (consp keywords) (null keywords))
|
||||
(set (intern (concat ghc-keyword-prefix mod)) keywords)
|
||||
(setq ghc-loaded-module (cons mod ghc-loaded-module)))))
|
||||
(ghc-merge-keywords)))
|
||||
(dolist (mod (ghc-gather-import-modules))
|
||||
(ghc-load-module mod))
|
||||
(ghc-merge-keywords))
|
||||
|
||||
(defun ghc-gather-import-modules ()
|
||||
(let ((bufs (mapcar 'buffer-name (buffer-list)))
|
||||
@ -171,12 +189,6 @@
|
||||
(forward-line)))
|
||||
ret))
|
||||
|
||||
(defun ghc-merge-keywords ()
|
||||
(let* ((modkeys (mapcar 'ghc-module-keyword ghc-loaded-module))
|
||||
(keywords (cons ghc-reserved-keyword modkeys))
|
||||
(uniq-sorted (sort (ghc-uniq-lol keywords) 'string<)))
|
||||
(setq ghc-merged-keyword uniq-sorted)))
|
||||
|
||||
(defun ghc-module-keyword (mod)
|
||||
(symbol-value (intern (concat ghc-keyword-prefix mod))))
|
||||
|
||||
|
@ -18,13 +18,6 @@
|
||||
(pkg (ghc-resolve-package-name mod)))
|
||||
(ghc-display-document pkg mod)))
|
||||
|
||||
(defun ghc-extract-module ()
|
||||
(interactive)
|
||||
(save-excursion
|
||||
(beginning-of-line)
|
||||
(when (looking-at "^import +\\([^ \n]+\\)")
|
||||
(match-string-no-properties 1))))
|
||||
|
||||
(defun ghc-resolve-package-name (mod)
|
||||
(with-temp-buffer
|
||||
(call-process "ghc-pkg" nil t nil "find-module" "--simple-output" mod)
|
||||
@ -57,8 +50,5 @@
|
||||
(make-sparse-keymap)))
|
||||
(define-key ghc-input-map "\t" 'ghc-complete))
|
||||
|
||||
(defun ghc-read-module-name (def)
|
||||
(read-from-minibuffer "Module name: " def ghc-input-map))
|
||||
|
||||
|
||||
(provide 'ghc-doc)
|
@ -38,4 +38,14 @@
|
||||
(read (current-buffer))
|
||||
(error ()))))
|
||||
|
||||
(defun ghc-extract-module ()
|
||||
(interactive)
|
||||
(save-excursion
|
||||
(beginning-of-line)
|
||||
(if (looking-at "^import +\\(qualified +\\)?\\([^ (\n]+\\)")
|
||||
(match-string-no-properties 2))))
|
||||
|
||||
(defun ghc-read-module-name (def)
|
||||
(read-from-minibuffer "Module name: " def ghc-input-map))
|
||||
|
||||
(provide 'ghc-func)
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
(defvar ghc-completion-key "\e\t")
|
||||
(defvar ghc-document-key "\e\C-d")
|
||||
(defvar ghc-import-key "\e\C-e")
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;
|
||||
@ -39,6 +40,7 @@
|
||||
(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)
|
||||
(ghc-comp-init)
|
||||
(setq ghc-initialized t)))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user