making ghc-mod-running a global var (##255).
This commit is contained in:
parent
7af19f5400
commit
7d81a357f7
@ -12,7 +12,8 @@
|
|||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(defvar-local ghc-process-running nil)
|
(defvar ghc-process-running nil)
|
||||||
|
|
||||||
(defvar-local ghc-process-process-name nil)
|
(defvar-local ghc-process-process-name nil)
|
||||||
(defvar-local ghc-process-original-buffer nil)
|
(defvar-local ghc-process-original-buffer nil)
|
||||||
(defvar-local ghc-process-original-file nil)
|
(defvar-local ghc-process-original-file nil)
|
||||||
@ -29,7 +30,8 @@
|
|||||||
(defun ghc-with-process (cmd callback &optional hook1 hook2)
|
(defun ghc-with-process (cmd callback &optional hook1 hook2)
|
||||||
(unless ghc-process-process-name
|
(unless ghc-process-process-name
|
||||||
(setq ghc-process-process-name (ghc-get-project-root)))
|
(setq ghc-process-process-name (ghc-get-project-root)))
|
||||||
(when ghc-process-process-name
|
(when (and ghc-process-process-name (not ghc-process-running))
|
||||||
|
(setq ghc-process-running t)
|
||||||
(if hook1 (funcall hook1))
|
(if hook1 (funcall hook1))
|
||||||
(let* ((cbuf (current-buffer))
|
(let* ((cbuf (current-buffer))
|
||||||
(name ghc-process-process-name)
|
(name ghc-process-process-name)
|
||||||
@ -37,8 +39,6 @@
|
|||||||
(file (buffer-file-name))
|
(file (buffer-file-name))
|
||||||
(cpro (get-process name)))
|
(cpro (get-process name)))
|
||||||
(ghc-with-current-buffer buf
|
(ghc-with-current-buffer buf
|
||||||
(unless ghc-process-running
|
|
||||||
(setq ghc-process-running t)
|
|
||||||
(setq ghc-process-original-buffer cbuf)
|
(setq ghc-process-original-buffer cbuf)
|
||||||
(setq ghc-process-original-file file)
|
(setq ghc-process-original-file file)
|
||||||
(setq ghc-process-callback callback)
|
(setq ghc-process-callback callback)
|
||||||
@ -49,7 +49,7 @@
|
|||||||
(when ghc-debug
|
(when ghc-debug
|
||||||
(ghc-with-debug-buffer
|
(ghc-with-debug-buffer
|
||||||
(insert (format "%% %s" cmd))))
|
(insert (format "%% %s" cmd))))
|
||||||
pro))))))
|
pro)))))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
@ -69,6 +69,9 @@
|
|||||||
pro))
|
pro))
|
||||||
|
|
||||||
(defun ghc-process-filter (process string)
|
(defun ghc-process-filter (process string)
|
||||||
|
(let ((pbuf (process-buffer process)))
|
||||||
|
(if (not (get-buffer pbuf))
|
||||||
|
(setq ghc-process-running nil) ;; just in case
|
||||||
(ghc-with-current-buffer (process-buffer process)
|
(ghc-with-current-buffer (process-buffer process)
|
||||||
(goto-char (point-max))
|
(goto-char (point-max))
|
||||||
(insert string)
|
(insert string)
|
||||||
@ -89,7 +92,7 @@
|
|||||||
(let ((cbuf (current-buffer)))
|
(let ((cbuf (current-buffer)))
|
||||||
(ghc-with-debug-buffer
|
(ghc-with-debug-buffer
|
||||||
(insert-buffer-substring cbuf))))
|
(insert-buffer-substring cbuf))))
|
||||||
(setq ghc-process-running nil)))))
|
(setq ghc-process-running nil)))))))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
@ -98,6 +101,7 @@
|
|||||||
(defvar ghc-process-results nil)
|
(defvar ghc-process-results nil)
|
||||||
|
|
||||||
(defun ghc-sync-process (cmd &optional n hook)
|
(defun ghc-sync-process (cmd &optional n hook)
|
||||||
|
(unless ghc-process-running
|
||||||
(setq ghc-process-rendezvous nil)
|
(setq ghc-process-rendezvous nil)
|
||||||
(setq ghc-process-results nil)
|
(setq ghc-process-results nil)
|
||||||
(setq ghc-process-num-of-results (or n 1))
|
(setq ghc-process-num-of-results (or n 1))
|
||||||
@ -110,9 +114,8 @@
|
|||||||
;; (discard-input) avoids getting stuck.
|
;; (discard-input) avoids getting stuck.
|
||||||
(discard-input))
|
(discard-input))
|
||||||
(quit
|
(quit
|
||||||
(ghc-with-current-buffer (process-buffer pro)
|
(setq ghc-process-running nil))))
|
||||||
(setq ghc-process-running nil)))))
|
ghc-process-results))
|
||||||
ghc-process-results)
|
|
||||||
|
|
||||||
(defun ghc-process-callback (status)
|
(defun ghc-process-callback (status)
|
||||||
(cond
|
(cond
|
||||||
|
Loading…
Reference in New Issue
Block a user