From a59fafde755acc8fe29b3ec8464f8200a9be4591 Mon Sep 17 00:00:00 2001 From: João Távora Date: Sun, 11 Jan 2026 12:42:47 +0000 Subject: 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. --- lisp/progmodes/eglot.el | 35 ++++++++++++++++++----------------- 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." (setq-local markdown-fontify-code-blocks-natively t) (insert string) (let ((inhibit-message t) - (message-log-max nil) - match) + (message-log-max nil)) (ignore-errors (delay-mode-hooks (funcall render-mode))) (font-lock-ensure) (goto-char (point-min)) (let ((inhibit-read-only t)) - (when (fboundp 'text-property-search-forward) - ;; If `render-mode' is `gfm-view-mode', the `invisible' - ;; regions are set to `markdown-markup'. Set them to 't' - ;; instead, since this has actual meaning in the "*eldoc*" - ;; buffer where we're taking this string (#bug79552). - (while (setq match (text-property-search-forward 'invisible)) - (put-text-property (prop-match-beginning match) - (prop-match-end match) - 'invisible t)))) + ;; If `render-mode' is `gfm-view-mode', the `invisible' + ;; regions are set to `markdown-markup'. Set them to 't' + ;; instead, since this has actual meaning in the "*eldoc*" + ;; buffer where we're taking this string (#bug79552). + (cl-loop for from = (point) then to + while (< from (point-max)) + for inv = (get-text-property from 'invisible) + for to = (or (next-single-property-change from 'invisible) + (point-max)) + when inv + do (put-text-property from to 'invisible t))) (string-trim (buffer-string)))))) (defun eglot--read-server (prompt &optional dont-if-just-the-one) @@ -5125,12 +5126,12 @@ lock machinery calls us again." (with-silent-modifications (save-excursion (cl-loop - initially (goto-char beg) - for match = (text-property-search-forward 'eglot--semtok-faces) - while (and match (< (point) end)) - do (dolist (f (prop-match-value match)) - (add-face-text-property - (prop-match-beginning match) (prop-match-end match) f))))))) + for from = beg then to + while (< from end) + for faces = (get-text-property from 'eglot--semtok-faces) + for to = (or (next-single-property-change from 'eglot--semtok-faces nil end) end) + when faces + do (dolist (f faces) (add-face-text-property from to f))))))) ;;; 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 '(3 "Timeout waiting for semantic tokens") (while (not (save-excursion (goto-char pos) - (text-property-search-forward 'eglot--semtok-faces))) + (cl-loop + for from = (point) then to + while (< from (point-max)) + for faces = (get-text-property from 'eglot--semtok-faces) + for to = (or (next-single-property-change + from 'eglot--semtok-faces) + (point-max)) + when faces return t))) (accept-process-output nil 0.1) (font-lock-ensure)))) -- cgit v1.2.1