From 52016b621061b1b2808dc7cd460f2d4d62093f00 Mon Sep 17 00:00:00 2001 From: Kazu Yamamoto Date: Mon, 14 Sep 2015 15:02:34 +0900 Subject: [PATCH] using ghc-get-project-root only when it is necessary. --- elisp/ghc-process.el | 94 ++++++++++++++++++++++---------------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/elisp/ghc-process.el b/elisp/ghc-process.el index c41e11a..8ca481b 100644 --- a/elisp/ghc-process.el +++ b/elisp/ghc-process.el @@ -35,53 +35,53 @@ (ghc-run-ghc-mod '("root"))) (defun ghc-with-process (cmd callback &optional hook1 hook2) - (let ((root (ghc-get-project-root))) - (unless ghc-process-process-name - (setq ghc-process-process-name root)) - (when (and ghc-process-process-name (not ghc-process-running)) - (setq ghc-process-running t) - (if hook1 (funcall hook1)) - (let* ((cbuf (current-buffer)) - (name ghc-process-process-name) - (buf (get-buffer-create (concat " ghc-mod:" name))) - (file (buffer-file-name)) - (cpro (get-process name))) - (ghc-with-current-buffer buf - (setq ghc-process-original-buffer cbuf) - (setq ghc-process-original-file file) - (setq ghc-process-hook hook2) - (setq ghc-process-root root) - (let ((pro (ghc-get-process cpro name buf)) - (map-cmd (format "map-file %s\n" file))) - ;; map-file - (setq ghc-process-file-mapping t) - (setq ghc-process-callback nil) - (erase-buffer) - (when ghc-debug - (ghc-with-debug-buffer - (insert (format "%% %s" map-cmd)) - (insert "CONTENTS + EOT\n"))) - (process-send-string pro map-cmd) - (with-current-buffer cbuf - (save-restriction - (widen) - (process-send-region pro (point-min) (point-max)))) - (process-send-string pro "\004\n") - (condition-case nil - (let ((inhibit-quit nil)) - (while ghc-process-file-mapping - (accept-process-output pro 0.1 nil t))) - (quit - (setq ghc-process-running nil) - (setq ghc-process-file-mapping nil))) - ;; command - (setq ghc-process-callback callback) - (erase-buffer) - (when ghc-debug - (ghc-with-debug-buffer - (insert (format "%% %s" cmd)))) - (process-send-string pro cmd) - pro)))))) + (unless ghc-process-process-name + (setq ghc-process-process-name (ghc-get-project-root))) + (when (and ghc-process-process-name (not ghc-process-running)) + (setq ghc-process-running t) + (if hook1 (funcall hook1)) + (let* ((cbuf (current-buffer)) + (name ghc-process-process-name) + (root ghc-process-process-name) + (buf (get-buffer-create (concat " ghc-mod:" name))) + (file (buffer-file-name)) + (cpro (get-process name))) + (ghc-with-current-buffer buf + (setq ghc-process-original-buffer cbuf) + (setq ghc-process-original-file file) + (setq ghc-process-hook hook2) + (setq ghc-process-root root) + (let ((pro (ghc-get-process cpro name buf)) + (map-cmd (format "map-file %s\n" file))) + ;; map-file + (setq ghc-process-file-mapping t) + (setq ghc-process-callback nil) + (erase-buffer) + (when ghc-debug + (ghc-with-debug-buffer + (insert (format "%% %s" map-cmd)) + (insert "CONTENTS + EOT\n"))) + (process-send-string pro map-cmd) + (with-current-buffer cbuf + (save-restriction + (widen) + (process-send-region pro (point-min) (point-max)))) + (process-send-string pro "\004\n") + (condition-case nil + (let ((inhibit-quit nil)) + (while ghc-process-file-mapping + (accept-process-output pro 0.1 nil t))) + (quit + (setq ghc-process-running nil) + (setq ghc-process-file-mapping nil))) + ;; command + (setq ghc-process-callback callback) + (erase-buffer) + (when ghc-debug + (ghc-with-debug-buffer + (insert (format "%% %s" cmd)))) + (process-send-string pro cmd) + pro))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;