From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: Major modes using `widen' is a good, even essential, programming practice. Date: Mon, 8 Aug 2022 10:38:36 +0000 Message-ID: References: <6ae35c9306ade07b4c45@heytings.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24854"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Gregory Heytings , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Aug 08 13:19:08 2022 Return-path: Envelope-to: ged-emacs-devel@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 1oL0mp-0006Gw-Vi for ged-emacs-devel@m.gmane-mx.org; Mon, 08 Aug 2022 13:19:07 +0200 Original-Received: from localhost ([::1]:45528 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oL0mo-0004Hn-QL for ged-emacs-devel@m.gmane-mx.org; Mon, 08 Aug 2022 07:19:06 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54968) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oL09i-00084o-9k for emacs-devel@gnu.org; Mon, 08 Aug 2022 06:38:42 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:60954 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.90_1) (envelope-from ) id 1oL09f-0002sq-Cs for emacs-devel@gnu.org; Mon, 08 Aug 2022 06:38:41 -0400 Original-Received: (qmail 95467 invoked by uid 3782); 8 Aug 2022 10:38:37 -0000 Original-Received: from acm.muc.de (p4fe1582e.dip0.t-ipconnect.de [79.225.88.46]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Mon, 08 Aug 2022 12:38:37 +0200 Original-Received: (qmail 5149 invoked by uid 1000); 8 Aug 2022 10:38:36 -0000 Content-Disposition: inline In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de Received-SPF: pass client-ip=193.149.48.1; envelope-from=acm@muc.de; helo=mail.muc.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:293250 Archived-At: Hello, Stefan. On Sun, Aug 07, 2022 at 19:21:32 -0400, Stefan Monnier wrote: > > Where, exactly are the terms of this supposed contract formulated? > I'm not sure it's written anywhere. > More specifically, for `jit-lock-functions`, the contract is not > very constraining. > For font-lock the contract is not still very explicit but is more > constraining in that we expect major modes not to look before point-min > or after point-max. For that reason font-lock normally widens the > buffer before it does anything else (unless `font-lock-dont-widen` is > set). > > And which part of this supposed contract has CC Mode broken? > It calls `widen` within its font-lock code. I can't remember exactly why CC Mode widens here (though I could surely find it in my notes), but it should be largely harmless in normal buffers. > Eli Zaretskii [2022-08-07 17:20:52] wrote: > > jit-lock calls the functions with two arguments, BEG and END, and > > expects them to work only on that chunk of text. > That is not the case: it expects the function to "fontify" *at least* > from BEG to END, but is quite happy to let it fontify more (and the > function can return a value indicating which portion was actually > returned in that case). Furthermore, it's clear that fontification of > BEG..END may need to look at text before BEG (and occasionally beyond > END as well). It's also worth pointing out that _looking_ at text, whatever that means exactly, is an order of magnitude faster than _fontifying_ that text. > Stefan -- Alan Mackenzie (Nuremberg, Germany).