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: Mon, 06 Feb 2023 20:10:24 +0200 Message-ID: <83lelapsvj.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> <83pmarufgi.fsf@gnu.org> <86ilggc6gn.fsf@mail.linkov.net> <83mt5sq7nr.fsf@gnu.org> <86edr2davu.fsf@mail.linkov.net> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38041"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 61215@debbugs.gnu.org To: Juri Linkov , Gregory Heytings Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Feb 06 19:11:21 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 1pP5xX-0009io-9b for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 06 Feb 2023 19:11:19 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pP5xI-0005n9-0Q; Mon, 06 Feb 2023 13:11:04 -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 1pP5xG-0005n1-DT for bug-gnu-emacs@gnu.org; Mon, 06 Feb 2023 13:11:02 -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 1pP5xG-00063z-5D for bug-gnu-emacs@gnu.org; Mon, 06 Feb 2023 13:11:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pP5xF-0008G2-Q8 for bug-gnu-emacs@gnu.org; Mon, 06 Feb 2023 13:11:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 06 Feb 2023 18:11:01 +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.167570702231687 (code B ref 61215); Mon, 06 Feb 2023 18:11:01 +0000 Original-Received: (at 61215) by debbugs.gnu.org; 6 Feb 2023 18:10:22 +0000 Original-Received: from localhost ([127.0.0.1]:49858 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pP5wc-0008F1-8y for submit@debbugs.gnu.org; Mon, 06 Feb 2023 13:10:22 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:46236) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pP5wa-0008Eg-7a for 61215@debbugs.gnu.org; Mon, 06 Feb 2023 13:10:20 -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 1pP5wU-0005bZ-Dc; Mon, 06 Feb 2023 13:10:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=y3ZHfuPpY8KSgGhOsio0bcitDcFSeDy92EXsVonTCCM=; b=M4oNQnrWph1D E6B5Gs2zWkl1ynFUw9oSDYkxcDgDfZ1hfVhxtj9Chv/fviIKu1ah63e2wr/TIItEffSMR+H/wtxbZ 4bK6WRn4TgBJqanX3JFJUfLLybNVkLW3WmZCrWAhHxEBk9PK/PiGxDXYyu88qfQ/kbH5srY0zr658 tupZftYS5/H1bDQw+XYXdoBxdTS/pmRiwYrhG9UQw0F+NFTUOFHCDEcd3QeLplnFWP1pv8XWD9vOj 5BoCgsOTIK/pzH8qm3OoDQPhpOHW071w1sVbRzNGXPfzKdWEJkND6ojNNK9u5N7ZMvFiQB/YgH10A /rkYZMl/EYqDaGUszuoHZg==; 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 1pP5wQ-00016b-Rl; Mon, 06 Feb 2023 13:10:14 -0500 In-Reply-To: <86edr2davu.fsf@mail.linkov.net> (message from Juri Linkov on Mon, 06 Feb 2023 19:15:49 +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:254993 Archived-At: > From: Juri Linkov > Cc: 61215@debbugs.gnu.org > Date: Mon, 06 Feb 2023 19:15:49 +0200 > > >> If you think the problem is in diff-syntax-fontify-hunk, > >> then I could try to find a working workaround local to diff-mode. > > > > Yes, now this is something for diff-mode to solve: it shouldn't assume > > that it will always be able to go to the beginning and the end of a > > hunk, because narrowing could interfere with that. Diff-mode should > > have some fallback plan for these cases. > > After debugging I discovered that the problem is not caused by font-lock > in diff-mode. The problem is in easy-mmode-define-navigation. > diff-mode uses it to navigate diff hunks. It supports such a feature > that when the user narrowed the diff buffer, it puts narrowing back > after moving to the next hunk. But this fails when the diff buffer > is narrowed automatically by long-line-optimizations. If there is > no way to distinguish whether the narrowing is automatic by long-lines > or manual by the user, this patch fixes the problem. It works without > errors, and even highlights first 250000 characters of the long line: Thanks. Maybe Gregory (CC'ed) can help here and tell whether there's a better solution. > diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el > index 5721470ad0d..d9176061434 100644 > --- a/lisp/emacs-lisp/easy-mmode.el > +++ b/lisp/emacs-lisp/easy-mmode.el > @@ -782,7 +782,10 @@ easy-mmode-define-navigation > (when-narrowed > (lambda (body) > (if (null narrowfun) body > - `(let ((was-narrowed (prog1 (buffer-narrowed-p) (widen)))) > + `(let ((was-narrowed > + (prog1 (unless (long-line-optimizations-p) > + (buffer-narrowed-p)) > + (widen)))) > ,body > (when was-narrowed (funcall #',narrowfun))))))) > (unless name (setq name base-name)) >