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

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

[elpa] externals/eglot 05ff697 29/69: Document current API breaches a bi


From: João Távora
Subject: [elpa] externals/eglot 05ff697 29/69: Document current API breaches a bit
Date: Fri, 22 Jun 2018 11:54:58 -0400 (EDT)

branch: externals/eglot
commit 05ff697756f28671fadc4aaa5c494934768ee0d2
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>

    Document current API breaches a bit
    
    * eglot-tests.el (eglot--call-with-dirs-and-files)
    (auto-reconnect): use eglot--process
    
    * eglot.el (eglot-shutdown, eglot, eglot-reconnect)
    (eglot--connect): Use eglot--process
    (eglot--process): Alias to concentrate the hack here.
    (eglot--signal-textDocument/didChange): Tweak comment.
---
 eglot-tests.el |  8 ++++----
 eglot.el       | 19 ++++++++++++-------
 2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/eglot-tests.el b/eglot-tests.el
index 8afbfa5..777d2da 100644
--- a/eglot-tests.el
+++ b/eglot-tests.el
@@ -67,7 +67,7 @@
       (let ((eglot-autoreconnect nil))
         (mapc #'eglot-shutdown
               (cl-remove-if-not
-               (lambda (server) (process-live-p (jsonrpc--process server)))
+               (lambda (server) (process-live-p (eglot--process server)))
                new-servers)))
       (dolist (buf new-buffers) ;; have to save otherwise will get prompted
         (with-current-buffer buf (save-buffer) (kill-buffer)))
@@ -145,13 +145,13 @@
           ;; In 1.2 seconds > `eglot-autoreconnect' kill servers. We
           ;; should have a automatic reconnection.
           (run-with-timer 1.2 nil (lambda () (delete-process
-                                              (jsonrpc--process server))))
-          (while (process-live-p (jsonrpc--process server))
+                                              (eglot--process server))))
+          (while (process-live-p (eglot--process server))
             (accept-process-output nil 0.5))
           (should (jsonrpc-current-connection))
           ;; Now try again too quickly
           (setq server (jsonrpc-current-connection))
-          (let ((proc (jsonrpc--process server)))
+          (let ((proc (eglot--process server)))
             (run-with-timer 0.5 nil (lambda () (delete-process proc)))
             (while (process-live-p proc) (accept-process-output nil 0.5)))
           (should (not (jsonrpc-current-connection))))))))
diff --git a/eglot.el b/eglot.el
index 1328331..ccb7b49 100644
--- a/eglot.el
+++ b/eglot.el
@@ -191,6 +191,11 @@ lasted more than that many seconds."
 (defvar eglot--servers-by-project (make-hash-table :test #'equal)
   "Keys are projects.  Values are lists of processes.")
 
+;; HACK: Do something to fix this in the jsonrpc API or here, but in
+;; the meantime concentrate the hack here.
+(defalias 'eglot--process 'jsonrpc--process
+  "An abuse of `jsonrpc--process', a jsonrpc.el internal.")
+
 (defun eglot-shutdown (server &optional _interactive)
   "Politely ask SERVER to quit.
 Forcefully quit it if it doesn't respond.  Don't leave this
@@ -206,9 +211,9 @@ function with the server still running."
     ;; Turn off `eglot--managed-mode' where appropriate.
     (dolist (buffer (eglot--managed-buffers server))
       (with-current-buffer buffer (eglot--managed-mode-onoff server -1)))
-    (when (process-live-p (jsonrpc--process server))
+    (when (process-live-p (eglot--process server))
       (eglot--warn "Brutally deleting non-compliant server %s" (jsonrpc-name 
server))
-      (delete-process (jsonrpc--process server)))))
+      (delete-process (eglot--process server)))))
 
 (defun eglot--on-shutdown (server)
   "Called by jsonrpc.el when SERVER is already dead."
@@ -330,7 +335,7 @@ INTERACTIVE is t if called interactively."
                                     (car (project-roots project)))))
          (current-server (jsonrpc-current-connection))
          (live-p (and current-server
-                      (process-live-p (jsonrpc--process current-server)))))
+                      (process-live-p (eglot--process current-server)))))
     (if (and live-p
              interactive
              (y-or-n-p "[eglot] Live process found, reconnect instead? "))
@@ -351,7 +356,7 @@ managing `%s' buffers in project `%s'."
   "Reconnect to SERVER.
 INTERACTIVE is t if called interactively."
   (interactive (list (jsonrpc-current-connection-or-lose) t))
-  (when (process-live-p (jsonrpc--process server))
+  (when (process-live-p (eglot--process server))
     (eglot-shutdown server interactive))
   (eglot--connect (eglot--project server)
                   (eglot--major-mode server)
@@ -391,7 +396,7 @@ And NICKNAME and CONTACT."
              server
              :initialize
              (jsonrpc-obj :processId (unless (eq (process-type
-                                                  (jsonrpc--process server))
+                                                  (eglot--process server))
                                                  'network)
                                        (emacs-pid))
                           :rootPath  (expand-file-name
@@ -415,7 +420,7 @@ And NICKNAME and CONTACT."
                                     (setf (eglot--inhibit-autoreconnect server)
                                           (null eglot-autoreconnect)))))))
           (setq success server))
-      (unless (or success (not (process-live-p (jsonrpc--process server)))
+      (unless (or success (not (process-live-p (eglot--process server)))
                   (eglot--moribund server))
         (eglot-shutdown server)))))
 
@@ -851,7 +856,7 @@ Records START, END and PRE-CHANGE-LENGTH locally."
                                              :text after-text)])))))
       (setq eglot--recent-changes (cons [] []))
       (setf (eglot--spinner server) (list nil :textDocument/didChange t))
-      ;; HACK!
+      ;; HACK! perhaps jsonrpc should just call this on every send
       (jsonrpc--call-deferred server))))
 
 (defun eglot--signal-textDocument/didOpen ()



reply via email to

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