feat(emacs/lean-server.el): lean-server-consume-all-async-tasks restart lean-server if necessary

related issue: #263
This commit is contained in:
Soonho Kong 2015-07-28 18:10:46 -07:00
parent 80e3da0526
commit 1829e64a76
2 changed files with 35 additions and 19 deletions

View file

@ -432,6 +432,8 @@ If it's not the same with file-name (default: buffer-file-name), send VISIT cmd.
(lean-server-async-task-queue-len))
(while lean-global-async-task-queue
(accept-process-output (lean-server-get-process) 0 50 t)
(let ((kill-timer (run-at-time lean-time-to-restart-server nil
'(lambda () (lean-server-restart-process)))))
(let* ((front-item (lean-server-async-task-queue-peek-front))
(cont (car front-item))
(cmd-type (cdr front-item))
@ -448,9 +450,10 @@ If it's not the same with file-name (default: buffer-file-name), send VISIT cmd.
(t
(lean-server-async-task-queue-pop-front)
(lean-debug "lean-server-consume-all-sync-tasks: either error or quit happend. queue size = %d"
(lean-server-async-task-queue-len))))))
(lean-server-async-task-queue-len)))))
(cancel-timer kill-timer)
(lean-debug "lean-server-consume-all-async-tasks: over. queue size = %d"
(lean-server-async-task-queue-len)))
(lean-server-async-task-queue-len)))))
(defun lean-server-send-cmd-sync (cmd &optional cont)
"Send cmd to lean-server (sync)."
@ -600,4 +603,13 @@ Otherwise, set an idle-timer to call the handler again"
(when (buffer-modified-p)
(lean-server-send-cmd-async (lean-cmd-sync))))
;; Sanity Check
;; ============
;; Compare the current buffer and the copy that lean-server is
;; maintaining.
(defun lean-server-sanity-check-p ()
(interactive)
(lean-server-send-cmd-async (lean-cmd-show) (lambda (msg) msg)))
(provide 'lean-server)

View file

@ -151,4 +151,8 @@ false (nil)."
"Disable this if we don't need to keep track of the changes. A usage
is to batch-process .org files to .html files")
(defcustom lean-time-to-restart-server 1
"After lean-time-to-kill-server passed, we restart lean-server if
the all jobs in the queue are not process.")
(provide 'lean-settings)