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

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

[elpa] externals/eglot bb60c0c 21/69: Rename jrpc.el to jsonrpc.el


From: João Távora
Subject: [elpa] externals/eglot bb60c0c 21/69: Rename jrpc.el to jsonrpc.el
Date: Fri, 22 Jun 2018 11:54:57 -0400 (EDT)

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

    Rename jrpc.el to jsonrpc.el
    
    * eglot.el [everywhere]: jrpc -> jsonrpc everywhere.
    Reindent.
    
    * eglot-tests [everywhere]: jrpc -> jsonrpc everywhere.
    
    * jsonrpc.el: New file.
    
    * Makefile: jrpc.el -> jsonrpc.el
---
 Makefile              |   2 +-
 eglot-tests.el        |  26 ++--
 eglot.el              | 359 ++++++++++++++++++++++---------------------
 jrpc.el => jsonrpc.el | 414 ++++++++++++++++++++++++++------------------------
 4 files changed, 409 insertions(+), 392 deletions(-)

diff --git a/Makefile b/Makefile
index 2360136..41619fc 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@ EMACS=emacs
 
 LOAD_PATH=-L .
 
-ELFILES := eglot.el jrpc.el eglot-tests.el
+ELFILES := eglot.el jsonrpc.el eglot-tests.el
 ELCFILES := $(ELFILES:.el=.elc)
 
 all: compile
