From f529f554a38c1d6cfbf2ece60d18a4d0c0a21caa Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Mon, 14 May 2018 21:49:58 +0100 Subject: [PATCH] Jrpc-connect is now passed a generic dispatching function * eglot.el (eglot--dispatch): New helper. (eglot--connect): Use it. * jrpc.el (jrpc--dispatcher, jrpc--request-continuations) (jrpc--server-request-ids): New process-local var. (jrpc--pending-continuations, jrpc--method-prefix): Remove. (jrpc-connect): Take DISPATCHER instead of PREFIX. (jrpc--process-receive): Use proc's dispatcher. (jrpc--process-send): Make private. (jrpc-forget-pending-continuations, jrpc-async-request) (jrpc-reply, jrpc-notify): Use new function names. --- lisp/progmodes/eglot.el | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 879972df1b1..13aeff69569 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -277,9 +277,18 @@ INTERACTIVE is t if called interactively." (defvar eglot-connect-hook nil "Hook run after connecting in `eglot--connect'.") +(defun eglot--dispatch (proc method id &rest params) + ;; a server notification or a server request + (let* ((handler-sym (intern (concat "eglot--server-" method)))) + (if (functionp handler-sym) + (apply handler-sym proc (append params (if id `(:id ,id)))) + (jrpc-reply + proc id + :error (jrpc-obj :code -32601 :message "Unimplemented"))))) + (defun eglot--connect (project managed-major-mode name command dont-inhibit) - (let ((proc (jrpc-connect name command "eglot--server-" #'eglot--on-shutdown))) + (let ((proc (jrpc-connect name command #'eglot--dispatch #'eglot--on-shutdown))) (setf (eglot--project proc) project) (setf (eglot--major-mode proc)managed-major-mode) (push proc (gethash project eglot--processes-by-project)) -- 2.39.2