unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Augusto Stoffel <arstoffel@gmail.com>
To: "João Távora" <joaotavora@gmail.com>
Cc: Eli Zaretskii <eliz@gnu.org>, 72343@debbugs.gnu.org
Subject: bug#72343: [PATCH] Fix eglot-server-programs for TeX modes
Date: Tue, 06 Aug 2024 20:48:00 +0200	[thread overview]
Message-ID: <87frrhxzbz.fsf@gmail.com> (raw)
In-Reply-To: <CALDnm53BHitCAu+p_=d4Ue9H7acVEWJ1ddPkTi3YyZqgnkQK=Q@mail.gmail.com> ("João Távora"'s message of "Tue, 6 Aug 2024 19:08:45 +0100")

On Tue,  6 Aug 2024 at 19:08, João Távora wrote:

> On Tue, Aug 6, 2024 at 5:38 PM Augusto Stoffel <arstoffel@gmail.com> wrote:
>
>> > So there's no "single pick" in general.
>> You don't need to explain that to me ;-).
>
> It is you who alluded to a single pick, so I thought I had to.  Also
> earlier you proposed multiple entries in eglot-server-programs, which
> would impede this multi-language-per-session feature.>  So I figured you
> wouldn't be familiar with it.

Fair enough.

>> What I want to achieve (or, if I may, what Eglot should do) in case it
>> wasn't clear yet, is: file x.tex is sent language id "latex" and file
>> y.tex is sent language id "plain-tex".
>
> Indeed it wasn't clear, so I'm very glad I asked.  I don't see
> "plain-tex" in the list over at
>
>   https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/
>
> I just see "tex" and "latex" and "bibtex".

I know about the list, but unfortunately "tex" as a language id makes no
sense.  It's like saying a program is written in "lisp" without saying
which Lisp dialect.

> But it won't for many other cases.  The fact that Emacs models
> latex-mode as a descendent of tex-mode is something Eglot can't do
> anything about.  It means that Emacs thinks that that every LaTex
> program is a TeX program at least at some syntactic level (is this true?
> no idea).

Again, every TeX program belongs to a specific dialect: plain TeX, LaTeX
and ConTeXt being the main ones.  Accordingly, tex-mode is not a real
major mode; it's just an "abstract base mode" from which the actual TeX
modes derive (see the docstring for details).

> I do think that's the lesser of two evils though.  So anyway this is my
> suggestion:
>
> @@ -292,7 +292,7 @@ eglot-server-programs
>      (scala-mode . ,(eglot-alternatives
>                      '("metals" "metals-emacs")))
>      (racket-mode . ("racket" "-l" "racket-langserver"))
> -    ((tex-mode context-mode texinfo-mode bibtex-mode)
> +    ((latex-mode (plain-tex-mode :language-id "tex") context-mode
> texinfo-mode bibtex-mode)
>       . ,(eglot-alternatives '("digestif" "texlab")))
>      (erlang-mode . ("erlang_ls" "--transport" "stdio"))
>      ((yaml-ts-mode yaml-mode) . ("yaml-language-server" "--stdio"))

So again, for the reason above, I wouldn't do what you suggest here.

> In theory, this could also be fixed by keeping tex-mode in there, and
> then adjusting Eglot's heuristic, by ranking the potential ancestors and
> selecting the closest one, in 'eglot--languageId'.  Could be tricky or
> could be easy, feel free to give it a shot.

(The status quo is already way too complicated, and this doesn't sound
like an improvement in that regard...)

> Yet another idea is to not reorder modes at all in 'eglot--lookup-mode'
> and use an explicit order to express this ranking.  I admit I don't
> remember what the reordering idea (main-mode-sym is the local var name)
> is for.  it couldprecede the multiple-language-ids feature.  Or it could
> be essential for some other thing: testing would be needed.
>
>> This doesn't matter, as it's an Eglot issue.  Any TeX server will do.
>
> This is not established, at least not yet.  You are requesting for a
> "plain-tex" LSP languageId property to be sent and that is outside the
> spec as far as I can tell from reading the spec.  Maybe your digestif
> server supports and likes it, though.  But it might break "texlab" for
> all I know.

Note also that the LSP spec says nothing about ConTeXt or Texinfo.
Moreover, texlab only supports latex and bibtex.

> Even the fact that "tex" is all that's being sent at the
> moment may or may not be a bug -- only LaTex/Tex specialists can say
> that.  And certainly a capable enough language server, which is tasked
> with analysing a file syntactically, can do much the same as our own
> tex-mode.el and figure out the correct language from the contents.
> Might do it better than Emacs.

That's true, and in fact it's true all languages.  So a server could as
well ignore the language id and deduce it on its own -- except for the
caveat that ultimately the user might know better and it's useful to
rely on the user's choice of major mode / language id.

> That said, if you really want to send "plain-tex", then there are two
> options.  You can change your user value of eglot-server-programs,
> obviously.  Or you can confirm with "texlab" that they don't mind, in
> which case -- but only in that case -- your latest patch is acceptable.

I didn't ask but I don't see what could go wrong, given that texlab is
for latex and bibtex only.





  reply	other threads:[~2024-08-06 18:48 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-28 18:08 bug#72343: [PATCH] Fix eglot-server-programs for TeX modes Augusto Stoffel
2024-07-28 18:20 ` Eli Zaretskii
2024-07-28 21:31   ` João Távora
2024-07-29  6:15     ` Augusto Stoffel
2024-07-29 11:26       ` Eli Zaretskii
2024-07-30 18:20         ` Augusto Stoffel
2024-07-30 20:29           ` João Távora
     [not found]             ` <CAHixrvYMZTMRSpixw2CAkdx_b+hdPZDkB7s+1X1sUX4E7jPWHw@mail.gmail.com>
     [not found]               ` <CALDnm50sjTEnSxJ3Rzna3pets2bjHnVF=6vix1gM_54+VoHNvQ@mail.gmail.com>
2024-08-02 15:13                 ` Augusto Stoffel
2024-08-02 15:29                   ` João Távora
2024-08-06 15:04                     ` Augusto Stoffel
2024-08-06 15:34                       ` João Távora
2024-08-06 15:45                         ` Augusto Stoffel
2024-08-06 16:27                           ` João Távora
2024-08-06 16:38                             ` Augusto Stoffel
2024-08-06 18:08                               ` João Távora
2024-08-06 18:48                                 ` Augusto Stoffel [this message]
2024-08-06 22:52                                   ` João Távora
2024-08-07  7:02                                     ` Augusto Stoffel
2024-08-07  8:47                                       ` João Távora
2024-08-07  9:17                                         ` Augusto Stoffel
2024-08-07 13:17                                           ` João Távora
2024-08-07  6:33                                 ` Augusto Stoffel
2024-08-07 13:23                                   ` João Távora
2024-08-12 16:37                                     ` Philip Kaludercic
2024-08-12 16:53                                       ` 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=87frrhxzbz.fsf@gmail.com \
    --to=arstoffel@gmail.com \
    --cc=72343@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=joaotavora@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).