diff options
| author | João Távora | 2026-01-11 12:42:47 +0000 |
|---|---|---|
| committer | João Távora | 2026-01-11 13:15:27 +0000 |
| commit | a59fafde755acc8fe29b3ec8464f8200a9be4591 (patch) | |
| tree | ad06b6b63d4c853d1585f99dc7e7f0d1db5edffa | |
| parent | 4484a9f87536ee0caff4b1f53fde8f4f3ac4adbe (diff) | |
| download | emacs-a59fafde755acc8fe29b3ec8464f8200a9be4591.tar.gz emacs-a59fafde755acc8fe29b3ec8464f8200a9be4591.zip | |
Eglot: don't use text-property-search-forward unavailable on 26.3
* lisp/progmodes/eglot.el (eglot--format-markup)
(eglot--semtok-font-lock-2): Rewrite.
* test/lisp/progmodes/eglot-tests.el (eglot--semtok-wait): Rewrite.
| -rw-r--r-- | lisp/progmodes/eglot.el | 35 | ||||
| -rw-r--r-- | test/lisp/progmodes/eglot-tests.el | 9 |
2 files changed, 26 insertions, 18 deletions
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index f75a512e18a..05075bffc87 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el | |||
| @@ -2172,21 +2172,22 @@ MARKUP is either an LSP MarkedString or MarkupContent object." | |||
| 2172 | (setq-local markdown-fontify-code-blocks-natively t) | 2172 | (setq-local markdown-fontify-code-blocks-natively t) |
| 2173 | (insert string) | 2173 | (insert string) |
| 2174 | (let ((inhibit-message t) | 2174 | (let ((inhibit-message t) |
| 2175 | (message-log-max nil) | 2175 | (message-log-max nil)) |
| 2176 | match) | ||
| 2177 | (ignore-errors (delay-mode-hooks (funcall render-mode))) | 2176 | (ignore-errors (delay-mode-hooks (funcall render-mode))) |
| 2178 | (font-lock-ensure) | 2177 | (font-lock-ensure) |
| 2179 | (goto-char (point-min)) | 2178 | (goto-char (point-min)) |
| 2180 | (let ((inhibit-read-only t)) | 2179 | (let ((inhibit-read-only t)) |
| 2181 | (when (fboundp 'text-property-search-forward) | 2180 | ;; If `render-mode' is `gfm-view-mode', the `invisible' |
| 2182 | ;; If `render-mode' is `gfm-view-mode', the `invisible' | 2181 | ;; regions are set to `markdown-markup'. Set them to 't' |
| 2183 | ;; regions are set to `markdown-markup'. Set them to 't' | 2182 | ;; instead, since this has actual meaning in the "*eldoc*" |
| 2184 | ;; instead, since this has actual meaning in the "*eldoc*" | 2183 | ;; buffer where we're taking this string (#bug79552). |
| 2185 | ;; buffer where we're taking this string (#bug79552). | 2184 | (cl-loop for from = (point) then to |
| 2186 | (while (setq match (text-property-search-forward 'invisible)) | 2185 | while (< from (point-max)) |
| 2187 | (put-text-property (prop-match-beginning match) | 2186 | for inv = (get-text-property from 'invisible) |
| 2188 | (prop-match-end match) | 2187 | for to = (or (next-single-property-change from 'invisible) |
| 2189 | 'invisible t)))) | 2188 | (point-max)) |
| 2189 | when inv | ||
| 2190 | do (put-text-property from to 'invisible t))) | ||
| 2190 | (string-trim (buffer-string)))))) | 2191 | (string-trim (buffer-string)))))) |
| 2191 | 2192 | ||
| 2192 | (defun eglot--read-server (prompt &optional dont-if-just-the-one) | 2193 | (defun eglot--read-server (prompt &optional dont-if-just-the-one) |
| @@ -5125,12 +5126,12 @@ lock machinery calls us again." | |||
| 5125 | (with-silent-modifications | 5126 | (with-silent-modifications |
| 5126 | (save-excursion | 5127 | (save-excursion |
| 5127 | (cl-loop | 5128 | (cl-loop |
| 5128 | initially (goto-char beg) | 5129 | for from = beg then to |
| 5129 | for match = (text-property-search-forward 'eglot--semtok-faces) | 5130 | while (< from end) |
| 5130 | while (and match (< (point) end)) | 5131 | for faces = (get-text-property from 'eglot--semtok-faces) |
| 5131 | do (dolist (f (prop-match-value match)) | 5132 | for to = (or (next-single-property-change from 'eglot--semtok-faces nil end) end) |
| 5132 | (add-face-text-property | 5133 | when faces |
| 5133 | (prop-match-beginning match) (prop-match-end match) f))))))) | 5134 | do (dolist (f faces) (add-face-text-property from to f))))))) |
| 5134 | 5135 | ||
| 5135 | 5136 | ||
| 5136 | ;;; Call and type hierarchies | 5137 | ;;; Call and type hierarchies |
diff --git a/test/lisp/progmodes/eglot-tests.el b/test/lisp/progmodes/eglot-tests.el index a51ef42d276..c2d67dc3530 100644 --- a/test/lisp/progmodes/eglot-tests.el +++ b/test/lisp/progmodes/eglot-tests.el | |||
| @@ -1576,7 +1576,14 @@ GUESSED-MAJOR-MODES-SYM are bound to the useful return values of | |||
| 1576 | '(3 "Timeout waiting for semantic tokens") | 1576 | '(3 "Timeout waiting for semantic tokens") |
| 1577 | (while (not (save-excursion | 1577 | (while (not (save-excursion |
| 1578 | (goto-char pos) | 1578 | (goto-char pos) |
| 1579 | (text-property-search-forward 'eglot--semtok-faces))) | 1579 | (cl-loop |
| 1580 | for from = (point) then to | ||
| 1581 | while (< from (point-max)) | ||
| 1582 | for faces = (get-text-property from 'eglot--semtok-faces) | ||
| 1583 | for to = (or (next-single-property-change | ||
| 1584 | from 'eglot--semtok-faces) | ||
| 1585 | (point-max)) | ||
| 1586 | when faces return t))) | ||
| 1580 | (accept-process-output nil 0.1) | 1587 | (accept-process-output nil 0.1) |
| 1581 | (font-lock-ensure)))) | 1588 | (font-lock-ensure)))) |
| 1582 | 1589 | ||