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#56682: feature/improved-locked-narrowing 9dee6df39c: Reworked locked narrowing. Date: Thu, 12 Jan 2023 11:34:32 +0200 Message-ID: <83eds0ksev.fsf@gnu.org> References: <166939872890.18950.12581667269687468681@vcs2.savannah.gnu.org> <20221125175209.51166C004B6@vcs2.savannah.gnu.org> <6c9d91cffc1bfd801530@heytings.org> <6c9d91cffc394613f58a@heytings.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26934"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 56682@debbugs.gnu.org To: gregory@heytings.org, Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 12 10:35:32 2023 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 1pFtzg-0006nL-0d for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 12 Jan 2023 10:35:32 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFtzS-0004RZ-3b; Thu, 12 Jan 2023 04:35:18 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFtzD-0004Qs-2P for bug-gnu-emacs@gnu.org; Thu, 12 Jan 2023 04:35:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pFtzC-0007s1-Pp for bug-gnu-emacs@gnu.org; Thu, 12 Jan 2023 04:35:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pFtzC-00072P-Gr for bug-gnu-emacs@gnu.org; Thu, 12 Jan 2023 04:35:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 12 Jan 2023 09:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56682 X-GNU-PR-Package: emacs Original-Received: via spool by 56682-submit@debbugs.gnu.org id=B56682.167351604726982 (code B ref 56682); Thu, 12 Jan 2023 09:35:02 +0000 Original-Received: (at 56682) by debbugs.gnu.org; 12 Jan 2023 09:34:07 +0000 Original-Received: from localhost ([127.0.0.1]:44691 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pFtyJ-000718-8c for submit@debbugs.gnu.org; Thu, 12 Jan 2023 04:34:07 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:47698) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pFtyH-00070e-6o for 56682@debbugs.gnu.org; Thu, 12 Jan 2023 04:34:05 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFtyB-0007km-UQ; Thu, 12 Jan 2023 04:33:59 -0500 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=odm4mgqKYvWqpSaRNz8xnhn1PTksyuR21RKAnTeqtaY=; b=Ie/EAtLhX4Jo 0bxYwI/eRi1R0X8BzxoNY9sR/Wvl8qqnuvmJu/matyK3SAbuBQ67rKdGsTBHWdcPjEaoD4f9XQcKd VfHTnvEu0fpeWcWFZLii8HzXGdFUdR9UzmoxI8C+NJ7Q4GccEb0lmuF+sFzUBKHesUiOSq111ABcS r2MrBfFjOpaY+DxkQhlnWD81ZfvQWYiGFhBVF0mydKGwNU93stbHCJfo+FKxnKYhsBWqp99ceQPIb uWPsGEVZUpEzSHgQuTOpfzJlB82Rs+0HmeMSwZXGITb4mi2Zj4RGOofT5A6vVLJvZ/qKVzlMZdv5w GWACllel3r4RAG+xws6ong==; Original-Received: from [87.69.77.57] (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 1pFty9-0002tW-UY; Thu, 12 Jan 2023 04:33:59 -0500 In-Reply-To: (bug-gnu-emacs@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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:253196 Archived-At: > Cc: 56682@debbugs.gnu.org > Date: Fri, 30 Dec 2022 13:51:19 -0500 > From: Stefan Monnier via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > > You have to know where your function is called and by which caller > > a lock was placed. > > That doesn't seem sufficient, because you need to additionally find the > name of the tag they used. AFAICT currently you can only find that out > by looking at the code. I think the names should be documented > somewhere else than just in the code itself. > > > Currently there are three such tags (and I don't expect more > > tags in core): fontification-functions, pre-command-hook and > > post-command-hook. > > These names seem wrong: I don't think the tag should say when/where the > lock happened to be placed, but what caused it to be placed. IIUC all > three cases up there share the same reason: overly long lines. > So I think they should all use the same tag which could be something > like `long-lines` or maybe they should use names such as > `long-line-threshold` and `large-hscroll-threshold` to record precisely > the cause for the lock. > > >> Looking more at the code, I have another question: why is > >> `narrowing_locks` a global alist indexed by buffers, instead of being > >> a buffer-local variable? > > > > For efficiency reasons. If it were a buffer-local variable, > > reset_outermost_narrowings, which is called by redisplay_internal, would > > have to consider all buffers, which would become unnecessarily slow with > > many (say 1000) buffers. With a global alist, only the (few) buffers in > > which narrowing locks are actually in effect are considered. > > Then I suggest you put a comment to that effect in the code. I also > can't understand why we need `xdisp.c` to call > `reset_outermost_narrowings`. I see you tried to explain it in the > doc-comment of the function but I failed to understand the explanation. > Maybe you could extend the comment by pointing to a very concrete > example (or maybe a discussion on the mailing list)? > > Another problem I see with it is that it seems to presume a very > particular use of locked narrowing (such as the one installed by the > long-lines code), whereas other uses of locked narrowing might not want > to be reset during redisplay. > > Similarly the doc-comment of `narrowing_lock_get_bound` talks about > "bounds ... that are visible on display", but that function doesn't know > what bounds are visible on display, actually. The interaction with > what's visible on display completely depends on when/where it's called > and when/where locks are installed. Could you try and clarify the > doc-comment to say what the function actually does, and then separately > explain how it *may* relate with "what's visible on display" and under > which assumption this relation may hold? > IIUC what the function does when OUTERMOST is true is return the > narrowing that was in effect when the first lock was installed, right? Gregory, any progress with documenting this?