emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/elpa c2862f4 063/139: Don't auto-reconnect if last atte


From: João Távora
Subject: [elpa] externals/elpa c2862f4 063/139: Don't auto-reconnect if last attempt lasted less than 3 seconds
Date: Mon, 14 May 2018 09:53:35 -0400 (EDT)

branch: externals/elpa
commit c2862f46c8330a0c0feaf871034166ed5d973894
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>

    Don't auto-reconnect if last attempt lasted less than 3 seconds
    
    * eglot.el (eglot--inhibit-auto-reconnect): New var.
    (eglot--process-sentinel): Use it.
---
 eglot.el | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/eglot.el b/eglot.el
index 8f371d2..df03d04 100644
--- a/eglot.el
+++ b/eglot.el
@@ -329,6 +329,9 @@ INTERACTIVE is t if called interactively."
        (with-current-buffer buffer
          (eglot--maybe-activate-editing-mode proc))))))
 
+(defvar eglot--inhibit-auto-reconnect nil
+  "If non-nil, don't autoreconnect on unexpected quit.")
+
 (defun eglot--process-sentinel (process change)
   "Called with PROCESS undergoes CHANGE."
   (eglot--debug "(sentinel) Process state changed to %s" change)
@@ -355,11 +358,20 @@ INTERACTIVE is t if called interactively."
     (cond ((eglot--moribund process)
            (eglot--message "(sentinel) Moribund process exited with status %s"
                            (process-exit-status process)))
-          (t
+          ((null eglot--inhibit-auto-reconnect)
            (eglot--warn
             "(sentinel) Reconnecting after process unexpectedly changed to %s."
             change)
-           (eglot-reconnect process)))
+           (eglot-reconnect process)
+           (setq eglot--inhibit-auto-reconnect
+                 (run-with-timer
+                  3 nil
+                  (lambda ()
+                    (setq eglot--inhibit-auto-reconnect nil)))))
+          (t
+           (eglot--warn
+            "(sentinel) Not auto-reconnecting, last one didn't last long."
+            change)))
     (force-mode-line-update t)
     (delete-process process)))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]