[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#71353: [PATCH] eglot--format-markup doesn't support MarkedString cod
From: |
João Távora |
Subject: |
bug#71353: [PATCH] eglot--format-markup doesn't support MarkedString code-blocks |
Date: |
Tue, 18 Jun 2024 14:39:20 +0100 |
On Sat, Jun 15, 2024 at 1:36 PM Eli Zaretskii <eliz@gnu.org> wrote:
>
> > 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.
The gist of the patch is correct, but please consider replacing by
this alternative, I don't like if-let inside pcase-let, it's too
complex: the following patch should be "flatter".
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 6896baf30ce..eabe01a1676 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -1863,14 +1863,22 @@ eglot--snippet-expansion-fn
(apply #'yas-expand-snippet args)))))
(defun eglot--format-markup (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))))))
+ "Format MARKUP according to LSP's spec.
+MARKUP is either an LSP MarkedString or MarkupContent object."
+ (let (string mode language)
+ (cond ((stringp markup)
+ (setq string markup
+ mode 'gfm-view-mode))
+ ((setq language (plist-get markup :language))
+ (setq string (concat "```" language "\n"
+ (plist-get markup :value) "\n```")
+ mode 'gfm-view-mode))
+ (t
+ (setq string (plist-get markup :value)
+ mode (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)
- bug#71353: [PATCH] eglot--format-markup doesn't support MarkedString code-blocks, Troy Brown, 2024/06/03
- bug#71353: [PATCH] eglot--format-markup doesn't support MarkedString code-blocks, Felician Nemeth, 2024/06/04
- bug#71353: [PATCH] eglot--format-markup doesn't support MarkedString code-blocks, Troy Brown, 2024/06/04
- bug#71353: [PATCH] eglot--format-markup doesn't support MarkedString code-blocks, Felician Nemeth, 2024/06/04
- bug#71353: [PATCH] eglot--format-markup doesn't support MarkedString code-blocks, Troy Brown, 2024/06/04
- bug#71353: [PATCH] eglot--format-markup doesn't support MarkedString code-blocks, Felician Nemeth, 2024/06/04
- bug#71353: [PATCH] eglot--format-markup doesn't support MarkedString code-blocks, Eli Zaretskii, 2024/06/15
- bug#71353: [PATCH] eglot--format-markup doesn't support MarkedString code-blocks, João Távora, 2024/06/15
- bug#71353: [PATCH] eglot--format-markup doesn't support MarkedString code-blocks, Eli Zaretskii, 2024/06/15
- bug#71353: [PATCH] eglot--format-markup doesn't support MarkedString code-blocks,
João Távora <=
- bug#71353: [PATCH] eglot--format-markup doesn't support MarkedString code-blocks, Troy Brown, 2024/06/30