Subject: Re: bug#71353: [PATCH] eglot--format-markup doesn't support MarkedString code-blocks

From: Eli Zaretskii <[email-masked]>
Date: Sat, 15 Jun 2024 15:36:27 +0300

> From: João Távora <[email-masked]>
> Date: Sat, 15 Jun 2024 10:37:48 +0100
> Cc: Felician Nemeth <[email-masked]>, Troy Brown <[email-masked]>, 
> 	[email-masked]
> 
> Can you please resend the patch for inspection?

Attached.

>From e9c6387eb123aac1fe4741a871be2b68128de41a Mon Sep 17 00:00:00 2001
From: Troy Brown <[email-masked]>
Date: Tue, 4 Jun 2024 08:30:53 -0400
Subject: [PATCH] Eglot: Support formatting MarkedString code-block

* lisp/progmodes/eglot.el (eglot--format-markup): Add support
for MarkedString code-block.

Copyright-paperwork-exempt: yes
---
 lisp/progmodes/eglot.el | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 5ccae5210fe..70224d0dcd6 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -1861,11 +1861,15 @@ eglot--format-markup
   "Format MARKUP according to LSP's spec."
   (pcase-let ((`(,string ,mode)
                (if (stringp markup) (list markup 'gfm-view-mode)
-                 (list (plist-get markup :value)
-                       (pcase (plist-get markup :kind)
-                         ("markdown" 'gfm-view-mode)
-                         ("plaintext" 'text-mode)
-                         (_ major-mode))))))
+                 (if-let ((language (plist-get markup :language))
+                          (value (plist-get markup :value)))
+                     (list (concat "```" language "\n" value "\n```")
+                           'gfm-view-mode)
+                   (list (plist-get markup :value)
+                         (pcase (plist-get markup :kind)
+                           ("markdown" 'gfm-view-mode)
+                           ("plaintext" 'text-mode)
+                           (_ major-mode)))))))
     (with-temp-buffer
       (setq-local markdown-fontify-code-blocks-natively t)
       (insert string)
-- 
2.37.1