diff --git a/elisp/ghc-info.el b/elisp/ghc-info.el index 4e763d8..c6b3c72 100644 --- a/elisp/ghc-info.el +++ b/elisp/ghc-info.el @@ -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))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; diff --git a/elisp/ghc-ins-mod.el b/elisp/ghc-ins-mod.el index 5285d3f..5c02693 100644 --- a/elisp/ghc-ins-mod.el +++ b/elisp/ghc-ins-mod.el @@ -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) diff --git a/elisp/ghc-process.el b/elisp/ghc-process.el index d220d6f..3a339ef 100644 --- a/elisp/ghc-process.el +++ b/elisp/ghc-process.el @@ -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)