From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#45898: 27.1; wedged in redisplay again Date: Wed, 29 Jun 2022 12:18:47 -0400 Message-ID: References: <46b65e3f-cf3d-a3f2-9a9a-100e58274ff6@jovi.net> <83sfoe2k0j.fsf@gnu.org> <87zgim6qtt.fsf@gnus.org> <83mtem2dc9.fsf@gnu.org> <87y1y63qmq.fsf@gnus.org> <83h74t3k5u.fsf@gnu.org> <87tu8sx569.fsf@gnus.org> <83v8t6us8t.fsf@gnu.org> <87zgiinptk.fsf@gnus.org> <83mteiufih.fsf@gnu.org> <877d5kojbo.fsf@gnus.org> <83zgigu3e0.fsf@gnu.org> <500e4b9c69f2a90e7cf05b956178d71b@webmail.orcon.net.nz> <835yl3tnv3.fsf@gnu.org> <83iloyo0x7.fsf@gnu.org> <83mte5jukr.fsf@gnu.org> <837d57gbed.fsf@gnu.org> <83o7yicx3p.fsf@gnu.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28512"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: Gerd =?UTF-8?Q?M=C3=B6llmann?= , psainty@orcon.net.nz, larsi@gnus.org, Emacs-hacker2018@jovi.net, 45898@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jun 29 18:19:10 2022 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 1o6aPG-0007Bg-JZ for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 29 Jun 2022 18:19:10 +0200 Original-Received: from localhost ([::1]:54300 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o6aPF-0005U1-FS for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 29 Jun 2022 12:19:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45986) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o6aP8-0005To-LW for bug-gnu-emacs@gnu.org; Wed, 29 Jun 2022 12:19:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:37899) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o6aP8-0006I8-DN for bug-gnu-emacs@gnu.org; Wed, 29 Jun 2022 12:19:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o6aP8-0007yc-9Q for bug-gnu-emacs@gnu.org; Wed, 29 Jun 2022 12:19:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 29 Jun 2022 16:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45898 X-GNU-PR-Package: emacs Original-Received: via spool by 45898-submit@debbugs.gnu.org id=B45898.165651953730651 (code B ref 45898); Wed, 29 Jun 2022 16:19:02 +0000 Original-Received: (at 45898) by debbugs.gnu.org; 29 Jun 2022 16:18:57 +0000 Original-Received: from localhost ([127.0.0.1]:60029 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o6aP3-0007yJ-CD for submit@debbugs.gnu.org; Wed, 29 Jun 2022 12:18:57 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:60205) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o6aP1-0007y4-Nd for 45898@debbugs.gnu.org; Wed, 29 Jun 2022 12:18:56 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 4CB798070D; Wed, 29 Jun 2022 12:18:50 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id C7FE180636; Wed, 29 Jun 2022 12:18:48 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1656519528; bh=1/vJfF9WXKV3JE5yUYiRMxlFbRBs8BYk0lxrs7/mQm8=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=jeEYh8S7M9lggiP09QsNDncI0lUbX4eOP5Be98FG3yX8mjRDfhqq91GkZm4wkC1qC +K1PCkR5egGMv4vfqdFbdocoBJFDPiOoBWMA5v+d56VDB5YZpDOdkf78VOjzMVw1dD pJdOmevUt6KzC+Lol5GlEPzuzm/QgiSZ5lfRV9kqP6Klr0keuIu3DBl+iHaIuYsh8J Mczkc4hnzAbYCxWYH2cT5vpgo3DSz3LBNGsmxxMWZk/81W5u22n7/RStLd1mdDGbI9 IuRX/lUNIronVaLw9GOWZmuMvL8strjWbqmqpQTpV3/mHsPOHdcd+ElMlDpCaBN4RA /KKLcqEZmQHzQ== Original-Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id B29AE1204C0; Wed, 29 Jun 2022 12:18:48 -0400 (EDT) In-Reply-To: <83o7yicx3p.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 24 Jun 2022 10:57:30 +0300") 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" Xref: news.gmane.io gmane.emacs.bugs:235652 Archived-At: Eli Zaretskii [2022-06-24 10:57:30] wrote: >> Yes, that's exactly what I'm proposing in the paragraph you quoted. >> I think it makes sense to bound the growth of the region due to >> `font-lock-extend-region-functions`. We could bound it where we handle >> `font-lock-extend-region-functions`, or we could bound it just inside >> `font-lock-extend-region-wholelines`. > > I hope this will be done soon. How 'bout the patch below? It doesn't seem to make much difference on the `medium_line.json` example from Phil, tho :-( Stefan diff --git a/lisp/font-lock.el b/lisp/font-lock.el index df0a26f4d0f..c6bd93eb2c8 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el @@ -1258,19 +1258,31 @@ font-lock-extend-region-multiline (setq font-lock-end new-end)))) changed)) +(defvar font-lock-wholeline-max 10000 + "Maximum line length for `font-lock-extend-region-wholelines'. +If lines are longer than that, `font-lock-extend-region-wholelines' will +not always round up to whole lines, and misfontification may occur. +This is a tradeoff between correctly applying the fontification rules, +and avoiding major slowdown on pathologically long lines.") + (defun font-lock-extend-region-wholelines () "Move fontification boundaries to beginning of lines." (let ((changed nil)) (goto-char font-lock-beg) (unless (bolp) - (setq changed t font-lock-beg - (let ((inhibit-field-text-motion t)) - (line-beginning-position)))) + (let ((new (max (- font-lock-beg font-lock-wholeline-max) + (let ((inhibit-field-text-motion t)) + (line-beginning-position))))) + (unless (eql new font-lock-beg) + (setq changed t) + (setq font-lock-beg new)))) (goto-char font-lock-end) (unless (bolp) - (unless (eq font-lock-end - (setq font-lock-end (line-beginning-position 2))) - (setq changed t))) + (let ((new (min (+ font-lock-end font-lock-wholeline-max) + (line-beginning-position 2)))) + (unless (eql new font-lock-end) + (setq changed t) + (setq font-lock-end new)))) changed)) (defun font-lock-default-fontify-region (beg end loudly)