From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#61215: 29.0.60; font-lock broken in diff-mode with long lines Date: Fri, 03 Feb 2023 13:59:57 +0200 Message-ID: <83pmarufgi.fsf@gnu.org> References: <86lelh6yhq.fsf_-_@mail.linkov.net> <83cz6tz12b.fsf@gnu.org> <86o7qcf2x5.fsf@mail.linkov.net> <83a61vx0jo.fsf@gnu.org> <86bkmbfalm.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31927"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 61215@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Feb 03 13:01:24 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNukt-00085i-Cm for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 03 Feb 2023 13:01:23 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNuke-0006O5-Mn; Fri, 03 Feb 2023 07:01:08 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNukZ-0006Mu-1t for bug-gnu-emacs@gnu.org; Fri, 03 Feb 2023 07:01:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pNukY-0000xm-PD for bug-gnu-emacs@gnu.org; Fri, 03 Feb 2023 07:01:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pNukY-0000s3-Ji for bug-gnu-emacs@gnu.org; Fri, 03 Feb 2023 07:01:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 03 Feb 2023 12:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61215 X-GNU-PR-Package: emacs Original-Received: via spool by 61215-submit@debbugs.gnu.org id=B61215.16754256033184 (code B ref 61215); Fri, 03 Feb 2023 12:01:02 +0000 Original-Received: (at 61215) by debbugs.gnu.org; 3 Feb 2023 12:00:03 +0000 Original-Received: from localhost ([127.0.0.1]:36637 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pNujb-0000pI-37 for submit@debbugs.gnu.org; Fri, 03 Feb 2023 07:00:03 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:36950) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pNujY-0000oH-Sf for 61215@debbugs.gnu.org; Fri, 03 Feb 2023 07:00:01 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNujS-0000M7-Mw; Fri, 03 Feb 2023 06:59:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=Kz5kW64pWNXmFBLIcjECdAGUJ/LJRz5E0fmoqTXYG48=; b=ViXlzGk4oQkutgdM4+zl ohGJyzZX2603EmC2+EEshFgQFdr9WIRTDt9XWPuhA+EB1rN0s9AYW1HlbNJnhiSUoBiIRgOA86lCq ql1SRYQMe22QhBvRJ2Z+oUEn3xbt5TI6EuM9MnNyq/3fMe/XMeyMkqB5DtkoRU05ziKS7busgmulA 3LqW/B+aSdcYEutDLlVPaNmbkctjQ/PzdrZnxft4kYh5qjJRybgeMJhU0W9oTpH/lmILRJiIIW3xZ JGxB87pHEJA8S6NOSEysgPORjb+eoRoZ+pZW0dd6Z6EZpWzr5gdMwZzoJ61B8KL8X3F0t+LOZw/rr Nj8sI+mCeoNAgg==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNujS-00065f-6P; Fri, 03 Feb 2023 06:59:54 -0500 In-Reply-To: <86bkmbfalm.fsf@mail.linkov.net> (message from Juri Linkov on Fri, 03 Feb 2023 09:53:57 +0200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:254727 Archived-At: > From: Juri Linkov > Cc: 61215@debbugs.gnu.org > Date: Fri, 03 Feb 2023 09:53:57 +0200 > > >> 1. Set debug-on-error and backtrace-on-redisplay-error to t > >> 2. Create a commit with some diff hunks in a prog mode at the beginning, > >> and a single-line 1MB file added at the end; > >> 3. From *vc-change-log* type `d' on that commit that opens *vc-diff* buffer > >> 4. Scroll the *vc-diff* buffer > >> > >> It displays an error in the *Warning* buffer: > >> > >> ⛔ Warning (error): Error in a redisplay Lisp hook. See buffer *Redisplay_trace* > > > > Can you reproduce this easily? > > Once you create such a commit, it's easy to reproduce this on it. The recipe is quite complicated, doesn't include a file with the long line that you used, and describes several steps in incomplete and vague manner. So it isn't so easy to reproduce for me, not really. I'd probably need several attempts until I succeed, and the fact that I need to create a repository just for this doesn't help (diff-mode is not just for VCS diffs, right?) If you can add the missing details and the file, it might be easier. > > If so, does the patch below help? > > Unfortunately, no. Still such a backtrace: > > Error: args-out-of-range (# 2000 1906) > mapbacktrace(#f(compiled-function (evald func args flags) #)) > debug-early-backtrace() > debug-early(error (args-out-of-range # 2000 1906)) > buffer-substring-no-properties(2000 1906) > (let* ((hunk (buffer-substring-no-properties (max beg (point-min)) (min end (point-max)))) ... > diff-syntax-fontify-hunk(2000 250945 nil) > diff-syntax-fontify(2000 250945) > #(2000 250945) > diff--iterate-hunks(10000 #) > diff--font-lock-syntax(10000) 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)))) ;; Trim a trailing newline to find hunk in diff-syntax-fontify-props ;; in diffs that have no newline at end of diff file. (text (string-trim-right