unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: "João Távora" <joaotavora@gmail.com>
Cc: 71353@debbugs.gnu.org, brownts@troybrown.dev, felician.nemeth@gmail.com
Subject: bug#71353: [PATCH] eglot--format-markup doesn't support MarkedString code-blocks
Date: Sat, 15 Jun 2024 15:36:27 +0300	[thread overview]
Message-ID: <86v82atmb8.fsf@gnu.org> (raw)
In-Reply-To: <CALDnm53HCcEO=+7vX=_HaGRGEaRyzYgJhXBShs0g4zS0gYQV-w@mail.gmail.com> (message from João Távora on Sat, 15 Jun 2024 10:37:48 +0100)

[-- Attachment #1: Type: text/plain, Size: 270 bytes --]

> From: João Távora <joaotavora@gmail.com>
> Date: Sat, 15 Jun 2024 10:37:48 +0100
> Cc: Felician Nemeth <felician.nemeth@gmail.com>, Troy Brown <brownts@troybrown.dev>, 
> 	71353@debbugs.gnu.org
> 
> Can you please resend the patch for inspection?

Attached.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Eglot-Support-formatting-MarkedString-code-block.patch --]
[-- Type: text/x-patch, Size: 1676 bytes --]

From e9c6387eb123aac1fe4741a871be2b68128de41a Mon Sep 17 00:00:00 2001
From: Troy Brown <brownts@troybrown.dev>
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


  reply	other threads:[~2024-06-15 12:36 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-04  2:51 bug#71353: [PATCH] eglot--format-markup doesn't support MarkedString code-blocks Troy Brown
2024-06-04  5:41 ` Felician Nemeth
2024-06-04 10:01   ` Troy Brown
2024-06-04 11:21     ` Felician Nemeth
2024-06-04 12:37       ` Troy Brown
2024-06-04 19:36         ` Felician Nemeth
2024-06-15  8:12           ` Eli Zaretskii
2024-06-15  9:37             ` João Távora
2024-06-15 12:36               ` Eli Zaretskii [this message]
2024-06-18 13:39                 ` João Távora
2024-07-01  3:28                   ` Troy Brown
2024-07-06  8:41                     ` Eli Zaretskii
2024-07-06  9:18                       ` 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=86v82atmb8.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=71353@debbugs.gnu.org \
    --cc=brownts@troybrown.dev \
    --cc=felician.nemeth@gmail.com \
    --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).