From: João Távora Date: Fri, 4 May 2018 14:19:19 +0000 (+0100) Subject: Handle dynamic registration in general (but nothing specific yet) X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~637 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b83cd67751ecb8a1d08993f0751bc5d3dc480a24;p=emacs.git Handle dynamic registration in general (but nothing specific yet) * eglot.el (eglot--server-client/registerCapability): Implement. (eglot--register-workspace/didChangeWatchedFiles): Dummy registrator. --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 68fe3e287a8..2b3f270ef9c 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -1003,15 +1003,28 @@ running. INTERACTIVE is t if called interactively." (cl-defun eglot--server-client/registerCapability (proc &key id registrations) "Handle notification client/registerCapability" - (mapc (lambda (reg) - (apply (cl-function - (lambda (&key _id _method _registerOptions) - ;;; TODO: handle this - )) - reg)) - registrations) - (eglot--reply proc id :error (eglot--obj :code -32601 - :message "sorry :-("))) + (catch 'done + (mapc + (lambda (reg) + (apply + (cl-function + (lambda (&key id method registerOptions) + (pcase-let* + ((handler-sym (intern (concat "eglot--register-" + method))) + (`(,ok ,message) + (and (functionp handler-sym) + (apply handler-sym proc :id id registerOptions)))) + (unless ok + (throw + 'done + (eglot--reply proc id + :error (eglot--obj + :code -32601 + :message (or message "sorry :-(")))))))) + reg)) + registrations) + (eglot--reply proc id :result (eglot--obj :message "OK")))) (defvar eglot--recent-before-changes nil "List of recent changes as collected by `eglot--before-change'.") @@ -1176,6 +1189,16 @@ Calls REPORT-FN maybe if server publishes diagnostics in time." ;; make the server report new diagnostics. (eglot--signal-textDocument/didChange)) + +;;; Dynamic registration +;;; +(cl-defun eglot--register-workspace/didChangeWatchedFiles + (_proc &key _id _watchers) + "Handle dynamic registration of workspace/didChangeWatchedFiles" + ;; TODO: file-notify-add-watch and + ;; file-notify-rm-watch can probably handle this + (list nil "Sorry, can't do this yet")) + ;;; Rust-specific ;;;