diff options
| author | Spencer Baugh | 2025-10-01 17:28:47 -0400 |
|---|---|---|
| committer | João Távora | 2025-10-03 09:44:56 +0100 |
| commit | 3ec87212a4227e08ffa46ccbf2f0eb198f99c1aa (patch) | |
| tree | 77a1d512b6a24117decfd74f093b7fd142797ad0 | |
| parent | 72f3f48d3676f7a31d4eb3f3bfc394ef58827d12 (diff) | |
| download | emacs-3ec87212a4227e08ffa46ccbf2f0eb198f99c1aa.tar.gz emacs-3ec87212a4227e08ffa46ccbf2f0eb198f99c1aa.zip | |
Eglot: make markup invisible instead of deleting it (bug#79552)
We use gfm-view-mode to render Markdown before we hand over the string
to ElDoc (which usually put it in a 'special' mode "*eldoc*" buffer).
'gfm-view-mode' adds keymap text properties to make links clickable. It
also makes some of the markup invisible with a special 'invisible'
property value which is specific to 'gfm-view-mode'. We used to delete
the latter, therefore breaking the link-clicking. Simply resetting the
regions with non-nil 'invisible' to 't' instead of deleting them fixes
this. See also https://github.com/joaotavora/eglot/discussions/1238
* lisp/progmodes/eglot.el: Make invisible markup invisible
instead of deleting it.
* etc/EGLOT-NEWS: Mention bugfix.
Co-authored-by: João Távora <joaotavora@gmail.com>
| -rw-r--r-- | etc/EGLOT-NEWS | 6 | ||||
| -rw-r--r-- | lisp/progmodes/eglot.el | 11 |
2 files changed, 14 insertions, 3 deletions
diff --git a/etc/EGLOT-NEWS b/etc/EGLOT-NEWS index 6505a6d8567..23104edd5d6 100644 --- a/etc/EGLOT-NEWS +++ b/etc/EGLOT-NEWS | |||
| @@ -54,6 +54,12 @@ by the LSP server pertain. This helps in skipping useless or harmful | |||
| 54 | updates, avoiding flakiness with code actions and flickering overlays | 54 | updates, avoiding flakiness with code actions and flickering overlays |
| 55 | when the buffer is changed. | 55 | when the buffer is changed. |
| 56 | 56 | ||
| 57 | ** Markdown links migrating to *eldoc* buffer now clickable (bug#79552) | ||
| 58 | |||
| 59 | Eglot now preserves crucial properties in the Markdown documentation | ||
| 60 | provided by the LSP server, fixing a longstanding bug with clickable | ||
| 61 | hyperlinks. See also github#1238. | ||
| 62 | |||
| 57 | 63 | ||
| 58 | * Changes in Eglot 1.18 (20/1/2025) | 64 | * Changes in Eglot 1.18 (20/1/2025) |
| 59 | 65 | ||
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index b35d5e15e6c..6a7edef08b3 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el | |||
| @@ -2018,7 +2018,7 @@ Doubles as an indicator of snippet support." | |||
| 2018 | (unless (bound-and-true-p yas-minor-mode) (yas-minor-mode 1)) | 2018 | (unless (bound-and-true-p yas-minor-mode) (yas-minor-mode 1)) |
| 2019 | (apply #'yas-expand-snippet args))))) | 2019 | (apply #'yas-expand-snippet args))))) |
| 2020 | 2020 | ||
| 2021 | (defun eglot--format-markup (markup &optional mode) | 2021 | (defun eglot--format-markup (markup &optional mode) |
| 2022 | "Format MARKUP according to LSP's spec. | 2022 | "Format MARKUP according to LSP's spec. |
| 2023 | MARKUP is either an LSP MarkedString or MarkupContent object." | 2023 | MARKUP is either an LSP MarkedString or MarkupContent object." |
| 2024 | (let (string render-mode language) | 2024 | (let (string render-mode language) |
| @@ -2050,9 +2050,14 @@ MARKUP is either an LSP MarkedString or MarkupContent object." | |||
| 2050 | (goto-char (point-min)) | 2050 | (goto-char (point-min)) |
| 2051 | (let ((inhibit-read-only t)) | 2051 | (let ((inhibit-read-only t)) |
| 2052 | (when (fboundp 'text-property-search-forward) | 2052 | (when (fboundp 'text-property-search-forward) |
| 2053 | ;; If `render-mode' is `gfm-view-mode', the `invisible' | ||
| 2054 | ;; regions are set to `markdown-markup'. Set them to 't' | ||
| 2055 | ;; instead, since this has actual meaning in the "*eldoc*" | ||
| 2056 | ;; buffer where we're taking this string (#bug79552). | ||
| 2053 | (while (setq match (text-property-search-forward 'invisible)) | 2057 | (while (setq match (text-property-search-forward 'invisible)) |
| 2054 | (delete-region (prop-match-beginning match) | 2058 | (put-text-property (prop-match-beginning match) |
| 2055 | (prop-match-end match))))) | 2059 | (prop-match-end match) |
| 2060 | 'invisible t)))) | ||
| 2056 | (string-trim (buffer-string)))))) | 2061 | (string-trim (buffer-string)))))) |
| 2057 | 2062 | ||
| 2058 | (defun eglot--read-server (prompt &optional dont-if-just-the-one) | 2063 | (defun eglot--read-server (prompt &optional dont-if-just-the-one) |