Subject: Re: bug#77856: 31.0.50; Add markdown-ts-mode support to eglot/eldoc

From: João Távora <[email-masked]>
Date: Fri, 18 Apr 2025 15:35:28 +0100

Eli Zaretskii <[email-masked]> writes:

>> Instead of relying on this workaround, would it be possible to support
>> `markdown-ts-mode` (or optionally `gfm-view-mode`) within
>> `eglot--format-markup` directly? This could be an opt-in feature for
>> users who prefer either mode for viewing Markdown content.

I'm interested in adding markdown-ts-mode support to Eglot (not only to
the Eglot->Eldoc interface but potentially also to the Eglot->Company
interface).

So a patch is welcome.  There is already a customization option
eglot-prefer-plaintext so no additional opt-in/out logic is required or
desired.  If that variable is nil the order should be:

-> Use markdown-ts-mode if it is available.
-> Use markdown-mode.el's gfm-view-mode if it is available
-> Go with plaintext as is done down.

It's important to keep in mind that Eglot works in Emacs versions as far
back as 26.3 and it should stay that way unless there's good reason to
break it.

An fboundp check should be enough.  The change is easiest if you first
replace all eglot.el's use of `gfm-view-mode' with an argless call to a
new symbol-returning helper function called
eglot--markdown-renderer-mode, for example.

An etc/EGLOT-NEWS entry should accompany the change.

>> Thanks for considering!

Good luck and thanks in advance!

João