unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "João Távora" <joaotavora@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: arash@gnu.org,  theophilusx@gmail.com,  emacs-devel@gnu.org
Subject: Re: Making `eglot-server-programs' a custom variable?
Date: Thu, 10 Nov 2022 15:38:32 +0000	[thread overview]
Message-ID: <874jv6akg7.fsf@gmail.com> (raw)
In-Reply-To: <83sfiqrg5g.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 10 Nov 2022 17:19:23 +0200")

Eli Zaretskii <eliz@gnu.org> writes:

>> From: João Távora <joaotavora@gmail.com>
>> Date: Thu, 10 Nov 2022 12:07:30 +0000
>> Cc: arash@gnu.org, theophilusx@gmail.com, emacs-devel@gnu.org
>> 
>>  > That said, I have no objection to converting eglot-server-programs into
>>  > a defcustom, if someone will commit to translating and maintaining all
>>  > the complex combination of options into "widget" form.  I don't have the 
>>  > time or inclination for this task, but maybe someone has.
>> 
>>  It is not a good idea to have a defcustom whose value should be such a
>>  complex data structure. 
>> 
>> I agree, but a command is a not a solution IMO: this belongs in the 
>> user's configuration file. 
>
> ??? The user init file can call the command, cannot it?

Yeah, but then why make it a command, i.e. an interactive function?  If
whatever you're proposing is going to be called interactively, it won't
persist through sessions.  So if you're proposing a simple function, I
think there's no need to for a function that simply calls add-to-list.

> And adding a command is not a replacement for having a variable:
> people who know enough Lisp can do what they want with the variable.
> The command is proposed as a replacement for a defcustom, because
> interactively customizing such a complex variable with a very long
> value is problematic at best.

Again I cannot see the point of a interactive command.  If you mean a
simple non-interactive function to be called from the user's init file,
I can't see much advantage of using that over using add-to-list, other
than auto-loading.  And auto-loading isn't necessarily an advantage: I
break out many Emacs sessions where I don't M-x eglot at all.
with-eval-after-load is the tool for the job here.

>> A good docstring (can it  be improved?) containing good descriptions 
>> and some ready-made recipes is the current and best approach to these 
>> things.
>
> Sorry, but I disagree.  No doc string can reasonably teach users
> advanced Lisp.  That's a non-starter.

Funny, that's how I learned all my Elisp until I learned of the Elisp
manual a few years ago.  And this is not "advanced" stuff at all.  This
is all that's needed:

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 204121045a0..a6df8371425 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -298,7 +298,10 @@ eglot-server-programs
   the call is interactive, the function can ask the user for
   hints on finding the required programs, etc.  Otherwise, it
   should not ask the user for any input, and return nil or signal
-  an error if it can't produce a valid CONTACT.")
+  an error if it can't produce a valid CONTACT.  This option can
+  be combined with the helper function
+  `eglot-alternatives' (which see) to define more than one
+  alternative server for a given MAJOR-MODE.")
 
 (defface eglot-highlight-symbol-face
   '((t (:inherit bold)))

Throwing in an example 3-line snippet in the manual for
eglot-alternatives is also fine:

(with-eval-after-load 'eglot
  (add-to-list 'eglot-server-programs
               `(foo-mode .
                  ,(eglot-alternatives '("fools" ("bazls" "--foo"))))))



  parent reply	other threads:[~2022-11-10 15:38 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-09 20:25 Making `eglot-server-programs' a custom variable? Arash Esbati
2022-11-09 20:49 ` Philip Kaludercic
2022-11-09 22:07   ` Arash Esbati
2022-11-10 17:47     ` Philip Kaludercic
2022-11-10 17:56       ` Stefan Monnier
2022-11-10 18:10         ` Philip Kaludercic
2022-11-10 18:29           ` Stefan Monnier
2022-11-10 19:36             ` Philip Kaludercic
2022-11-12  3:47       ` Jim Porter
2022-11-12  5:16         ` chad
2022-11-12  7:26           ` Philip Kaludercic
2022-11-12  7:34         ` Philip Kaludercic
2022-11-12  7:58         ` Eli Zaretskii
2022-11-12  8:03           ` Philip Kaludercic
2022-11-12  8:25             ` Eli Zaretskii
2022-11-12  8:45               ` Philip Kaludercic
2022-11-12  9:01                 ` Eli Zaretskii
2022-11-12  9:40                   ` Philip Kaludercic
2022-11-12 10:02                     ` Eli Zaretskii
2022-11-12 13:46                       ` Philip Kaludercic
2022-11-12 14:30                         ` Eli Zaretskii
2022-11-13  0:20                           ` Philip Kaludercic
2022-11-13  6:39                             ` Eli Zaretskii
2022-11-13  7:11                               ` Philip Kaludercic
2022-11-13  7:43                                 ` Eli Zaretskii
2022-11-15 17:50                                   ` Philip Kaludercic
2022-11-15 18:15                                     ` Eli Zaretskii
2022-11-16 13:05                                       ` Philip Kaludercic
2022-11-16 13:44                                         ` Eli Zaretskii
2022-11-16 14:12                                           ` Philip Kaludercic
2022-11-16 14:51                                             ` Eli Zaretskii
2022-11-16 17:05                                               ` Philip Kaludercic
2022-11-10  6:36 ` Eli Zaretskii
2022-11-10  7:56   ` Tim Cross
2022-11-10  8:24     ` Eli Zaretskii
2022-11-10  9:34       ` Tim Cross
2022-11-10 11:16         ` Eli Zaretskii
2022-11-10 13:59           ` Tim Cross
2022-11-10  9:18   ` Arash Esbati
2022-11-10  9:34     ` Eli Zaretskii
2022-11-10 10:25       ` João Távora
2022-11-10 17:04         ` Eli Zaretskii
2022-11-10 17:10         ` Eli Zaretskii
2022-11-10 21:45           ` João Távora
2022-11-11  6:12             ` Yuri Khan
2022-11-11  9:09               ` João Távora
2022-11-12  2:34               ` Brian Cully via Emacs development discussions.
2022-11-12 16:22                 ` Michael Albinus
2022-11-11  7:04             ` Eli Zaretskii
2022-11-11  9:12               ` João Távora
2022-11-11 11:53                 ` Eli Zaretskii
2022-11-12 14:44           ` Arash Esbati
2022-11-12 14:49             ` Eli Zaretskii
2022-11-12 14:58               ` Arash Esbati
2022-11-10 21:28     ` Augusto Stoffel
2022-11-11 10:05       ` Arash Esbati
2022-11-11 12:05         ` Eli Zaretskii
2022-11-11 12:22           ` Arash Esbati
2022-11-11 12:33             ` Eli Zaretskii
2022-11-11 13:26               ` Augusto Stoffel
2022-11-11 13:48               ` Arash Esbati
2022-11-11 13:54                 ` Eli Zaretskii
2022-11-10 10:15 ` João Távora
2022-11-10 11:23   ` Eli Zaretskii
2022-11-10 12:07     ` João Távora
2022-11-10 15:19       ` Eli Zaretskii
2022-11-10 15:35         ` Dmitry Gutov
2022-11-10 16:50           ` Eli Zaretskii
2022-11-10 18:22             ` Dmitry Gutov
2022-11-10 18:31               ` Eli Zaretskii
2022-11-10 15:38         ` João Távora [this message]
2022-11-10 16:52           ` Eli Zaretskii
2022-11-10 17:08           ` Eli Zaretskii
2022-11-10 21:13             ` João Távora
2022-11-10 13:57   ` Stefan Monnier
2022-11-10 15:21     ` João Távora
2022-11-10 17:43       ` Stefan Monnier
2022-11-10 22:10         ` João Távora

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874jv6akg7.fsf@gmail.com \
    --to=joaotavora@gmail.com \
    --cc=arash@gnu.org \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=theophilusx@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).