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

View File

@ -10,9 +10,6 @@
;;; Code: ;;; Code:
(defvar ghc-ins-mod-rendezvous nil)
(defvar ghc-ins-mod-results nil)
(defun ghc-insert-module () (defun ghc-insert-module ()
(interactive) (interactive)
(let* ((expr0 (ghc-things-at-point)) (let* ((expr0 (ghc-things-at-point))
@ -76,21 +73,7 @@
(forward-line))) (forward-line)))
(defun ghc-function-to-modules (fun) (defun ghc-function-to-modules (fun)
(setq ghc-ins-mod-rendezvous nil) (let ((cmd (format "find %s\n" fun)))
(setq ghc-ins-mod-results nil) (ghc-sync-process (lambda () cmd))))
(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)))
(provide 'ghc-ins-mod) (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 () (defun ghc-kill-process ()
(interactive) (interactive)
(let* ((name ghc-process-process-name) (let* ((name ghc-process-process-name)