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#57447: 28.1.90; Can font-lock stop requesting fontification of invisible text? Date: Sat, 27 Aug 2022 10:02:39 +0300 Message-ID: <837d2u184w.fsf@gnu.org> References: <87fshi6ygu.fsf@localhost> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32696"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 57447@debbugs.gnu.org To: Ihor Radchenko Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Aug 27 09:03:33 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 1oRpqu-0008LF-0F for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 27 Aug 2022 09:03:32 +0200 Original-Received: from localhost ([::1]:38610 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRpqs-00043b-6y for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 27 Aug 2022 03:03:30 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41992) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRpqT-000430-3j for bug-gnu-emacs@gnu.org; Sat, 27 Aug 2022 03:03:08 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:37051) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oRpqQ-0006Bb-3w for bug-gnu-emacs@gnu.org; Sat, 27 Aug 2022 03:03:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oRpqP-0001xZ-Q2 for bug-gnu-emacs@gnu.org; Sat, 27 Aug 2022 03:03:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 27 Aug 2022 07:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57447 X-GNU-PR-Package: emacs Original-Received: via spool by 57447-submit@debbugs.gnu.org id=B57447.16615837527497 (code B ref 57447); Sat, 27 Aug 2022 07:03:01 +0000 Original-Received: (at 57447) by debbugs.gnu.org; 27 Aug 2022 07:02:32 +0000 Original-Received: from localhost ([127.0.0.1]:55033 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oRppv-0001wr-RD for submit@debbugs.gnu.org; Sat, 27 Aug 2022 03:02:32 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:39024) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oRppu-0001we-Ph for 57447@debbugs.gnu.org; Sat, 27 Aug 2022 03:02:31 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:40682) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRppp-00068j-JI; Sat, 27 Aug 2022 03:02:25 -0400 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=hIp4yiyNy7rTRKHz8kix7Xjr/33ZYFwLLfQgZVNgKC4=; b=Gw9Xt6jy2nZy UUiE8ZRl9HlJkzCuu8MMLlXAWp9wKyE7JIOc1PcqZd208Cxpqmuy+1R8zg16a8ExstCjQDA6I8KBe 5+ftQIj6tRFkXW1sgeDpnYjuysTo8b6IACd9VECfTCE0fKL5oEatsfrmZYNT2wqU/llyO5+CL6nrE 36dofmHXu9/CXhpk/jtPM7xg3eoQHv51SEWVdNahS7dZMy3sjj7SdPR/SFNwqZcUOkNXhVGs90o3V 1QYBpfzu+Y4SoQqqwQ62qSBI9eKiZVoSO5Xcb45R4CbhSRBjxnI/2rXbJ67t26lMomEw3yq39GKvT j2EelkEsynH+PKxm1GgxHw==; Original-Received: from [87.69.77.57] (port=2293 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 1oRppo-0005xo-V8; Sat, 27 Aug 2022 03:02:25 -0400 In-Reply-To: <87fshi6ygu.fsf@localhost> (message from Ihor Radchenko on Sat, 27 Aug 2022 13:34:57 +0800) 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:240881 Archived-At: > From: Ihor Radchenko > Date: Sat, 27 Aug 2022 13:34:57 +0800 > > Org mode tends to hide large chunks of text under folded headlines. > I expect this hidden text to be ignored by the font-lock engine. > > However, in reality, there appear to be some scenarios when hidden text > is, in fact, being requested for fontification. > > I have an Org file with a number of folded headlines. 32 of them can fit > into one screen of text on my system, when folded. The total character > count contained within the folded headlines (both visible and inside the > 32 hidden text chunks) is 12742. However, most of this text is folded, and only 2446 characters are visible in the buffer. > > I expect font-lock to fontify around 2446 characters (32 lines), but > Emacs instead requests fontification of 9374 characters (315 lines; 10 > screens of text) at once; ~1.5k chars for each folded text region. > > Fontification of 10 screens of text is obviously 10x slower and can > create noticeable feedback slowdowns. > > Can anything be done to make Emacs fontify less (or none) of the hidden > text? I explained that recently, in a discussion in which you participated: the display engine skips invisible text, but that cannot completely avoid fontifications of some of the invisible text. The technical reason for that is that the display engine considers the 'fontified' property before it considers the 'invisible' property (and any other properties). Since fontification-functions put text properties on buffer text, the 'fontified' property _must_ be examined first, and the fontification-functions _must_ be invoked _before_ the properties are examined; otherwise we'd risk behaving incorrectly due to outdated or not-yet-existing properties. One way this could be improved is by making jit-lock-chunk-size smaller. This will make the probability of such "over-fontification" lower. If a mode _knows_ that no fontifications could ever produce invisible properties or overlays, then its fontification-functions could stop whenever they encounter invisible text. > The fontification log is: > > org-font-lock: About to fontify 13481..15094 > org-font-lock: Fontified drawer(13372..13487) completely. Thanks, but this log is insufficient to analyze whether the code functions correctly. To do such an analysis one must know which text parts (in therms of buffer positions) were invisible and which weren't. Also, you haven't shown the code which produces the log, so the exact meanings of "about to fontify", "fontfied drawer", and the rest of the log messages, as well as the numerical notations like "13487:+235", are unclear.