From: João Távora Date: Mon, 14 May 2018 20:49:58 +0000 (+0100) Subject: Jrpc-connect is now passed a generic dispatching function X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~489^2~25 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f529f554a38c1d6cfbf2ece60d18a4d0c0a21caa;p=emacs.git 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. --- 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))