From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: master 7362554: Widen around c-font-lock-fontify-region. This fixes bug #38049. Date: Thu, 14 Nov 2019 16:29:38 -0500 Message-ID: References: <20191109144026.20810.76129@vcs0.savannah.gnu.org> <20191109144027.DDC3720927@vcs0.savannah.gnu.org> <38328d99-23c8-7ba7-a23d-e70ac0aab67a@yandex.ru> <20191111203445.GA5135@ACM> <7497e71d-bab6-fa04-bbc4-f52fadeda16d@yandex.ru> <20191113211936.GB4942@ACM> <6fc930a1-eb47-9e54-8752-8cf7ff041586@yandex.ru> <03042d05-2160-77c4-9abd-b0f13f638247@yandex.ru> <83woc24ets.fsf@gnu.org> <83h836466w.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="202768"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: acm@muc.de, emacs-devel@gnu.org, dgutov@yandex.ru To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Nov 14 22:30:41 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iVMhN-000qYo-9C for ged-emacs-devel@m.gmane.org; Thu, 14 Nov 2019 22:30:41 +0100 Original-Received: from localhost ([::1]:33876 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVMhL-00016T-Fs for ged-emacs-devel@m.gmane.org; Thu, 14 Nov 2019 16:30:39 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48816) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVMgU-000155-JG for emacs-devel@gnu.org; Thu, 14 Nov 2019 16:29:47 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iVMgS-0003Ez-IT for emacs-devel@gnu.org; Thu, 14 Nov 2019 16:29:45 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:16628) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iVMgQ-0003EW-Rr; Thu, 14 Nov 2019 16:29:43 -0500 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 0C50C449CDE; Thu, 14 Nov 2019 16:29:42 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 7D494449CD9; Thu, 14 Nov 2019 16:29:40 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1573766980; bh=QJpNkYsqoAniKxOpU58uDvbe9teSmDctu6dV1glbPbE=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=I6SwurBmYQHg9fX7IJHoynR1gJEDdq0mQc1pNX24iWglNy3fKfwB1oxDwGgfJR6PN q6MbHKuSQNqhrEB7xnBGo6LAomvITeDBBAEzIb9NnoLO/COvlWmlBKqcDEaCNNgYqx TBbCJJswhE8zo06nkOIQqzIR14Fiqv6IE9cg1JBXE4KI32EoL3XGePDk6pDy87bDRG ibRKkwrWwWmzgOk3jLQl/D0VjpIrui7QxMDbCmYHxAoGq6/AyYYN71TnilkrqN6zpu EogOIIIsS3nw/8c6kLmBSkz/IeJCYZe1xHod+WgEWPEFYar+HXPhFgbeQJLgj/cPKJ RnGEhN6Txpv/w== Original-Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 54910120CD4; Thu, 14 Nov 2019 16:29:40 -0500 (EST) In-Reply-To: <83h836466w.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 14 Nov 2019 21:19:03 +0200") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 132.204.25.50 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:242204 Archived-At: >> I think the problem is wider than CC-mode. Maybe CC-mode is more >> susceptible to it or maybe it's just an accident that this was reported >> for CC-mode, but running font-lock (and syntax-propertize) within >> narrowing tends to be fiddly. > I'm also okay with fixing it in font-lock or jit-lock. But doing that > inside reposition.el makes no sense to me. IIUC this can't be fixed in font-lock or jit-lock. It can only be fixed "upstream" (e.g. in repos-count-screen-lines) or "downstream" (in the particular major mode's rules). I think neither "upstream" nor "downstream" is satisfactory, but until/unless we introduce some "structure" on the narrowings (so that font-lock can know for sure whether and how it can widen) that's what we have to live with. > So we are going to do such changes in every application that calls > vertical-motion, directly or indirectly? I'd phrase it as "this would need to be done in any narrowing which changes point-min and internally can trigger jit-lock". Whether we're going to do it or not I don't know. I think "don't change point-min" is generally the better fix (which partly means weaning ourselves from narrowing). > And what about posn-at-point, or pos-visible-in-window-p, or any other > API that uses the display code internally? If these can trigger jit-lock then that applies as well, yes. `sit-for` as well, BTW. > are we going to fix their callers as well? The fix should not be "where we can do vertical-motion (and friends)" but "where we narrow (and later trigger jit-lock)". Whether that means "fix their callers as well" depends on what it is that owns the "their callers": yes it would be in the functions that call (directly or not) `vertical-motion` (and friends) but in the functions that call those functions. >> > In particular, what if the POINT-MIN..END chunk is still too large to >> > fontify in one go? >> AFAIK all uses of jit-lock are more efficient if they get fewer larger >> chunks than more smaller chunks. > So you are saying that we should enlarge jit-lock-chunk-size to > most-positive-fixnum? That would cause jit-lock being applied not just to "fewer larger chunks" but also to more total text: when the redisplay calls jit-lock, we know POS will be displayed and needs to be jit-locked but we don't how far further we will keep looking, and that what jit-lock-chunk-size is for (it's supposed to be large enough that the per-chunk overhead doesn't kill it while being small enough that the amount of text we needlessly jit-lock isn't too large either). In the presently discussed patch we know beforehand that all the text between start and end will be considered and will need to be jit-locked, which is why we can do it more efficiently in a single explicit call than what the redisplay code would do otherwise. In any case, changing the narrow-to-region so it doesn't change point-min is the right fix. Adding a call to `jit-lock-fontify-now` is another but worse way to fix it. Adding that call should be harmless and could be beneficial for performance, but I personally wouldn't do it (it can also be harmful for performance in the case where the text has already been jit-locked in which case it won't do anything but will still take a bit of time to do it). Stfan