using ghc-modi for C-cC-i.

This commit is contained in:
Kazu Yamamoto 2014-04-19 20:48:26 +09:00
parent 122c8da7b0
commit f8be944f12
3 changed files with 24 additions and 23 deletions

View File

@ -9,6 +9,7 @@
;;; Code:
(require 'ghc-func)
(require 'ghc-process)
(defun ghc-show-info (&optional ask)
(interactive "P")
@ -21,10 +22,9 @@
(lambda () (insert info))))))
(defun ghc-get-info (expr)
(let* ((modname (or (ghc-find-module-name) "Main"))
(file (buffer-file-name))
(cmds (list "info" file modname expr)))
(ghc-run-ghc-mod cmds)))
(let* ((file (buffer-file-name))
(cmd (format "info %s %s\n" file expr)))
(car (ghc-sync-process (lambda () cmd)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;

View File

@ -10,9 +10,6 @@
;;; Code:
(defvar ghc-ins-mod-rendezvous nil)
(defvar ghc-ins-mod-results nil)
(defun ghc-insert-module ()
(interactive)
(let* ((expr0 (ghc-things-at-point))
@ -76,21 +73,7 @@
(forward-line)))
(defun ghc-function-to-modules (fun)
(setq ghc-ins-mod-rendezvous nil)
(setq ghc-ins-mod-results nil)
(ghc-with-process
(lambda () (ghc-ins-mod-send fun))
'ghc-ins-mod-callback)
(while (null ghc-ins-mod-rendezvous)
(sit-for 0.01))
ghc-ins-mod-results)
(defun ghc-ins-mod-send (fun)
(concat "find " fun "\n"))
(defun ghc-ins-mod-callback ()
(let ((mods (ghc-read-lisp-this-buffer)))
(setq ghc-ins-mod-rendezvous t)
(setq ghc-ins-mod-results mods)))
(let ((cmd (format "find %s\n" fun)))
(ghc-sync-process (lambda () cmd))))
(provide 'ghc-ins-mod)

View File

@ -87,6 +87,24 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar ghc-process-rendezvous nil)
(defvar ghc-process-results nil)
(defun ghc-sync-process (send)
(setq ghc-process-rendezvous nil)
(setq ghc-process-results nil)
(ghc-with-process send 'ghc-process-callback)
(while (null ghc-process-rendezvous)
(sit-for 0.01))
ghc-process-results)
(defun ghc-process-callback ()
(let ((mods (ghc-read-lisp-this-buffer)))
(setq ghc-process-results mods)
(setq ghc-process-rendezvous t)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun ghc-kill-process ()
(interactive)
(let* ((name ghc-process-process-name)