diff --git a/eglot-tests.el b/eglot-tests.el
index 7a832dd..9359a78 100644
--- a/eglot-tests.el
+++ b/eglot-tests.el
@@ -78,7 +78,7 @@
   (let* ((tag (make-symbol "tag"))
          (timed-out (make-symbol "timeout"))
          (timer )
-         (jrpc-request-timeout 1)
+         (jsonrpc-request-timeout 1)
          (retval))
     (unwind-protect
         (setq retval
@@ -112,22 +112,22 @@
   (let (proc)
     (eglot--with-test-timeout 2
       (eglot--with-dirs-and-files
-        '(("project" . (("coiso.rs" . "bla")
-                        ("merdix.rs" . "bla")))
-          ("anotherproject" . (("cena.rs" . "bla"))))
+          '(("project" . (("coiso.rs" . "bla")
+                          ("merdix.rs" . "bla")))
+            ("anotherproject" . (("cena.rs" . "bla"))))
         (with-current-buffer
             (eglot--find-file-noselect "project/coiso.rs")
           (setq proc
                 (eglot 'rust-mode `(transient . ,default-directory)
                        '("rls")))
-          (should (jrpc-current-process)))
+          (should (jsonrpc-current-process)))
         (with-current-buffer
             (eglot--find-file-noselect "project/merdix.rs")
-          (should (jrpc-current-process))
-          (should (eq (jrpc-current-process) proc)))
+          (should (jsonrpc-current-process))
+          (should (eq (jsonrpc-current-process) proc)))
         (with-current-buffer
             (eglot--find-file-noselect "anotherproject/cena.rs")
-          (should-error (jrpc-current-process-or-lose)))))))
+          (should-error (jsonrpc-current-process-or-lose)))))))
 
 (ert-deftest auto-reconnect ()
   "Start a server. Kill it. Watch it reconnect."
@@ -135,8 +135,8 @@
         (eglot-autoreconnect 1))
     (eglot--with-test-timeout 3
       (eglot--with-dirs-and-files
-        '(("project" . (("coiso.rs" . "bla")
-                        ("merdix.rs" . "bla"))))
+          '(("project" . (("coiso.rs" . "bla")
+                          ("merdix.rs" . "bla"))))
         (with-current-buffer
             (eglot--find-file-noselect "project/coiso.rs")
           (setq proc
@@ -146,12 +146,12 @@
           ;; should have a automatic reconnection.
           (run-with-timer 1.2 nil (lambda () (delete-process proc)))
           (while (process-live-p proc) (accept-process-output nil 0.5))
-          (should (jrpc-current-process))
+          (should (jsonrpc-current-process))
           ;; Now try again too quickly
-          (setq proc (jrpc-current-process))
+          (setq proc (jsonrpc-current-process))
           (run-with-timer 0.5 nil (lambda () (delete-process proc)))
           (while (process-live-p proc) (accept-process-output nil 0.5))
-          (should (not (jrpc-current-process))))))))
+          (should (not (jsonrpc-current-process))))))))
 
 (provide 'eglot-tests)
 ;;; eglot-tests.el ends here
diff --git a/eglot.el b/eglot.el
index 81229a5..907c98b 100644
--- a/eglot.el
+++ b/eglot.el
@@ -59,7 +59,7 @@
 (require 'flymake)
 (require 'xref)
 (require 'subr-x)
-(require 'jrpc)
+(require 'jsonrpc)
 (require 'filenotify)
 
 
@@ -98,26 +98,26 @@ lasted more than that many seconds."
 (defvar eglot--processes-by-project (make-hash-table :test #'equal)
   "Keys are projects.  Values are lists of processes.")
 
-(jrpc-define-process-var eglot--major-mode nil
+(jsonrpc-define-process-var eglot--major-mode nil
   "The major-mode this server is managing.")
 
-(jrpc-define-process-var eglot--capabilities :unreported
+(jsonrpc-define-process-var eglot--capabilities :unreported
   "Holds list of capabilities that server reported")
 
-(jrpc-define-process-var eglot--project nil
+(jsonrpc-define-process-var eglot--project nil
   "The project the server belongs to.")
 
-(jrpc-define-process-var eglot--spinner `(nil nil t)
+(jsonrpc-define-process-var eglot--spinner `(nil nil t)
   "\"Spinner\" used by some servers.
 A list (ID WHAT DONE-P).")
 
-(jrpc-define-process-var eglot--moribund nil
+(jsonrpc-define-process-var eglot--moribund nil
   "Non-nil if server is about to exit")
 
-(jrpc-define-process-var eglot--inhibit-autoreconnect eglot-autoreconnect
+(jsonrpc-define-process-var eglot--inhibit-autoreconnect eglot-autoreconnect
   "If non-nil, don't autoreconnect on unexpected quit.")
 
-(jrpc-define-process-var eglot--file-watches (make-hash-table :test #'equal)
+(jsonrpc-define-process-var eglot--file-watches (make-hash-table :test #'equal)
   "File system watches for the didChangeWatchedfiles thingy.")
 
 (defun eglot--on-shutdown (proc)
@@ -146,14 +146,14 @@ A list (ID WHAT DONE-P).")
 Forcefully quit it if it doesn't respond.  Don't leave this
 function with the server still running.  INTERACTIVE is t if
 called interactively."
-  (interactive (list (jrpc-current-process-or-lose) t))
+  (interactive (list (jsonrpc-current-process-or-lose) t))
   (when interactive (eglot--message "Asking %s politely to terminate" proc))
   (unwind-protect
-      (let ((jrpc-request-timeout 3))
+      (let ((jsonrpc-request-timeout 3))
         (setf (eglot--moribund proc) t)
-        (jrpc-request proc :shutdown nil)
+        (jsonrpc-request proc :shutdown nil)
         ;; this one should always fail under normal conditions
-        (ignore-errors (jrpc-request proc :exit nil)))
+        (ignore-errors (jsonrpc-request proc :exit nil)))
     (when (process-live-p proc)
       (eglot--warn "Brutally deleting existing process %s" proc)
       (delete-process proc))))
@@ -178,14 +178,14 @@ called interactively."
 
 (defun eglot--client-capabilities ()
   "What the EGLOT LSP client supports."
-  (jrpc-obj
-   :workspace    (jrpc-obj
+  (jsonrpc-obj
+   :workspace    (jsonrpc-obj
                   :applyEdit t
                   :workspaceEdit `(:documentChanges :json-false)
                   :didChangeWatchesFiles `(:dynamicRegistration t)
                   :symbol `(:dynamicRegistration :json-false))
-   :textDocument (jrpc-obj
-                  :synchronization (jrpc-obj
+   :textDocument (jsonrpc-obj
+                  :synchronization (jsonrpc-obj
                                     :dynamicRegistration :json-false
                                     :willSave t :willSaveWaitUntil t :didSave 
t)
                   :completion         `(:dynamicRegistration :json-false)
@@ -197,7 +197,7 @@ called interactively."
                   :documentHighlight  `(:dynamicRegistration :json-false)
                   :rename             `(:dynamicRegistration :json-false)
                   :publishDiagnostics `(:relatedInformation :json-false))
-   :experimental (jrpc-obj)))
+   :experimental (jsonrpc-obj)))
 
 (defvar eglot--command-history nil
   "History of CONTACT arguments to `eglot'.")
@@ -282,7 +282,7 @@ MANAGED-MAJOR-MODE is an Emacs major mode.
 INTERACTIVE is t if called interactively."
   (interactive (eglot--interactive))
   (let* ((short-name (eglot--project-short-name project)))
-    (let ((current-process (jrpc-current-process)))
+    (let ((current-process (jsonrpc-current-process)))
       (if (and (process-live-p current-process)
                interactive
                (y-or-n-p "[eglot] Live process found, reconnect instead? "))
@@ -301,32 +301,33 @@ managing `%s' buffers in project `%s'."
 (defun eglot-reconnect (process &optional interactive)
   "Reconnect to PROCESS.
 INTERACTIVE is t if called interactively."
-  (interactive (list (jrpc-current-process-or-lose) t))
+  (interactive (list (jsonrpc-current-process-or-lose) t))
   (when (process-live-p process)
     (eglot-shutdown process interactive))
   (eglot--connect (eglot--project process)
                   (eglot--major-mode process)
-                  (jrpc-name process)
-                  (jrpc-contact process))
+                  (jsonrpc-name process)
+                  (jsonrpc-contact process))
   (eglot--message "Reconnected!"))
 
-(defalias 'eglot-events-buffer 'jrpc-events-buffer)
+(defalias 'eglot-events-buffer 'jsonrpc-events-buffer)
 
 (defvar eglot-connect-hook nil "Hook run after connecting in 
`eglot--connect'.")
 
 (defun eglot--dispatch (proc method id params)
-  "Dispatcher passed to `jrpc-connect'.
+  "Dispatcher passed to `jsonrpc-connect'.
 Builds a function from METHOD, passes it PROC, ID and PARAMS."
   (let* ((handler-sym (intern (format "eglot--server-%s" method))))
     (if (functionp handler-sym) ;; FIXME: fails if params is array, not object
         (apply handler-sym proc (append params (if id `(:id ,id))))
-      (jrpc-reply proc id
-                  :error (jrpc-obj :code -32601 :message "Unimplemented")))
+      (jsonrpc-reply proc id
+                     :error (jsonrpc-obj :code -32601 :message 
"Unimplemented")))
     (force-mode-line-update t)))
 
 (defun eglot--connect (project managed-major-mode name contact)
   (let* ((contact (if (functionp contact) (funcall contact) contact))
-         (proc (jrpc-connect name contact #'eglot--dispatch 
#'eglot--on-shutdown))
+         (proc
+          (jsonrpc-connect name contact #'eglot--dispatch 
#'eglot--on-shutdown))
          success)
     (setf (eglot--project proc) project)
     (setf (eglot--major-mode proc)managed-major-mode)
@@ -334,23 +335,23 @@ Builds a function from METHOD, passes it PROC, ID and 
PARAMS."
     (run-hook-with-args 'eglot-connect-hook proc)
     (unwind-protect
         (cl-destructuring-bind (&key capabilities)
-            (jrpc-request
+            (jsonrpc-request
              proc
              :initialize
-             (jrpc-obj :processId (unless (eq (process-type proc)
-                                              'network)
-                                    (emacs-pid))
-                       :rootPath  (car (project-roots project))
-                       :rootUri  (eglot--path-to-uri
-                                  (car (project-roots project)))
-                       :initializationOptions  []
-                       :capabilities (eglot--client-capabilities)))
+             (jsonrpc-obj :processId (unless (eq (process-type proc)
+                                                 'network)
+                                       (emacs-pid))
+                          :rootPath  (car (project-roots project))
+                          :rootUri  (eglot--path-to-uri
+                                     (car (project-roots project)))
+                          :initializationOptions  []
+                          :capabilities (eglot--client-capabilities)))
           (setf (eglot--capabilities proc) capabilities)
-          (setf (jrpc-status proc) nil)
+          (setf (jsonrpc-status proc) nil)
           (dolist (buffer (buffer-list))
             (with-current-buffer buffer
               (eglot--maybe-activate-editing-mode proc)))
-          (jrpc-notify proc :initialized (jrpc-obj :__dummy__ t))
+          (jsonrpc-notify proc :initialized (jsonrpc-obj :__dummy__ t))
           (setf (eglot--inhibit-autoreconnect proc)
                 (cond
                  ((booleanp eglot-autoreconnect) (not eglot-autoreconnect))
@@ -389,12 +390,12 @@ Builds a function from METHOD, passes it PROC, ID and 
PARAMS."
 (defun eglot--pos-to-lsp-position (&optional pos)
   "Convert point POS to LSP position."
   (save-excursion
-    (jrpc-obj :line
-              ;; F!@(#*&#$)CKING OFF-BY-ONE
-              (1- (line-number-at-pos pos t))
-              :character
-              (- (goto-char (or pos (point)))
-                 (line-beginning-position)))))
+    (jsonrpc-obj :line
+                 ;; F!@(#*&#$)CKING OFF-BY-ONE
+                 (1- (line-number-at-pos pos t))
+                 :character
+                 (- (goto-char (or pos (point)))
+                    (line-beginning-position)))))
 
 (defun eglot--lsp-position-to-point (pos-plist)
   "Convert LSP position POS-PLIST to Emacs point."
@@ -444,7 +445,7 @@ Builds a function from METHOD, passes it PROC, ID and 
PARAMS."
 
 (defun eglot--server-capable (feat)
   "Determine if current server is capable of FEAT."
-  (plist-get (eglot--capabilities (jrpc-current-process-or-lose)) feat))
+  (plist-get (eglot--capabilities (jsonrpc-current-process-or-lose)) feat))
 
 (defun eglot--range-region (range)
   "Return region (BEG . END) that represents LSP RANGE."
@@ -461,8 +462,8 @@ Builds a function from METHOD, passes it PROC, ID and 
PARAMS."
   nil nil eglot-mode-map
   (cond
    (eglot--managed-mode
-    (add-hook 'jrpc-find-process-functions 'eglot--find-current-process nil t)
-    (add-hook 'jrpc-ready-predicates 'eglot--server-ready-p nil t)
+    (add-hook 'jsonrpc-find-process-functions 'eglot--find-current-process nil 
t)
+    (add-hook 'jsonrpc-ready-predicates 'eglot--server-ready-p nil t)
     (add-hook 'after-change-functions 'eglot--after-change nil t)
     (add-hook 'before-change-functions 'eglot--before-change nil t)
     (add-hook 'flymake-diagnostic-functions 'eglot-flymake-backend nil t)
@@ -476,8 +477,8 @@ Builds a function from METHOD, passes it PROC, ID and 
PARAMS."
                   #'eglot-eldoc-function)
     (add-function :around (local imenu-create-index-function) #'eglot-imenu))
    (t
-    (remove-hook 'jrpc-find-process-functions 'eglot--find-current-process t)
-    (remove-hook 'jrpc-ready-predicates 'eglot--server-ready-p t)
+    (remove-hook 'jsonrpc-find-process-functions 'eglot--find-current-process 
t)
+    (remove-hook 'jsonrpc-ready-predicates 'eglot--server-ready-p t)
     (remove-hook 'flymake-diagnostic-functions 'eglot-flymake-backend t)
     (remove-hook 'after-change-functions 'eglot--after-change t)
     (remove-hook 'before-change-functions 'eglot--before-change t)
@@ -549,11 +550,11 @@ Uses THING, FACE, DEFS and PREPEND."
 
 (defun eglot--mode-line-format ()
   "Compose the EGLOT's mode-line."
-  (pcase-let* ((proc (jrpc-current-process))
-               (name (and (process-live-p proc) (jrpc-name proc)))
-               (pending (and proc (length (jrpc-outstanding-request-ids 
proc))))
+  (pcase-let* ((proc (jsonrpc-current-process))
+               (name (and (process-live-p proc) (jsonrpc-name proc)))
+               (pending (and proc (length (jsonrpc-outstanding-request-ids 
proc))))
                (`(,_id ,doing ,done-p ,detail) (and proc (eglot--spinner 
proc)))
-               (`(,status ,serious-p) (and proc (jrpc-status proc))))
+               (`(,status ,serious-p) (and proc (jsonrpc-status proc))))
     (append
      `(,(eglot--mode-line-props "eglot" 'eglot-mode-line nil))
      (when name
@@ -609,10 +610,10 @@ Uses THING, FACE, DEFS and PREPEND."
                    '("OK"))
                nil t (plist-get (elt actions 0) :title)))
       (if reply
-          (jrpc-reply process id :result (jrpc-obj :title reply))
-        (jrpc-reply process id
-                    :error (jrpc-obj :code -32800
-                                     :message "User cancelled"))))))
+          (jsonrpc-reply process id :result (jsonrpc-obj :title reply))
+        (jsonrpc-reply process id
+                       :error (jsonrpc-obj :code -32800
+                                           :message "User cancelled"))))))
 
 (cl-defun eglot--server-window/logMessage (_proc &key _type _message)
   "Handle notification window/logMessage") ;; noop, use events buffer
@@ -659,10 +660,10 @@ THINGS are either registrations or unregisterations."
                                 proc :id id registerOptions))
           (unless (eq t (car retval))
             (cl-return-from eglot--register-unregister
-              (jrpc-reply
+              (jsonrpc-reply
                proc jsonrpc-id
                :error `(:code -32601 :message ,(or (cadr retval) 
"sorry")))))))))
-  (jrpc-reply proc jsonrpc-id :result (jrpc-obj :message "OK")))
+  (jsonrpc-reply proc jsonrpc-id :result (jsonrpc-obj :message "OK")))
 
 (cl-defun eglot--server-client/registerCapability
     (proc &key id registrations)
@@ -680,42 +681,42 @@ THINGS are either registrations or unregisterations."
   (condition-case err
       (progn
         (eglot--apply-workspace-edit edit 'confirm)
-        (jrpc-reply proc id :result `(:applied )))
+        (jsonrpc-reply proc id :result `(:applied )))
     (error
-     (jrpc-reply proc id
-                 :result `(:applied :json-false)
-                 :error
-                 (jrpc-obj :code -32001
-                           :message (format "%s" err))))))
+     (jsonrpc-reply proc id
+                    :result `(:applied :json-false)
+                    :error
+                    (jsonrpc-obj :code -32001
+                                 :message (format "%s" err))))))
 
 (defun eglot--TextDocumentIdentifier ()
   "Compute TextDocumentIdentifier object for current buffer."
-  (jrpc-obj :uri (eglot--path-to-uri buffer-file-name)))
+  (jsonrpc-obj :uri (eglot--path-to-uri buffer-file-name)))
 
 (defvar-local eglot--versioned-identifier 0)
 
 (defun eglot--VersionedTextDocumentIdentifier ()
   "Compute VersionedTextDocumentIdentifier object for current buffer."
   (append (eglot--TextDocumentIdentifier)
-          (jrpc-obj :version eglot--versioned-identifier)))
+          (jsonrpc-obj :version eglot--versioned-identifier)))
 
 (defun eglot--TextDocumentItem ()
   "Compute TextDocumentItem object for current buffer."
   (append
    (eglot--VersionedTextDocumentIdentifier)
-   (jrpc-obj :languageId
-             (if (string-match "\\(.*\\)-mode" (symbol-name major-mode))
-                 (match-string 1 (symbol-name major-mode))
-               "unknown")
-             :text
-             (save-restriction
-               (widen)
-               (buffer-substring-no-properties (point-min) (point-max))))))
+   (jsonrpc-obj :languageId
+                (if (string-match "\\(.*\\)-mode" (symbol-name major-mode))
+                    (match-string 1 (symbol-name major-mode))
+                  "unknown")
+                :text
+                (save-restriction
+                  (widen)
+                  (buffer-substring-no-properties (point-min) (point-max))))))
 
 (defun eglot--TextDocumentPositionParams ()
   "Compute TextDocumentPositionParams."
-  (jrpc-obj :textDocument (eglot--TextDocumentIdentifier)
-            :position (eglot--pos-to-lsp-position)))
+  (jsonrpc-obj :textDocument (eglot--TextDocumentIdentifier)
+               :position (eglot--pos-to-lsp-position)))
 
 (defvar-local eglot--recent-changes nil
   "Recent buffer changes as collected by `eglot--before-change'.")
@@ -747,16 +748,16 @@ Records START, END and PRE-CHANGE-LENGTH locally."
 
 ;; HACK! Launching a deferred sync request with outstanding changes is a
 ;; bad idea, since that might lead to the request never having a
-;; chance to run, because `jrpc-ready-predicates'.
-(advice-add #'jrpc-request :before
+;; chance to run, because `jsonrpc-ready-predicates'.
+(advice-add #'jsonrpc-request :before
             (cl-function (lambda (_proc _method _params &key deferred)
-              (when (and eglot--managed-mode deferred)
-                (eglot--signal-textDocument/didChange)))))
+                           (when (and eglot--managed-mode deferred)
+                             (eglot--signal-textDocument/didChange)))))
 
 (defun eglot--signal-textDocument/didChange ()
   "Send textDocument/didChange to server."
   (when (eglot--outstanding-edits-p)
-    (let* ((proc (jrpc-current-process-or-lose))
+    (let* ((proc (jsonrpc-current-process-or-lose))
            (sync-kind (eglot--server-capable :textDocumentSync))
            (emacs-messup (/= (length (car eglot--recent-changes))
                              (length (cdr eglot--recent-changes))))
@@ -765,58 +766,58 @@ Records START, END and PRE-CHANGE-LENGTH locally."
         (eglot--warn "`eglot--recent-changes' messup: %s" 
eglot--recent-changes))
       (save-restriction
         (widen)
-        (jrpc-notify
+        (jsonrpc-notify
          proc :textDocument/didChange
-         (jrpc-obj
+         (jsonrpc-obj
           :textDocument
           (eglot--VersionedTextDocumentIdentifier)
           :contentChanges
           (if full-sync-p (vector
-                           (jrpc-obj
+                           (jsonrpc-obj
                             :text (buffer-substring-no-properties (point-min)
                                                                   
(point-max))))
             (cl-loop for (start-pos end-pos) across (car eglot--recent-changes)
                      for (len after-text) across (cdr eglot--recent-changes)
-                     vconcat `[,(jrpc-obj :range (jrpc-obj :start start-pos
-                                                           :end end-pos)
-                                          :rangeLength len
-                                          :text after-text)])))))
+                     vconcat `[,(jsonrpc-obj :range (jsonrpc-obj :start 
start-pos
+                                                                 :end end-pos)
+                                             :rangeLength len
+                                             :text after-text)])))))
       (setq eglot--recent-changes (cons [] []))
       (setf (eglot--spinner proc) (list nil :textDocument/didChange t))
       ;; HACK!
-      (jrpc--call-deferred proc))))
+      (jsonrpc--call-deferred proc))))
 
 (defun eglot--signal-textDocument/didOpen ()
   "Send textDocument/didOpen to server."
   (setq eglot--recent-changes (cons [] []))
-  (jrpc-notify
-   (jrpc-current-process-or-lose)
+  (jsonrpc-notify
+   (jsonrpc-current-process-or-lose)
    :textDocument/didOpen `(:textDocument ,(eglot--TextDocumentItem))))
 
 (defun eglot--signal-textDocument/didClose ()
   "Send textDocument/didClose to server."
-  (jrpc-notify
-   (jrpc-current-process-or-lose)
+  (jsonrpc-notify
+   (jsonrpc-current-process-or-lose)
    :textDocument/didClose `(:textDocument ,(eglot--TextDocumentIdentifier))))
 
 (defun eglot--signal-textDocument/willSave ()
   "Send textDocument/willSave to server."
-  (let ((proc (jrpc-current-process-or-lose))
+  (let ((proc (jsonrpc-current-process-or-lose))
         (params `(:reason 1 :textDocument ,(eglot--TextDocumentIdentifier))))
-    (jrpc-notify proc :textDocument/willSave params)
+    (jsonrpc-notify proc :textDocument/willSave params)
     (ignore-errors
-      (let ((jrpc-request-timeout 0.5))
+      (let ((jsonrpc-request-timeout 0.5))
         (when (plist-get :willSaveWaitUntil
                          (eglot--server-capable :textDocumentSync))
           (eglot--apply-text-edits
-           (jrpc-request proc :textDocument/willSaveWaituntil params)))))))
+           (jsonrpc-request proc :textDocument/willSaveWaituntil params)))))))
 
 (defun eglot--signal-textDocument/didSave ()
   "Send textDocument/didSave to server."
-  (jrpc-notify
-   (jrpc-current-process-or-lose)
+  (jsonrpc-notify
+   (jsonrpc-current-process-or-lose)
    :textDocument/didSave
-   (jrpc-obj
+   (jsonrpc-obj
     ;; TODO: Handle TextDocumentSaveRegistrationOptions to control this.
     :text (buffer-substring-no-properties (point-min) (point-max))
     :textDocument (eglot--TextDocumentIdentifier))))
@@ -856,26 +857,27 @@ DUMMY is ignored"
 
 (cl-defmethod xref-backend-identifier-completion-table ((_backend (eql eglot)))
   (when (eglot--server-capable :documentSymbolProvider)
-    (let ((proc (jrpc-current-process-or-lose))
+    (let ((proc (jsonrpc-current-process-or-lose))
           (text-id (eglot--TextDocumentIdentifier)))
       (completion-table-with-cache
        (lambda (string)
          (setq eglot--xref-known-symbols
                (mapcar
-                (jrpc-lambda (&key name kind location containerName)
+                (jsonrpc-lambda
+                    (&key name kind location containerName)
                   (propertize name
                               :textDocumentPositionParams
-                              (jrpc-obj :textDocument text-id
-                                        :position (plist-get
-                                                   (plist-get location :range)
-                                                   :start))
+                              (jsonrpc-obj :textDocument text-id
+                                           :position (plist-get
+                                                      (plist-get location 
:range)
+                                                      :start))
                               :locations (list location)
                               :kind kind
                               :containerName containerName))
-                (jrpc-request proc
-                              :textDocument/documentSymbol
-                              (jrpc-obj
-                               :textDocument text-id))))
+                (jsonrpc-request proc
+                                 :textDocument/documentSymbol
+                                 (jsonrpc-obj
+                                  :textDocument text-id))))
          (all-completions string eglot--xref-known-symbols))))))
 
 (cl-defmethod xref-backend-identifier-at-point ((_backend (eql eglot)))
@@ -890,13 +892,13 @@ DUMMY is ignored"
          (location-or-locations
           (if rich-identifier
               (get-text-property 0 :locations rich-identifier)
-            (jrpc-request (jrpc-current-process-or-lose)
-                          :textDocument/definition
-                          (get-text-property
-                           0 :textDocumentPositionParams identifier)))))
-    (mapcar (jrpc-lambda (&key uri range)
-       (eglot--xref-make identifier uri (plist-get range :start)))
-     location-or-locations)))
+            (jsonrpc-request (jsonrpc-current-process-or-lose)
+                             :textDocument/definition
+                             (get-text-property
+                              0 :textDocumentPositionParams identifier)))))
+    (mapcar (jsonrpc-lambda (&key uri range)
+              (eglot--xref-make identifier uri (plist-get range :start)))
+            location-or-locations)))
 
 (cl-defmethod xref-backend-references ((_backend (eql eglot)) identifier)
   (unless (eglot--server-capable :referencesProvider)
@@ -908,42 +910,42 @@ DUMMY is ignored"
     (unless params
       (eglot--error "Don' know where %s is in the workspace!" identifier))
     (mapcar
-     (jrpc-lambda (&key uri range)
+     (jsonrpc-lambda (&key uri range)
        (eglot--xref-make identifier uri (plist-get range :start)))
-     (jrpc-request (jrpc-current-process-or-lose)
-                   :textDocument/references
-                   (append
-                    params
-                    (jrpc-obj :context
-                              (jrpc-obj :includeDeclaration t)))))))
+     (jsonrpc-request (jsonrpc-current-process-or-lose)
+                      :textDocument/references
+                      (append
+                       params
+                       (jsonrpc-obj :context
+                                    (jsonrpc-obj :includeDeclaration t)))))))
 
 (cl-defmethod xref-backend-apropos ((_backend (eql eglot)) pattern)
   (when (eglot--server-capable :workspaceSymbolProvider)
     (mapcar
-     (jrpc-lambda (&key name location &allow-other-keys)
+     (jsonrpc-lambda (&key name location &allow-other-keys)
        (cl-destructuring-bind (&key uri range) location
          (eglot--xref-make name uri (plist-get range :start))))
-     (jrpc-request (jrpc-current-process-or-lose)
-                   :workspace/symbol
-                   (jrpc-obj :query pattern)))))
+     (jsonrpc-request (jsonrpc-current-process-or-lose)
+                      :workspace/symbol
+                      (jsonrpc-obj :query pattern)))))
 
 (defun eglot-completion-at-point ()
   "EGLOT's `completion-at-point' function."
   (let ((bounds (bounds-of-thing-at-point 'symbol))
-        (proc (jrpc-current-process-or-lose)))
+        (proc (jsonrpc-current-process-or-lose)))
     (when (eglot--server-capable :completionProvider)
       (list
        (or (car bounds) (point))
        (or (cdr bounds) (point))
        (completion-table-with-cache
         (lambda (_ignored)
-          (let* ((resp (jrpc-request proc
-                                     :textDocument/completion
-                                     (eglot--TextDocumentPositionParams)
-                                     :deferred :textDocument/completion))
+          (let* ((resp (jsonrpc-request proc
+                                        :textDocument/completion
+                                        (eglot--TextDocumentPositionParams)
+                                        :deferred :textDocument/completion))
                  (items (if (vectorp resp) resp (plist-get resp :items))))
             (mapcar
-             (jrpc-lambda (&rest all &key label &allow-other-keys)
+             (jsonrpc-lambda (&rest all &key label &allow-other-keys)
                (add-text-properties 0 1 all label) label)
              items))))
        :annotation-function
@@ -962,8 +964,8 @@ DUMMY is ignored"
        (lambda (obj)
          (let ((documentation
                 (or (get-text-property 0 :documentation obj)
-                    (plist-get (jrpc-request proc :completionItem/resolve
-                                             (text-properties-at 0 obj))
+                    (plist-get (jsonrpc-request proc :completionItem/resolve
+                                                (text-properties-at 0 obj))
                                :documentation))))
            (when documentation
              (with-current-buffer (get-buffer-create " *eglot doc*")
@@ -1014,8 +1016,8 @@ DUMMY is ignored"
   "Request \"hover\" information for the thing at point."
   (interactive)
   (cl-destructuring-bind (&key contents range)
-      (jrpc-request (jrpc-current-process-or-lose) :textDocument/hover
-                    (eglot--TextDocumentPositionParams))
+      (jsonrpc-request (jsonrpc-current-process-or-lose) :textDocument/hover
+                       (eglot--TextDocumentPositionParams))
     (when (seq-empty-p contents) (eglot--error "No hover info here"))
     (with-help-window "*eglot help*"
       (with-current-buffer standard-output
@@ -1025,48 +1027,51 @@ DUMMY is ignored"
   "EGLOT's `eldoc-documentation-function' function.
 If SKIP-SIGNATURE, don't try to send textDocument/signatureHelp."
   (let* ((buffer (current-buffer))
-         (proc (jrpc-current-process-or-lose))
+         (proc (jsonrpc-current-process-or-lose))
          (position-params (eglot--TextDocumentPositionParams))
          sig-showing)
     (cl-macrolet ((when-buffer-window
                    (&body body) `(when (get-buffer-window buffer)
                                    (with-current-buffer buffer ,@body))))
       (when (eglot--server-capable :signatureHelpProvider)
-        (jrpc-async-request
+        (jsonrpc-async-request
          proc :textDocument/signatureHelp position-params
-         :success-fn (jrpc-lambda (&key signatures activeSignature
-                                        activeParameter)
-                       (when-buffer-window
-                        (when (cl-plusp (length signatures))
-                          (setq sig-showing t)
-                          (eldoc-message (eglot--sig-info signatures
-                                                          activeSignature
-                                                          activeParameter)))))
+         :success-fn
+         (jsonrpc-lambda (&key signatures activeSignature
+                               activeParameter)
+           (when-buffer-window
+            (when (cl-plusp (length signatures))
+              (setq sig-showing t)
+              (eldoc-message (eglot--sig-info signatures
+                                              activeSignature
+                                              activeParameter)))))
          :deferred :textDocument/signatureHelp))
       (when (eglot--server-capable :hoverProvider)
-        (jrpc-async-request
+        (jsonrpc-async-request
          proc :textDocument/hover position-params
-         :success-fn (jrpc-lambda (&key contents range)
+         :success-fn (jsonrpc-lambda (&key contents range)
                        (unless sig-showing
                          (when-buffer-window
-                          (eldoc-message (eglot--hover-info contents range)))))
+                          (eldoc-message
+                           (eglot--hover-info contents range)))))
          :deferred :textDocument/hover))
       (when (eglot--server-capable :documentHighlightProvider)
-        (jrpc-async-request
+        (jsonrpc-async-request
          proc :textDocument/documentHighlight position-params
-         :success-fn (lambda (highlights)
-                       (mapc #'delete-overlay eglot--highlights)
-                       (setq eglot--highlights
-                             (when-buffer-window
-                              (mapcar
-                               (jrpc-lambda (&key range _kind)
-                                 (pcase-let ((`(,beg . ,end)
-                                              (eglot--range-region range)))
-                                   (let ((ov (make-overlay beg end)))
-                                     (overlay-put ov 'face 'highlight)
-                                     (overlay-put ov 'evaporate t)
-                                     ov)))
-                               highlights))))
+         :success-fn
+         (lambda (highlights)
+           (mapc #'delete-overlay eglot--highlights)
+           (setq eglot--highlights
+                 (when-buffer-window
+                  (mapcar
+                   (jsonrpc-lambda (&key range _kind)
+                     (pcase-let ((`(,beg . ,end)
+                                  (eglot--range-region range)))
+                       (let ((ov (make-overlay beg end)))
+                         (overlay-put ov 'face 'highlight)
+                         (overlay-put ov 'evaporate t)
+                         ov)))
+                   highlights))))
          :deferred :textDocument/documentHighlight))))
   nil)
 
@@ -1075,14 +1080,15 @@ If SKIP-SIGNATURE, don't try to send 
textDocument/signatureHelp."
   (if (eglot--server-capable :documentSymbolProvider)
       (let ((entries
              (mapcar
-              (jrpc-lambda (&key name kind location _containerName)
+              (jsonrpc-lambda
+                  (&key name kind location _containerName)
                 (cons (propertize name :kind (cdr (assoc kind 
eglot--kind-names)))
                       (eglot--lsp-position-to-point
                        (plist-get (plist-get location :range) :start))))
-              (jrpc-request (jrpc-current-process-or-lose)
-                            :textDocument/documentSymbol
-                            (jrpc-obj
-                             :textDocument (eglot--TextDocumentIdentifier))))))
+              (jsonrpc-request (jsonrpc-current-process-or-lose)
+                               :textDocument/documentSymbol
+                               (jsonrpc-obj
+                                :textDocument 
(eglot--TextDocumentIdentifier))))))
         (append
          (seq-group-by (lambda (e) (get-text-property 0 :kind (car e)))
                        entries)
@@ -1094,7 +1100,8 @@ If SKIP-SIGNATURE, don't try to send 
textDocument/signatureHelp."
   (unless (or (not version) (equal version eglot--versioned-identifier))
     (eglot--error "Edits on `%s' require version %d, you have %d"
                   (current-buffer) version eglot--versioned-identifier))
-  (mapc (jrpc-lambda (&key range newText)
+  (mapc (jsonrpc-lambda
+            (&key range newText)
           (save-restriction
             (widen)
             (save-excursion
@@ -1146,9 +1153,9 @@ Proceed? "
   (unless (eglot--server-capable :renameProvider)
     (eglot--error "Server can't rename!"))
   (eglot--apply-workspace-edit
-   (jrpc-request (jrpc-current-process-or-lose)
-                 :textDocument/rename `(,@(eglot--TextDocumentPositionParams)
-                                        ,@(jrpc-obj :newName newname)))
+   (jsonrpc-request (jsonrpc-current-process-or-lose)
+                    :textDocument/rename 
`(,@(eglot--TextDocumentPositionParams)
+                                           ,@(jsonrpc-obj :newName newname)))
    current-prefix-arg))
 
 
@@ -1170,7 +1177,7 @@ Proceed? "
                                     (string-match (wildcard-to-regexp
                                                    (expand-file-name glob))
                                                   f))))
-              (jrpc-notify
+              (jsonrpc-notify
                proc :workspace/didChangeWatchedFiles
                `(:changes ,(vector `(:uri ,(eglot--path-to-uri file)
                                           :type ,(cl-case action
@@ -1209,7 +1216,7 @@ Proceed? "
   (add-hook 'rust-mode-hook 'eglot--setup-rls-idiosyncrasies)
   (defun eglot--setup-rls-idiosyncrasies ()
     "Prepare `eglot' to deal with RLS's special treatment."
-    (add-hook 'jrpc-ready-predicates 'eglot--rls-probably-ready-for-p t t)))
+    (add-hook 'jsonrpc-ready-predicates 'eglot--rls-probably-ready-for-p t t)))
 
 (cl-defun eglot--server-window/progress
     (process &key id done title message &allow-other-keys)
diff --git a/jrpc.el b/jsonrpc.el
similarity index 60%
rename from jrpc.el
rename to jsonrpc.el
index f59dacc..251ebf4 100644
--- a/jrpc.el
+++ b/jsonrpc.el
@@ -1,4 +1,4 @@
-;;; jrpc.el --- JSON-RPC library                  -*- lexical-binding: t; -*-
+;;; jsonrpc.el --- JSON-RPC library                  -*- lexical-binding: t; 
-*-
 
 ;; Copyright (C) 2018 Free Software Foundation, Inc.
 
@@ -33,25 +33,25 @@
 ;; concepts can be used within the same process, over sockets, over
 ;; http, or in many various message passing environments."
 ;;
-;; To approach this agnosticism, jrpc.el uses Emacs's "process"
+;; To approach this agnosticism, jsonrpc.el uses Emacs's "process"
 ;; abstraction since it mostly hides the underlying differences
 ;; between local subprocesses and network endpoints.  Thus everywhere
 ;; in this library (be it in the internals or in the user-visible
 ;; protocol), JSONRPC endpoint is an (augmented) process object.
 ;;
-;; The main entry point is `jrpc-connect'.  It is passed a name
+;; The main entry point is `jsonrpc-connect'.  It is passed a name
 ;; identifying the connection and a "contact", which will determine
 ;; the connection type to make.  It can a list of strings (a command
 ;; and arguments for creating subprocesses) or a (HOST PORT-NUMBER
 ;; PARAMS...) for connecting via TCP.  For flexibility, it can also be
 ;; a pre-connected process.
 ;;
-;; `jrpc-connect' returns a process upon connection.  This value
-;; should be saved to be later given to `jrpc-notify', `jrpc-reply',
-;; `jrpc-request' and `jrpc-async-request' as a way of contacting the
-;; connected remote endpoint.
+;; `jsonrpc-connect' returns a process upon connection.  This value
+;; should be saved to be later given to `jsonrpc-notify',
+;; `jsonrpc-reply', `jsonrpc-request' and `jsonrpc-async-request' as a
+;; way of contacting the connected remote endpoint.
 ;;
-;; `jrpc-connect' is also passed a dispatcher function for handling
+;; `jsonrpc-connect' is also passed a dispatcher function for handling
 ;; handling the contacts asynchronously initiated by the remote
 ;; endpoint's, as well as a optional function for cleaning up after
 ;; the tear-down of the JSONRPC connection.
@@ -59,56 +59,60 @@
 ;; The JSON objects are passed to the dispatcher after being read by
 ;; `json-read' of Emacs's json.el library.  They are read as plists,
 ;; and, likewise, json.el-compatible plists should be given to
-;; `jrpc-notify', `jrpc-request', etc...
+;; `jsonrpc-notify', `jsonrpc-request', etc...
 ;;
 ;; To facilitate handling of key-value plists, this library make
 ;; liberal use of cl-lib.el and suggests (but doesn't force) its
-;; clients to do the same.  A macro `jrpc-lambda' can be used to
+;; clients to do the same.  A macro `jsonrpc-lambda' can be used to
 ;; create a lambda for destructuring a JSON-object like in this
 ;; example:
 ;;
-;; (jrpc-async-request myproc :frobnicate `(:foo "trix")
-;;                     :success-fn (jrpc-lambda (&key bar baz 
&allow-other-keys)
-;;                                   (message "Server replied back %s and %s!"
-;;                                            bar baz))
-;;                     :error-fn (jrpc-lambda (&key code message _data)
-;;                                 (message "Sadly, server reports %s: %s"
-;;                                          code message)))
+;;  (jsonrpc-async-request
+;;   myproc :frobnicate `(:foo "trix")
+;;   :success-fn (jsonrpc-lambda (&key bar baz &allow-other-keys)
+;;                 (message "Server replied back %s and %s!"
+;;                          bar baz))
+;;   :error-fn (jsonrpc-lambda (&key code message _data)
+;;               (message "Sadly, server reports %s: %s"
+;;                        code message)))
 ;;
 ;; Finally, here's an example Emacs JSONRPC server that offers a (very
 ;; small) subset of Elisp for remote calling:
 ;;
-;; (defvar server) (defvar server-endpoint)
-;; (defvar server-allowed-functions '(+ - * / vconcat append sit-for))
+;;   (defvar server) (defvar server-endpoint)
+;;   (defvar server-allowed-functions '(+ - * / vconcat append sit-for))
 ;;
-;; (setq server
-;;       (make-network-process
-;;        :name "Emacs RPC server" :server t :host "localhost" :service 9393
-;;        :log (lambda (_server client _message)
-;;               (jrpc-connect
-;;                (process-name client) client
-;;                (lambda (proc method id params)
-;;                  (unless (memq method server-allowed-functions)
-;;                    (signal 'error `((jrpc-error-message . "Sorry, this 
isn't allowed")
-;;                                     (jrpc-error-code . 32601))))
-;;                  (jrpc-reply proc id :result (apply method (append params 
nil))))))))
+;;   (setq server
+;;         (make-network-process
+;;          :name "Emacs RPC server" :server t :host "localhost" :service 9393
+;;          :log (lambda (_server client _message)
+;;                 (jsonrpc-connect
+;;                  (process-name client) client
+;;                  (lambda (proc method id params)
+;;                    (unless (memq method server-allowed-functions)
+;;                      (signal 'error `((jsonrpc-error-message
+;;                                        . "Sorry, this isn't allowed")
+;;                                       (jsonrpc-error-code . 32601))))
+;;                    (jsonrpc-reply proc id :result
+;;                                   (apply method (append params nil))))))))
+
+;;   (setq server-endpoint (jsonrpc-connect
+;;                          "Emacs RPC client" '("localhost" 9393)
+;;                          (lambda (_proc method id &rest params)
+;;                            (message "server wants to %s" method))))
 ;;
-;; (setq server-endpoint (jrpc-connect "Emacs RPC client" '("localhost" 9393)
-;;                                     (lambda (_proc method id &rest params)
-;;                                       (message "server wants to %s" 
method))))
-;;
-;; ;; returns 3
-;; (jrpc-request server-endpoint '+ '(1 2))
-;; ;; errors with -32601
-;; (jrpc-request server-endpoint 'delete-directory "~/tmp")
-;; ;; signals an -32603 JSONRPC error
-;; (jrpc-request server-endpoint '+ '(a 2))
-;; ;; times out
-;; (jrpc-request server-endpoint 'sit-for '(5))
-;; ;; stretching it, but works
-;; (jrpc-request server-endpoint 'vconcat '([1 2 3] [3 4 5]))
-;; ;; json.el can't serialize this, json.el errors and request isn't sent
-;; (jrpc-request server-endpoint 'append '((1 2 3) (3 4 5)))
+;;   ;; returns 3
+;;   (jsonrpc-request server-endpoint '+ '(1 2))
+;;   ;; errors with -32601
+;;   (jsonrpc-request server-endpoint 'delete-directory "~/tmp")
+;;   ;; signals an -32603 JSONRPC error
+;;   (jsonrpc-request server-endpoint '+ '(a 2))
+;;   ;; times out
+;;   (jsonrpc-request server-endpoint 'sit-for '(5))
+;;   ;; stretching it, but works
+;;   (jsonrpc-request server-endpoint 'vconcat '([1 2 3] [3 4 5]))
+;;   ;; json.el can't serialize this, json.el errors and request isn't sent
+;;   (jsonrpc-request server-endpoint 'append '((1 2 3) (3 4 5)))
 ;;
 ;;; Code:
 
@@ -119,48 +123,48 @@
 (require 'pcase)
 (require 'array) ; xor
 
-(defgroup jrpc nil
+(defgroup jsonrpc nil
   "Interaction between JSONRPC endpoints"
-  :prefix "jrpc-"
+  :prefix "jsonrpc-"
   :group 'applications)
 
-(defcustom jrpc-request-timeout 3
+(defcustom jsonrpc-request-timeout 3
   "How many seconds to wait for a JSONRPC from the server.
 If nil, don't use a timeout (not recommended)."
   :type :integer)
 
-(defvar jrpc-find-process-functions nil
+(defvar jsonrpc-find-process-functions nil
   "Special hook to find an active JSON-RPC process.")
 
-(defun jrpc-current-process ()
+(defun jsonrpc-current-process ()
   "The current logical JSON-RPC process."
-  (run-hook-with-args-until-success 'jrpc-find-process-functions))
+  (run-hook-with-args-until-success 'jsonrpc-find-process-functions))
 
-(defun jrpc-current-process-or-lose ()
+(defun jsonrpc-current-process-or-lose ()
   "Return the current JSON-RPC process or error."
-  (or (jrpc-current-process)
-      (jrpc-error "No current JSON-RPC process")))
+  (or (jsonrpc-current-process)
+      (jsonrpc-error "No current JSON-RPC process")))
 
-(defun jrpc-error (format &rest args)
+(defun jsonrpc-error (format &rest args)
   "Error out with FORMAT and ARGS.
 If invoked inside a dispatcher function, this function is suitable
 for replying to the remote endpoint with a -32603 error code and
 FORMAT as the message."
-  (signal 'error (format "[jrpc] %s" (apply #'format format args))))
+  (signal 'error (format "[jsonrpc] %s" (apply #'format format args))))
 
-(defun jrpc-message (format &rest args)
+(defun jsonrpc-message (format &rest args)
   "Message out with FORMAT with ARGS."
-  (message "[jrpc] %s" (concat "[jrpc] %s" (apply #'format format args))))
+  (message "[jsonrpc] %s" (concat "[jsonrpc] %s" (apply #'format format 
args))))
 
-(defun jrpc-warn (format &rest args)
+(defun jsonrpc-warn (format &rest args)
   "Warning message with FORMAT and ARGS."
-  (apply #'jrpc-message (concat "(warning) " format) args)
+  (apply #'jsonrpc-message (concat "(warning) " format) args)
   (let ((warning-minimum-level :error))
-    (display-warning 'jrpc
+    (display-warning 'jsonrpc
                      (apply #'format format args)
                      :warning)))
 
-(defmacro jrpc-define-process-var
+(defmacro jsonrpc-define-process-var
     (var-sym initval &optional doc)
   "Define VAR-SYM as a generalized process-local variable.
 INITVAL is the default value.  DOC is the documentation."
@@ -178,48 +182,48 @@ INITVAL is the default value.  DOC is the documentation."
      (gv-define-setter ,var-sym (to-store process)
        `(let ((once ,to-store)) (process-put ,process ',',var-sym once) 
once))))
 
-(jrpc-define-process-var jrpc-name nil
+(jsonrpc-define-process-var jsonrpc-name nil
   "A name for the process")
 
-(jrpc-define-process-var jrpc--dispatcher nil
+(jsonrpc-define-process-var jsonrpc--dispatcher nil
   "Emacs-lisp function for server-invoked methods.")
 
-(jrpc-define-process-var jrpc-status `(:unknown nil)
+(jsonrpc-define-process-var jsonrpc-status `(:unknown nil)
   "Status as declared by the server.
 A list (WHAT SERIOUS-P).")
 
-(jrpc-define-process-var jrpc--expected-bytes nil
+(jsonrpc-define-process-var jsonrpc--expected-bytes nil
   "How many bytes declared by server")
 
-(jrpc-define-process-var jrpc--request-continuations (make-hash-table)
+(jsonrpc-define-process-var jsonrpc--request-continuations (make-hash-table)
   "A hash table of request ID to continuation lambdas.")
 
-(jrpc-define-process-var jrpc--server-request-ids nil
+(jsonrpc-define-process-var jsonrpc--server-request-ids nil
   "Server-initiated request id that client hasn't replied to.")
 
-(jrpc-define-process-var jrpc--events-buffer nil
+(jsonrpc-define-process-var jsonrpc--events-buffer nil
   "A buffer pretty-printing the JSON-RPC RPC events")
 
-(jrpc-define-process-var jrpc-contact nil
+(jsonrpc-define-process-var jsonrpc-contact nil
   "Method used to contact a server.")
 
-(jrpc-define-process-var jrpc--on-shutdown nil
+(jsonrpc-define-process-var jsonrpc--on-shutdown nil
   "Function run when JSONRPC server is dying.
 Run after running any error handlers for outstanding requests.
 A function passed the process object for the server.")
 
-(jrpc-define-process-var jrpc--deferred-actions
+(jsonrpc-define-process-var jsonrpc--deferred-actions
     (make-hash-table :test #'equal)
   "Actions deferred to when server is thought to be ready.")
 
-(defun jrpc-outstanding-request-ids (proc)
+(defun jsonrpc-outstanding-request-ids (proc)
   "IDs of outstanding JSONRPC requests for PROC."
-  (hash-table-keys (jrpc--request-continuations proc)))
+  (hash-table-keys (jsonrpc--request-continuations proc)))
 
-(defun jrpc--make-process (name contact)
+(defun jsonrpc--make-process (name contact)
   "Make a process from CONTACT.
 NAME is a name to give the inferior process or connection.
-CONTACT is as explained in `jrpc-connect'.  Returns a process
+CONTACT is as explained in `jsonrpc-connect'.  Returns a process
 object."
   (let* ((readable-name (format "JSON-RPC server (%s)" name)                   
                                         )
          (buffer (get-buffer-create (format "*%s stderr*" readable-name)))
@@ -237,11 +241,11 @@ object."
                                                                   name)))))))
     (set-process-buffer proc buffer)
     (set-marker (process-mark proc) (with-current-buffer buffer (point-min)))
-    (set-process-filter proc #'jrpc--process-filter)
-    (set-process-sentinel proc #'jrpc--process-sentinel)
+    (set-process-filter proc #'jsonrpc--process-filter)
+    (set-process-sentinel proc #'jsonrpc--process-sentinel)
     proc))
 
-(defmacro jrpc-obj (&rest what)
+(defmacro jsonrpc-obj (&rest what)
   "Make WHAT a suitable argument for `json-encode'."
   (declare (debug (&rest form)))
   ;; FIXME: maybe later actually do something, for now this just fixes
@@ -249,7 +253,7 @@ object."
   `(list ,@what))
 
 ;;;###autoload
-(cl-defun jrpc-connect (name contact dispatcher &optional on-shutdown)
+(cl-defun jsonrpc-connect (name contact dispatcher &optional on-shutdown)
   "Connect to JSON-RPC server hereafter known as NAME through CONTACT.
 
 NAME is a string naming the server.
@@ -261,7 +265,7 @@ interpreted as (HOST PORT PARAMETERS...) to connect to an
 existing server via TCP, with the remaining PARAMETERS are given
 to `open-network-stream's optional arguments.  CONTACT can also
 be a live connected process object. In that case its buffer,
-filter and sentinel are overwritten by `jrpc-connect'.
+filter and sentinel are overwritten by `jsonrpc-connect'.
 
 ON-SHUTDOWN, if non-nil, is a function called on server exit and
 passed the moribund process object as a single argument.
@@ -275,48 +279,48 @@ contains the method parameters as JSON data.
 
 If ID is non-nil, DISPATCHER is expected to reply to the
 request. If it doesn't, or if it signals an error before doing
-so, jrpc.el will automatically reply with an error. If DISPATCHER
-signals an error with alist elements `jrpc-error-message' and
-`jrpc-error-code' in its DATA, the corresponding elements are
+so, jsonrpc.el will automatically reply with an error. If DISPATCHER
+signals an error with alist elements `jsonrpc-error-message' and
+`jsonrpc-error-code' in its DATA, the corresponding elements are
 used for the automated error reply.
 
-`jrpc-connect' returns a process object representing the server."
-  (let* ((proc (jrpc--make-process name contact)))
-    (setf (jrpc-contact proc) contact
-          (jrpc-name proc) name
-          (jrpc--dispatcher proc) dispatcher
-          (jrpc--on-shutdown proc) on-shutdown)
+`jsonrpc-connect' returns a process object representing the server."
+  (let* ((proc (jsonrpc--make-process name contact)))
+    (setf (jsonrpc-contact proc) contact
+          (jsonrpc-name proc) name
+          (jsonrpc--dispatcher proc) dispatcher
+          (jsonrpc--on-shutdown proc) on-shutdown)
     (with-current-buffer (process-buffer proc)
       (let ((inhibit-read-only t)) (erase-buffer) (read-only-mode t) proc))))
 
-(defun jrpc--process-sentinel (proc change)
+(defun jsonrpc--process-sentinel (proc change)
   "Called when PROC undergoes CHANGE."
-  (jrpc-log-event proc `(:message "Process state changed" :change ,change))
+  (jsonrpc-log-event proc `(:message "Process state changed" :change ,change))
   (when (not (process-live-p proc))
-    (with-current-buffer (jrpc-events-buffer proc)
+    (with-current-buffer (jsonrpc-events-buffer proc)
       (let ((inhibit-read-only t))
         (insert "\n----------b---y---e---b---y---e----------\n")))
     ;; Cancel outstanding timers
     (maphash (lambda (_id triplet)
                (pcase-let ((`(,_success ,_error ,timeout) triplet))
                  (when timeout (cancel-timer timeout))))
-             (jrpc--request-continuations proc))
+             (jsonrpc--request-continuations proc))
     (unwind-protect
         ;; Call all outstanding error handlers
         (maphash (lambda (_id triplet)
                    (pcase-let ((`(,_success ,error ,_timeout) triplet))
                      (funcall error `(:code -1 :message "Server died"))))
-                 (jrpc--request-continuations proc))
-      (jrpc-message "Server exited with status %s" (process-exit-status proc))
-      (funcall (or (jrpc--on-shutdown proc) #'ignore) proc)
+                 (jsonrpc--request-continuations proc))
+      (jsonrpc-message "Server exited with status %s" (process-exit-status 
proc))
+      (funcall (or (jsonrpc--on-shutdown proc) #'ignore) proc)
       (delete-process proc))))
 
-(defun jrpc--process-filter (proc string)
+(defun jsonrpc--process-filter (proc string)
   "Called when new data STRING has arrived for PROC."
   (when (buffer-live-p (process-buffer proc))
     (with-current-buffer (process-buffer proc)
       (let ((inhibit-read-only t)
-            (expected-bytes (jrpc--expected-bytes proc)))
+            (expected-bytes (jsonrpc--expected-bytes proc)))
         ;; Insert the text, advancing the process marker.
         ;;
         (save-excursion
@@ -360,15 +364,16 @@ used for the automated error reply.
                                       (condition-case-unless-debug oops
                                           (json-read)
                                         (error
-                                         (jrpc-warn "Invalid JSON: %s %s"
-                                                    (cdr oops) (buffer-string))
+                                         (jsonrpc-warn "Invalid JSON: %s %s"
+                                                       (cdr oops) 
(buffer-string))
                                          nil))))
                                 (when json-message
                                   ;; Process content in another
                                   ;; buffer, shielding proc buffer from
                                   ;; tamper
                                   (with-temp-buffer
-                                    (jrpc--process-receive proc 
json-message)))))
+                                    (jsonrpc--process-receive proc
+                                                              json-message)))))
                           (goto-char message-end)
                           (delete-region (point-min) (point))
                           (setq expected-bytes nil))))
@@ -378,13 +383,13 @@ used for the automated error reply.
                       (setq done 
:waiting-for-more-bytes-in-this-message))))))))
           ;; Saved parsing state for next visit to this filter
           ;;
-          (setf (jrpc--expected-bytes proc) expected-bytes))))))
+          (setf (jsonrpc--expected-bytes proc) expected-bytes))))))
 
-(defun jrpc-events-buffer (process &optional interactive)
+(defun jsonrpc-events-buffer (process &optional interactive)
   "Display events buffer for current JSONRPC connection PROCESS.
 INTERACTIVE is t if called interactively."
-  (interactive (list (jrpc-current-process-or-lose) t))
-  (let* ((probe (jrpc--events-buffer process))
+  (interactive (list (jsonrpc-current-process-or-lose) t))
+  (let* ((probe (jsonrpc--events-buffer process))
          (buffer (or (and (buffer-live-p probe)
                           probe)
                      (let ((buffer (get-buffer-create
@@ -393,16 +398,16 @@ INTERACTIVE is t if called interactively."
                        (with-current-buffer buffer
                          (buffer-disable-undo)
                          (read-only-mode t)
-                         (setf (jrpc--events-buffer process) buffer))
+                         (setf (jsonrpc--events-buffer process) buffer))
                        buffer))))
     (when interactive (display-buffer buffer))
     buffer))
 
-(defun jrpc-log-event (proc message &optional type)
-  "Log an jrpc-related event.
+(defun jsonrpc-log-event (proc message &optional type)
+  "Log an jsonrpc-related event.
 PROC is the current process.  MESSAGE is a JSON-like plist.  TYPE
 is a symbol saying if this is a client or server originated."
-  (with-current-buffer (jrpc-events-buffer proc)
+  (with-current-buffer (jsonrpc-events-buffer proc)
     (cl-destructuring-bind (&key method id error &allow-other-keys) message
       (let* ((inhibit-read-only t)
              (subtype (cond ((and method id)       'request)
@@ -421,95 +426,96 @@ is a symbol saying if this is a client or server 
originated."
             (setq msg (propertize msg 'face 'error)))
           (insert-before-markers msg))))))
 
-(defun jrpc--process-receive (proc message)
+(defun jsonrpc--process-receive (proc message)
   "Process MESSAGE from PROC."
   (pcase-let ((`(,method ,id ,error ,params ,result)
                (condition-case-unless-debug oops
                    (cl-destructuring-bind
                        (&rest args &key method id error params result _jsonrpc)
                        message (list method id error params result))
-                 (error (jrpc-warn "Invalid JSONRPC message %s: %s" message
-                                   (cdr oops))
+                 (error (jsonrpc-warn "Invalid JSONRPC message %s: %s" message
+                                      (cdr oops))
                         nil)))
               (continuations)
               (lisp-err))
-    (jrpc-log-event proc message 'server)
-    (when error (setf (jrpc-status proc) `(,error t)))
+    (jsonrpc-log-event proc message 'server)
+    (when error (setf (jsonrpc-status proc) `(,error t)))
     (cond (method
            (condition-case-unless-debug oops
-               (funcall (jrpc--dispatcher proc) proc (intern method) id params)
+               (funcall (jsonrpc--dispatcher proc) proc (intern method) id 
params)
              (error (setq lisp-err oops)))
-           (unless (or (member id (jrpc--server-request-ids proc))
+           (unless (or (member id (jsonrpc--server-request-ids proc))
                        (not (or id lisp-err)))
-             (jrpc-reply
+             (jsonrpc-reply
               proc id
-              :error (jrpc-obj
-                      :code (or (alist-get 'jrpc-error-code (cdr lisp-err))
+              :error (jsonrpc-obj
+                      :code (or (alist-get 'jsonrpc-error-code (cdr lisp-err))
                                 -32603)
-                      :message (or (alist-get 'jrpc-error-message (cdr 
lisp-err))
+                      :message (or (alist-get 'jsonrpc-error-message
+                                              (cdr lisp-err))
                                    "Internal error"))))
-           (setf (jrpc--server-request-ids proc)
-                 (delete id (jrpc--server-request-ids proc))))
+           (setf (jsonrpc--server-request-ids proc)
+                 (delete id (jsonrpc--server-request-ids proc))))
           ((setq continuations
-                 (and id (gethash id (jrpc--request-continuations proc))))
+                 (and id (gethash id (jsonrpc--request-continuations proc))))
            (let ((timer (nth 2 continuations)))
              (when timer (cancel-timer timer)))
-           (remhash id (jrpc--request-continuations proc))
+           (remhash id (jsonrpc--request-continuations proc))
            (if error (funcall (nth 1 continuations) error)
              (funcall (nth 0 continuations) result)))
           (id
-           (jrpc-warn "No continuation for id %s" id)))
-    (jrpc--call-deferred proc)))
+           (jsonrpc-warn "No continuation for id %s" id)))
+    (jsonrpc--call-deferred proc)))
 
-(defun jrpc--process-send (proc message)
+(defun jsonrpc--process-send (proc message)
   "Send MESSAGE to PROC (ID is optional)."
   (let ((json-object-type 'plist)
         (json (json-encode message)))
     (process-send-string proc (format "Content-Length: %d\r\n\r\n%s"
                                       (string-bytes json)
                                       json))
-    (jrpc-log-event proc message 'client)))
+    (jsonrpc-log-event proc message 'client)))
 
-(defvar jrpc--next-request-id 0)
+(defvar jsonrpc--next-request-id 0)
 
-(defun jrpc--next-request-id ()
+(defun jsonrpc--next-request-id ()
   "Compute the next id for a client request."
-  (setq jrpc--next-request-id (1+ jrpc--next-request-id)))
+  (setq jsonrpc--next-request-id (1+ jsonrpc--next-request-id)))
 
-(defun jrpc-forget-pending-continuations (proc)
+(defun jsonrpc-forget-pending-continuations (proc)
   "Stop waiting for responses from the current JSONRPC PROC."
-  (interactive (list (jrpc-current-process-or-lose)))
-  (clrhash (jrpc--request-continuations proc)))
+  (interactive (list (jsonrpc-current-process-or-lose)))
+  (clrhash (jsonrpc--request-continuations proc)))
 
-(defun jrpc-clear-status (process)
+(defun jsonrpc-clear-status (process)
   "Clear most recent error message from PROCESS."
-  (interactive (list (jrpc-current-process-or-lose)))
-  (setf (jrpc-status process) nil))
+  (interactive (list (jsonrpc-current-process-or-lose)))
+  (setf (jsonrpc-status process) nil))
 
-(defun jrpc--call-deferred (proc)
+(defun jsonrpc--call-deferred (proc)
   "Call PROC's deferred actions, who may again defer themselves."
-  (when-let ((actions (hash-table-values (jrpc--deferred-actions proc))))
-    (jrpc-log-event proc `(:running-deferred ,(length actions)))
+  (when-let ((actions (hash-table-values (jsonrpc--deferred-actions proc))))
+    (jsonrpc-log-event proc `(:running-deferred ,(length actions)))
     (mapc #'funcall (mapcar #'car actions))))
 
-(defvar jrpc-ready-predicates '()
+(defvar jsonrpc-ready-predicates '()
   "Special hook of predicates controlling deferred actions.
-If one of these returns nil, a deferrable `jrpc-async-request'
+If one of these returns nil, a deferrable `jsonrpc-async-request'
 will be deferred.  Each predicate is passed the symbol for the
 request and a process object.")
 
-(cl-defmacro jrpc-lambda (cl-lambda-list &body body)
+(cl-defmacro jsonrpc-lambda (cl-lambda-list &body body)
   (declare (indent 1) (debug (sexp &rest form)))
-  (let ((e (gensym "jrpc-lambda-elem")))
+  (let ((e (gensym "jsonrpc-lambda-elem")))
     `(lambda (,e) (apply (cl-function (lambda ,cl-lambda-list ,@body)) ,e))))
 
-(cl-defun jrpc-async-request (proc
-                              method
-                              params
-                              &rest args
-                              &key success-fn error-fn timeout-fn
-                              (timeout jrpc-request-timeout)
-                              (deferred nil))
+(cl-defun jsonrpc-async-request (proc
+                                 method
+                                 params
+                                 &rest args
+                                 &key success-fn error-fn timeout-fn
+                                 (timeout jsonrpc-request-timeout)
+                                 (deferred nil))
   "Make a request to PROC, expecting a reply, return immediately.
 The JSONRPC request is formed by METHOD, a symbol, and PARAMS a
 JSON object.
@@ -517,14 +523,14 @@ JSON object.
 The caller can expect SUCCESS-FN or ERROR-FN to be called with a
 JSONRPC `:result' or `:error' object, respectively.  If this
 doesn't happen after TIMEOUT seconds (defaults to
-`jrpc-request-timeout'), the caller can expect TIMEOUT-FN to be
+`jsonrpc-request-timeout'), the caller can expect TIMEOUT-FN to be
 called with no arguments. The default values of SUCCESS-FN,
 ERROR-FN and TIMEOUT-FN simply log the events into
-`jrpc-events-buffer'.
+`jsonrpc-events-buffer'.
 
 If DEFERRED is non-nil, maybe defer the request to a future time
 when the server is thought to be ready according to
-`jrpc-ready-predicates' (which see).  The request might never be
+`jsonrpc-ready-predicates' (which see).  The request might never be
 sent at all, in case it is overridden in the meantime by a new
 request with identical DEFERRED and for the same buffer.
 However, in that situation, the original timeout is kept.
@@ -532,7 +538,7 @@ However, in that situation, the original timeout is kept.
 Return a list (ID TIMER). ID is the new request's ID, or nil if
 the request was deferred. TIMER is a timer object set (or nil, if
 TIMEOUT is nil)"
-  (let* ((id (jrpc--next-request-id))
+  (let* ((id (jsonrpc--next-request-id))
          (timer nil)
          (make-timer
           (lambda ( )
@@ -541,78 +547,82 @@ TIMEOUT is nil)"
                   (run-with-timer
                    timeout nil
                    (lambda ()
-                     (remhash id (jrpc--request-continuations proc))
+                     (remhash id (jsonrpc--request-continuations proc))
                      (funcall (or timeout-fn
                                   (lambda ()
-                                    (jrpc-log-event
+                                    (jsonrpc-log-event
                                      proc `(:timed-out ,method :id id
                                                        :params 
,params))))))))))))
     (when deferred
       (let* ((buf (current-buffer))
-             (existing (gethash (list deferred buf) (jrpc--deferred-actions 
proc))))
+             (existing (gethash (list deferred buf)
+                                (jsonrpc--deferred-actions proc))))
         (when existing (setq timer (cadr existing)))
-        (if (run-hook-with-args-until-failure 'jrpc-ready-predicates
+        (if (run-hook-with-args-until-failure 'jsonrpc-ready-predicates
                                               deferred proc)
-            (remhash (list deferred buf) (jrpc--deferred-actions proc))
-          (jrpc-log-event proc `(:deferring ,method :id ,id :params ,params))
+            (remhash (list deferred buf) (jsonrpc--deferred-actions proc))
+          (jsonrpc-log-event proc `(:deferring ,method :id ,id :params 
,params))
           (let* ((buf (current-buffer)) (point (point))
                  (later (lambda ()
                           (when (buffer-live-p buf)
                             (with-current-buffer buf
                               (save-excursion (goto-char point)
-                                              (apply #'jrpc-async-request proc
+                                              (apply #'jsonrpc-async-request 
proc
                                                      method params args)))))))
             (puthash (list deferred buf)
                      (list later (setq timer (funcall make-timer)))
-                     (jrpc--deferred-actions proc))
+                     (jsonrpc--deferred-actions proc))
             ;; Non-local exit!
-            (cl-return-from jrpc-async-request (list nil timer))))))
+            (cl-return-from jsonrpc-async-request (list nil timer))))))
     ;; Really send it
     ;;
-    (jrpc--process-send proc (jrpc-obj :jsonrpc "2.0"
-                                       :id id
-                                       :method method
-                                       :params params))
+    (jsonrpc--process-send proc (jsonrpc-obj :jsonrpc "2.0"
+                                             :id id
+                                             :method method
+                                             :params params))
     (puthash id
              (list (or success-fn
-                       (jrpc-lambda (&rest _ignored)
-                         (jrpc-log-event
-                          proc (jrpc-obj :message "success ignored" :id id))))
+                       (jsonrpc-lambda (&rest _ignored)
+                                       (jsonrpc-log-event
+                                        proc (jsonrpc-obj :message "success 
ignored" :id id))))
                    (or error-fn
-                       (jrpc-lambda (&key code message &allow-other-keys)
-                         (setf (jrpc-status proc) `(,message t))
-                         (jrpc-log-event
-                          proc (jrpc-obj :message "error ignored, status set"
-                                         :id id :error code))))
+                       (jsonrpc-lambda (&key code message &allow-other-keys)
+                                       (setf (jsonrpc-status proc) `(,message 
t))
+                                       (jsonrpc-log-event
+                                        proc (jsonrpc-obj :message "error 
ignored, status set"
+                                                          :id id :error 
code))))
                    (setq timer (funcall make-timer)))
-             (jrpc--request-continuations proc))
+             (jsonrpc--request-continuations proc))
     (list id timer)))
 
-(cl-defun jrpc-request (proc method params &key deferred)
+(cl-defun jsonrpc-request (proc method params &key deferred)
   "Make a request to PROC, wait for a reply.
-Like `jrpc-async-request' for PROC, METHOD and PARAMS, but
+Like `jsonrpc-async-request' for PROC, METHOD and PARAMS, but
 synchronous, i.e. doesn't exit until anything
 interesting (success, error or timeout) happens.  Furthermore,
 only exit locally (and return the JSONRPC result object) if the
 request is successful, otherwise exit non-locally with an error.
 
-DEFERRED is passed to `jrpc-async-request', which see."
-  (let* ((tag (cl-gensym "jrpc-request-catch-tag"))
+DEFERRED is passed to `jsonrpc-async-request', which see."
+  (let* ((tag (cl-gensym "jsonrpc-request-catch-tag"))
          req-id req-timer
          (retval
           (unwind-protect ; protect against user-quit, for example
               (catch tag
                 (pcase-let
                     ((`(,id ,timer)
-                      (jrpc-async-request
+                      (jsonrpc-async-request
                        proc method params
                        :success-fn (lambda (result) (throw tag `(done 
,result)))
-                       :error-fn (jrpc-lambda (&key code message data)
-                                   (throw tag `(error (jrpc-error-code . ,code)
-                                                      (jrpc-error-message . 
,message)
-                                                      (jrpc-error-data . 
,data))))
-                       :timeout-fn (lambda ()
-                                     (throw tag '(error (jrpc-error-message . 
"Timed out"))))
+                       :error-fn
+                       (jsonrpc-lambda
+                        (&key code message data)
+                        (throw tag `(error (jsonrpc-error-code . ,code)
+                                           (jsonrpc-error-message . ,message)
+                                           (jsonrpc-error-data . ,data))))
+                       :timeout-fn
+                       (lambda ()
+                         (throw tag '(error (jsonrpc-error-message . "Timed 
out"))))
                        :deferred deferred)))
                   (setq req-id (or id 'deferred) req-timer timer))
                 (while t (accept-process-output nil 30)))
@@ -620,25 +630,25 @@ DEFERRED is passed to `jrpc-async-request', which see."
     (when (eq 'error (car retval))
       (signal 'error
               (cons
-               (format "[jrpc] jrpc-request (%s) failed:" req-id) (cdr 
retval))))
+               (format "[jsonrpc] jsonrpc-request (%s) failed:" req-id) (cdr 
retval))))
     (cadr retval)))
 
-(cl-defun jrpc-notify (proc method params)
+(cl-defun jsonrpc-notify (proc method params)
   "Notify PROC of something, don't expect a reply.e"
-  (jrpc--process-send proc (jrpc-obj :jsonrpc  "2.0"
-                                     :method method
-                                     :params params)))
+  (jsonrpc--process-send proc (jsonrpc-obj :jsonrpc  "2.0"
+                                           :method method
+                                           :params params)))
 
-(cl-defun jrpc-reply (proc id &key (result nil result-supplied-p) error)
+(cl-defun jsonrpc-reply (proc id &key (result nil result-supplied-p) error)
   "Reply to PROC's request ID with RESULT or ERROR."
-  (unless id (jrpc-error "Need a non-nil ID"))
+  (unless id (jsonrpc-error "Need a non-nil ID"))
   (unless (xor result-supplied-p error)
-    (jrpc-error "Can't pass both RESULT and ERROR!"))
-  (push id (jrpc--server-request-ids proc))
-  (jrpc--process-send
+    (jsonrpc-error "Can't pass both RESULT and ERROR!"))
+  (push id (jsonrpc--server-request-ids proc))
+  (jsonrpc--process-send
    proc `(:jsonrpc  "2.0" :id ,id
                     ,@(when result `(:result ,result))
                     ,@(when error `(:error ,error)))))
 
-(provide 'jrpc)
-;;; jrpc.el ends here
+(provide 'jsonrpc)
+;;; jsonrpc.el ends here



reply via email to

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