From: João Távora Date: Mon, 6 Aug 2018 16:53:09 +0000 (+0100) Subject: Accept functions as entries in eglot-server-programs X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~459 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=71a3fb813f8e4055bc4f9f68db73be5aa17d0867;p=emacs.git Accept functions as entries in eglot-server-programs CONTACT in the (MAJOR-MODE . CONTACT) association in eglot-server-programs can now be a function of no arguments producing any value previously valid for contact. The function is called at time of `M-x eglot` or `eglot-ensure`. This is useful for servers requiring command-line invocations that depend on the specific momentary environment. * eglot.el (eglot-server-programs): CONTACT can be a fucntion of no arguments. (eglot--guess-contact, eglot--connect): Accept function CONTACTs. GitHub-reference: per https://github.com/joaotavora/eglot/issues/63 --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index c3a0d518d85..33b478f4af6 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -121,7 +121,10 @@ of those modes. CONTACT can be: converted to produce a plist with a suitable :PROCESS initarg to CLASS-NAME. The class `eglot-lsp-server' descends `jsonrpc-process-connection', which you should see for the - semantics of the mandatory :PROCESS argument.") + semantics of the mandatory :PROCESS argument. + +* A function of no arguments producing any of the above values + for CONTACT.") (defface eglot-mode-line '((t (:inherit font-lock-constant-face :weight bold))) @@ -310,6 +313,7 @@ be guessed." (lambda (m1 m2) (or (eq m1 m2) (and (listp m1) (memq m2 m1))))))) + (guess (if (functionp guess) (funcall guess) guess)) (class (or (and (consp guess) (symbolp (car guess)) (prog1 (car guess) (setq guess (cdr guess)))) 'eglot-lsp-server)) @@ -457,6 +461,7 @@ This docstring appeases checkdoc, that's all." (nickname (file-name-base (directory-file-name default-directory))) (readable-name (format "EGLOT (%s/%s)" nickname managed-major-mode)) autostart-inferior-process + (contact (if (functionp contact) (funcall contact) contact)) (initargs (cond ((keywordp (car contact)) contact) ((integerp (cadr contact)) @@ -1658,7 +1663,7 @@ If SKIP-SIGNATURE, don't try to send textDocument/signatureHelp." "Passes through required cquery initialization options" (let* ((root (car (project-roots (eglot--project server)))) (cache (expand-file-name ".cquery_cached_index/" root))) - (list :cacheDirectory (file-name-as-directory cache) + (list :cacheDirectory (file-name-as-directory cache)Ini :progressReportFrequencyMs -1)))