From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ihor Radchenko Newsgroups: gmane.emacs.bugs Subject: bug#57447: 28.1.90; Can font-lock stop requesting fontification of invisible text? Date: Sat, 27 Aug 2022 15:45:19 +0800 Message-ID: <87bks66sfk.fsf@localhost> References: <87fshi6ygu.fsf@localhost> <837d2u184w.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22511"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 57447@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Aug 27 09:45:12 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 1oRqVE-0005f0-9y for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 27 Aug 2022 09:45:12 +0200 Original-Received: from localhost ([::1]:37126 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRqVD-00028r-0a for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 27 Aug 2022 03:45:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRqV4-00028h-Pm for bug-gnu-emacs@gnu.org; Sat, 27 Aug 2022 03:45:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:37073) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oRqV4-0003oO-GT for bug-gnu-emacs@gnu.org; Sat, 27 Aug 2022 03:45:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oRqV4-0002w2-D6 for bug-gnu-emacs@gnu.org; Sat, 27 Aug 2022 03:45:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ihor Radchenko Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 27 Aug 2022 07:45:02 +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.166158626611222 (code B ref 57447); Sat, 27 Aug 2022 07:45:02 +0000 Original-Received: (at 57447) by debbugs.gnu.org; 27 Aug 2022 07:44:26 +0000 Original-Received: from localhost ([127.0.0.1]:55055 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oRqUT-0002uu-RM for submit@debbugs.gnu.org; Sat, 27 Aug 2022 03:44:26 -0400 Original-Received: from mail-pj1-f49.google.com ([209.85.216.49]:34382) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oRqUS-0002uh-HC for 57447@debbugs.gnu.org; Sat, 27 Aug 2022 03:44:25 -0400 Original-Received: by mail-pj1-f49.google.com with SMTP id c16-20020a17090aa61000b001fb3286d9f7so8931471pjq.1 for <57447@debbugs.gnu.org>; Sat, 27 Aug 2022 00:44:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc; bh=CKyXrRoYWc8n+zA+qh2axCR65Qhm40pr3OQnothIyqg=; b=hqEidZefDBbGEGj+vzAJXMWU4ZFCAiKyXMYECD9bj+Yi4Q0YWkkKy8293UvtTvAJL5 cwYsj5ETw9ZMDSzXycB/p+VTyXG45zY/Dc3hW4iLwAex1a4mPj+CbkK3sEOQo5YjoLTY Pr3dumrnaEdMGojWDx7SyKGWJUevmKdWFhcYKXHvdfQcMAXCDWDoLmbOGXhO3UgQoE8D InjIR+fPkDud+S0KWj9A4y4rgAVcRU9IiRs/PBqVjcIxt5QszexLxBXjeYV5DLMPRefw 1GzpnIwb4mRK/WDFa9r8BPNsEmlJ3WV/inYuHaTzWATy/yTqxlq6Lz9vOfXsfxzyKIOz 7n8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc; bh=CKyXrRoYWc8n+zA+qh2axCR65Qhm40pr3OQnothIyqg=; b=zJEgN11XqJf+un/cPtoEdzvvCKXJHVfF3x08VrkHC2ep3C3+hZZUFV5d2DN3WRBrmH wJwtWSIwrKU95ZVMxUC0s1F3z9IsbHX+uJl8hf+ggMeWuNOyrannUS6U3J5/OtIvPrBi tu4MDaP4ObdXnKR5Q0p/Tpj8nY1MuKePqXh3/wx7AqWLr21yGKfOKp/5WkPj7S7qbeFP 4daooHKT5iga9i3fQTfHUCto8LG0E4PVLSYU30DaAqmJT9TzLXfUagPgP/9cfoCaAZf4 xz4s+IrWiNkBlQnMTgOUxoexCz7Ro+s8/i41PJfo/cZM8R3qSxoC+AoJGjPtsuHAmPrr nfkw== X-Gm-Message-State: ACgBeo0vXc1oEICATVuWwYTIKxX0oH8M0+uFPMSd29Za7EAFboBRJjy6 +YxfRPlRjmeenwtVBwXFPxf2UVkDXeA= X-Google-Smtp-Source: AA6agR5lSxfTmXe13YL+r6GfB4fg0no0IMUv8oInDVjSX8ljv0zGP0fbvUcZ0i1WOfuAnwru2wjKNQ== X-Received: by 2002:a17:903:230c:b0:173:361:c345 with SMTP id d12-20020a170903230c00b001730361c345mr6788115plh.20.1661586258346; Sat, 27 Aug 2022 00:44:18 -0700 (PDT) Original-Received: from localhost ([2409:8a70:2b3:c8a0:8ec6:81ff:fe70:339d]) by smtp.gmail.com with ESMTPSA id f189-20020a62dbc6000000b005361af33036sm3029424pfg.22.2022.08.27.00.44.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Aug 2022 00:44:17 -0700 (PDT) In-Reply-To: <837d2u184w.fsf@gnu.org> 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:240882 Archived-At: Eli Zaretskii writes: >> 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. This issue surfaced exactly because I was hoping that the overheads are not going to be too terrible if we leave Emacs decide what to fontify. In the past, Org explicitly suppressed fontification of all the hidden text. I did expect some invisible text to be fontified, but did not expect 10x increase in the requested text size. > One way this could be improved is by making jit-lock-chunk-size > smaller. This will make the probability of such "over-fontification" > lower. I tried to reduce the chunk size and at appears to help. However, I am not sure if there are other side effects of reducing jit-lock-chunk-size. > 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. This is not so simple in Org, unfortunately. Sometimes, we do want to fontify invisible text for the purposes of imenu/agenda/etc. The code required to handle invisibility manually gets quite complex: https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=dd0a723603ec4c9085a10ac8fbf864fdb026e48a >> 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. "About to fontify" refers to region boundaries used to call font-lock-fontify-region. The other messages refer to the actual fontification that was performed. The code producing the messages is in https://github.com/yantar92/org/blob/feature/org-font-lock-element/lisp/org-font-lock-core.el Search for org-font-lock-verbose in the code. If you want to test it yourself, clone https://github.com/yantar92/org and use feature/org-font-lock-element branch with the file I provided, unfold the "Home" headline, and then unfold the "Ideas ..." headline. To enable messages, you need to set org-font-lock-verbose to non-nil. -- Ihor Radchenko, Org mode contributor, Learn more about Org mode at https://orgmode.org/. Support Org development at https://liberapay.com/org-mode, or support my work at https://liberapay.com/yantar92