From ac31e6edc27e252c984ab4be1df205b09866876f Mon Sep 17 00:00:00 2001 From: Sergey Vinokurov Date: Sun, 17 May 2015 23:22:05 +0300 Subject: [PATCH] don't silently ignore case when ghc process is already running in ghc-with-process --- elisp/ghc-process.el | 45 +++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/elisp/ghc-process.el b/elisp/ghc-process.el index b44416e..0519549 100644 --- a/elisp/ghc-process.el +++ b/elisp/ghc-process.el @@ -18,7 +18,8 @@ (defvar-local ghc-process-original-buffer nil) (defvar-local ghc-process-original-file nil) (defvar-local ghc-process-callback nil) -(defvar-local ghc-process-hook nil) +(defvar-local ghc-process-hook nil + "Hook that will be called upon successfull completion of ghc-mod command.") (defvar ghc-command "ghc-mod") @@ -30,26 +31,28 @@ (defun ghc-with-process (cmd callback &optional hook1 hook2) (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) - (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-callback callback) - (setq ghc-process-hook hook2) - (erase-buffer) - (let ((pro (ghc-get-process cpro name buf))) - (process-send-string pro cmd) - (when ghc-debug - (ghc-with-debug-buffer - (insert (format "%% %s" cmd)))) - pro))))) + (if ghc-process-running + (error "ghc process already running") + (progn + (when 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-callback callback) + (setq ghc-process-hook hook2) + (erase-buffer) + (let ((pro (ghc-get-process cpro name buf))) + (process-send-string pro cmd) + (when ghc-debug + (ghc-with-debug-buffer + (insert (format "%% %s" cmd)))) + pro)))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;