From 19453e67d7c55b7be7871e20a25d48c89ec02028 Mon Sep 17 00:00:00 2001 From: Kazu Yamamoto Date: Mon, 21 Apr 2014 09:46:33 +0900 Subject: [PATCH] ghc-with-process now takes string for the first argument. --- elisp/ghc-check.el | 18 +++++++++--------- elisp/ghc-info.el | 4 ++-- elisp/ghc-ins-mod.el | 2 +- elisp/ghc-process.el | 9 ++++----- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/elisp/ghc-check.el b/elisp/ghc-check.el index 06d38f5..ff46d9f 100644 --- a/elisp/ghc-check.el +++ b/elisp/ghc-check.el @@ -46,21 +46,21 @@ nil does not display errors/warnings. (defun ghc-check-syntax () (interactive) - (ghc-with-process 'ghc-check-send 'ghc-check-callback)) + (setq mode-line-process " -:-") ;; fixme + (ghc-with-process (ghc-check-send) 'ghc-check-callback)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (ghc-defstruct hilit-info file line msg err) (defun ghc-check-send () - (with-current-buffer ghc-process-original-buffer - (setq mode-line-process " -:-")) - (if ghc-check-command - (let ((opts (ghc-haskell-list-of-string ghc-hlint-options))) - (if opts - (concat "lint " opts " " ghc-process-original-file "\n") - (concat "lint " ghc-process-original-file "\n"))) - (concat "check " ghc-process-original-file "\n"))) + (let ((file (buffer-file-name))) + (if ghc-check-command + (let ((opts (ghc-haskell-list-of-string ghc-hlint-options))) + (if opts + (format "lint %s %s\n" opts file) + (format "lint %s\n" file))) + (format "check %s\n" file)))) (defun ghc-haskell-list-of-string (los) (when los diff --git a/elisp/ghc-info.el b/elisp/ghc-info.el index 2f7579f..0fad9c9 100644 --- a/elisp/ghc-info.el +++ b/elisp/ghc-info.el @@ -24,7 +24,7 @@ (defun ghc-get-info (expr) (let* ((file (buffer-file-name)) (cmd (format "info %s %s\n" file expr))) - (car (ghc-sync-process (lambda () cmd))))) + (ghc-sync-process cmd))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; @@ -111,7 +111,7 @@ (cn (int-to-string (1+ (current-column)))) (file (buffer-file-name)) (cmd (format "type %s %s %s\n" file ln cn))) - (ghc-sync-process (lambda () cmd)))) + (ghc-sync-process cmd))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; diff --git a/elisp/ghc-ins-mod.el b/elisp/ghc-ins-mod.el index 5c02693..14db867 100644 --- a/elisp/ghc-ins-mod.el +++ b/elisp/ghc-ins-mod.el @@ -74,6 +74,6 @@ (defun ghc-function-to-modules (fun) (let ((cmd (format "find %s\n" fun))) - (ghc-sync-process (lambda () cmd)))) + (ghc-sync-process cmd))) (provide 'ghc-ins-mod) diff --git a/elisp/ghc-process.el b/elisp/ghc-process.el index 3a339ef..f16e614 100644 --- a/elisp/ghc-process.el +++ b/elisp/ghc-process.el @@ -31,7 +31,7 @@ (when (looking-at "^\\(.*\\)$") (match-string-no-properties 1)))))) -(defun ghc-with-process (send callback) +(defun ghc-with-process (cmd callback) (unless ghc-process-process-name (setq ghc-process-process-name (ghc-get-project-root))) (when ghc-process-process-name @@ -47,8 +47,7 @@ (setq ghc-process-original-file file) (setq ghc-process-callback callback) (erase-buffer) - (let ((pro (ghc-get-process cpro name buf)) - (cmd (funcall send))) + (let ((pro (ghc-get-process cpro name buf))) (process-send-string pro cmd) (when ghc-debug (ghc-with-debug-buffer @@ -90,10 +89,10 @@ (defvar ghc-process-rendezvous nil) (defvar ghc-process-results nil) -(defun ghc-sync-process (send) +(defun ghc-sync-process (cmd) (setq ghc-process-rendezvous nil) (setq ghc-process-results nil) - (ghc-with-process send 'ghc-process-callback) + (ghc-with-process cmd 'ghc-process-callback) (while (null ghc-process-rendezvous) (sit-for 0.01)) ghc-process-results)