GNU bug report logs - #61215
29.0.60; font-lock broken in diff-mode with long lines

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> linkov.net>

Date: Wed, 1 Feb 2023 18:21:01 UTC

Severity: normal

Found in version 29.0.60

Full log


View this message in rfc822 format

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 61215 <at> debbugs.gnu.org
Subject: bug#61215: 29.0.60; font-lock broken in diff-mode with long lines
Date: Sun, 05 Feb 2023 20:28:24 +0200
> This probably means diff-mode relies on the buffer being widened.
> Which is a bad idea for font-lock functions.
>
> Anyway, how about the below?
>
> diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
> index eb01ded..62db362 100644
> --- a/lisp/vc/diff-mode.el
> +++ b/lisp/vc/diff-mode.el
> @@ -2762,7 +2762,10 @@ diff-syntax-fontify-hunk
>    "Highlight source language syntax in diff hunk between BEG and END.
>  When OLD is non-nil, highlight the hunk from the old source."
>    (goto-char beg)
> -  (let* ((hunk (buffer-substring-no-properties beg end))
> +  (let* ((hunk (buffer-substring-no-properties (min (max beg (point-min))
> +                                                    (point-max))
> +                                               (max (min end (point-max))
> +                                                    (point-min))))

Now a new error:

Debugger entered--Lisp error: (error "Unknown diff hunk type")
  signal(error ("Unknown diff hunk type"))
  error("Unknown diff hunk type")
  diff-hunk-text("" t nil)
  diff-syntax-fontify-hunk(2000 250992 nil)
  diff-syntax-fontify(2000 250992)
  #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_39>(2000 250992)
  diff--iterate-hunks(10000 #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_39>)
  diff--font-lock-syntax(10000)
  font-lock-fontify-keywords-region(1527 10000 nil)
  font-lock-default-fontify-region(1527 3027 nil)
  font-lock-fontify-region(1527 3027)
  #f(compiled-function (fun) #<bytecode -0x156e32bfeabd7fc3>)(font-lock-fontify-region)
  run-hook-wrapped(#f(compiled-function (fun) #<bytecode -0x156e32bfeabd7fc3>) font-lock-fontify-region)
  jit-lock--run-functions(1527 3027)
  jit-lock-fontify-now(1527 3027)
  jit-lock-function(1527)
  redisplay_internal\ \(C\ function\)()

If you think the problem is in diff-syntax-fontify-hunk,
then I could try to find a working workaround local to diff-mode.




This bug report was last modified 2 years and 76 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.