From d581bdf0e1b51295bac2c3cca18368b3b992fc7a Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Mon, 5 May 2025 19:52:28 +0300 Subject: [PATCH] * lisp/vc/diff-mode.el (diff-syntax-fontify-hunk): Add 'ignore-errors'. (cherry picked from commit e5746d3677b86ef3d0ba0d7f1e916180cc4b6f69) --- lisp/vc/diff-mode.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index acdcb691ae9..e13825c473e 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -3143,7 +3143,12 @@ 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) - (diff-syntax-fontify-props file text line-nb t)))))))) + ;; 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 + (diff-syntax-fontify-props file text line-nb t))))))))) ;; Put properties over the hunk text (goto-char beg) -- 2.39.5