From 16a43c65835a59ef3958e5a155c802e1bc811fda Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Wed, 7 May 2025 09:20:18 +0300 Subject: [PATCH] Don't ignore errors in diff-syntax-fontify-hunk. * lisp/nxml/nxml-mode.el (nxml-extend-region): Protect against error "Invalid search bound (wrong side of point)". * lisp/vc/diff-mode.el (diff-syntax-fontify-hunk): Use 'with-demoted-errors' instead of 'ignore-errors'. (cherry picked from commit ddc7bd547a2b422c4b8dca30076c0d9b70de09ad) --- lisp/nxml/nxml-mode.el | 3 ++- lisp/vc/diff-mode.el | 6 +----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/lisp/nxml/nxml-mode.el b/lisp/nxml/nxml-mode.el index 7acc19b9058..1f2c7e81a09 100644 --- a/lisp/nxml/nxml-mode.el +++ b/lisp/nxml/nxml-mode.el @@ -817,7 +817,8 @@ Called with `font-lock-beg' and `font-lock-end' dynamically bound." (skip-syntax-forward " ") ;; find the beginning of the previous tag - (when (not (equal (char-after) ?\<)) + (when (and (not (equal (char-after) ?\<)) + (< nxml-prolog-end (point))) (search-backward "<" nxml-prolog-end t)) (nxml-ensure-scan-up-to-date) (nxml-move-outside-backwards) diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index e13825c473e..194b0f5cb55 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -3143,11 +3143,7 @@ When OLD is non-nil, highlight the hunk from the old source." ((memq diff-font-lock-syntax '(hunk-also hunk-only)) (with-temp-buffer (insert text) - ;; Enabling a major mode on a single hunk without - ;; sufficient context often raises many errors such as - ;; "Premature end of data", "Invalid search bound", etc. - ;; So need to ignore all these errors. - (ignore-errors + (with-demoted-errors "%S" (diff-syntax-fontify-props file text line-nb t))))))))) ;; Put properties over the hunk text -- 2.39.5