From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Gregory Heytings Newsgroups: gmane.emacs.devel Subject: Re: Major modes using `widen' is a good, even essential, programming practice. Date: Mon, 08 Aug 2022 10:41:08 +0000 Message-ID: <5e6d30abc3d269d9c96b@heytings.org> References: <6ae35c9306ade07b4c45@heytings.org> Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35915"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Alan Mackenzie , 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:13:21 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 1oL0hF-0009C1-8l for ged-emacs-devel@m.gmane-mx.org; Mon, 08 Aug 2022 13:13:21 +0200 Original-Received: from localhost ([::1]:36512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oL0hE-0006Un-AK for ged-emacs-devel@m.gmane-mx.org; Mon, 08 Aug 2022 07:13:20 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55410) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oL0C8-0002Jl-W5 for emacs-devel@gnu.org; Mon, 08 Aug 2022 06:41:15 -0400 Original-Received: from heytings.org ([95.142.160.155]:42498) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oL0C7-0003O2-Dn for emacs-devel@gnu.org; Mon, 08 Aug 2022 06:41:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heytings.org; s=20220101; t=1659955269; bh=zN2x77AagLUHw8+uvck/JzAzgDyU9qZsrmfpSdGZRDI=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:From; b=4/zWFcL+yQcI4GfWtoPkHcI9R5JlKHsAM0kSIqpBydchD/VTcv/AaHx+aQxldeMWB B66blRKfCKi2JEN885tjqe6Ua9nBYjFTsk/s/kmOvckimAADo4xtmuSw/5u0PG9CxG 297oJMg43k9uUXP/I2HpOqVIriezEXdsqQJuY6imlc4UzGbJ/jn13QRjNkziJp27+f i55CMhif/MgGOKYU0BICm729fsDvSgKJnc29UUW5ft5k3h3ZLqvxlIittjTPkyEC/Y Xip77qU7vVvpIBinn1XyyJfM4XY/92fiU9LYR3Dc2W6mHjV17XcDFPIGPZUE4QSvZr RmZ9ROK1zViCA== In-Reply-To: Received-SPF: pass client-ip=95.142.160.155; envelope-from=gregory@heytings.org; helo=heytings.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-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:293249 Archived-At: >> 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). > And how much is "more"? There's a reason it's called "jit-lock" and not "aot-lock", isn't it? The docstring of jit-lock-mode is quite clear about this: it's a "demand-driven buffer fontification", "triggered by Emacs C code", with which "fontification occurs when necessary" when motion commands "would otherwise reveal unfontified areas". Likewise "the START and END of the region to fontify" in the docstring of jit-lock-functions give the bounds within which fontification is supposed to happen. Exceeding these bounds a bit, say by a few hundred characters, is okay; considering that they are mere hints and that the whole buffer can potentially be modified isn't. > > Furthermore, it's clear that fontification of BEG..END may need to look > at text before BEG (and occasionally beyond END as well). > Yes, and that's one the reasons why the locked narrowed region is in fact quite large. For example, with emacs -Q, the size (width x height) of the window is 2880 characters, and the locked narrowed region is 16800 characters, roughly equally distributed before and after point. That's (inside a long line) about three screenfulls before and three screenfulls after point.