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.bugs Subject: bug#56682: locked narrowing (was: bug#56682: Fix the long lines font locking related slowdowns) Date: Tue, 16 Aug 2022 19:39:21 +0000 Message-ID: <325f95fd2b8688c3aa74@heytings.org> References: <12348081660379417@sas2-a098efd00d24.qloud-c.yandex.net> <66bbbb95983414e79637@heytings.org> <83wnb9hadb.fsf@gnu.org> <395454dd-7238-c5d0-e924-2f65a186baa7@yandex.ru> <83r11hh4pm.fsf@gnu.org> <3a1232a17b09ce88af40@heytings.org> <83edxghqg2.fsf@gnu.org> <325f95fd2bcc0b666b0b@heytings.org> <83edxgfi75.fsf@gnu.org> <5e3c3081-f098-8140-c767-b895c32bf30b@yandex.ru> <835yisffil.fsf@gnu.org> <831qtgff78.fsf@gnu.org> <83zgg4dw4y.fsf@gnu.org> <83r11gdrr4.fsf@gnu.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="21001"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 56682@debbugs.gnu.org, Eli Zaretskii , dgutov@yandex.ru To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Aug 16 21:40:32 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 1oO2QS-0005FW-Cr for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 16 Aug 2022 21:40:32 +0200 Original-Received: from localhost ([::1]:44392 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oO2QQ-00016x-TM for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 16 Aug 2022 15:40:30 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58492) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oO2Py-00016l-Ol for bug-gnu-emacs@gnu.org; Tue, 16 Aug 2022 15:40:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58676) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oO2Py-0004hx-FX for bug-gnu-emacs@gnu.org; Tue, 16 Aug 2022 15:40:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oO2Py-0007gP-C2 for bug-gnu-emacs@gnu.org; Tue, 16 Aug 2022 15:40:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Gregory Heytings Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 16 Aug 2022 19:40: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.166067876529480 (code B ref 56682); Tue, 16 Aug 2022 19:40:02 +0000 Original-Received: (at 56682) by debbugs.gnu.org; 16 Aug 2022 19:39:25 +0000 Original-Received: from localhost ([127.0.0.1]:48425 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oO2PN-0007fO-B6 for submit@debbugs.gnu.org; Tue, 16 Aug 2022 15:39:25 -0400 Original-Received: from heytings.org ([95.142.160.155]:56382) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oO2PL-0007fF-PA for 56682@debbugs.gnu.org; Tue, 16 Aug 2022 15:39:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heytings.org; s=20220101; t=1660678762; bh=isXtToLmdxiag9NRvqvO2FkBwdjOxp1QHP07nYZjr9E=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:From; b=nGZ2Nuf2NzEfibyzU/+si2gQmhr2MfokhDHSvQv2rD4S31D1hvx5SMv9rym0N+iSc TsxDEyNU/plHbGKeuLC8yn/JS/9fQ7Us380FmbLZ7XY7KSTuvOENUbRWsM0CEZmn4b +7166DGm3vRX4s3bV1LF7ngQU+b8b/1e77nnBlK2FDVy5G64Xp+8JYomqdAEOOFo78 rktG5+pbC4sraG5uj+ETI9mmU6ORCCnwY8H6hvHL9xmMIsuw13cmdrcWXOsWDZa6V+ jmw9YRXrTT+OE+tj3CWqMTni0d6xza3rLW7qWuduLHgfknmFxSe6qpDdA93G+slIeN /QJbT2He6eIzg== In-Reply-To: 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:239999 Archived-At: > > [ Sorry, Gregory. But see below for more concrete/constructive > criticism. ] > There's no need to be sorry. This is WIP, any (constructive) criticism is welcome. And I do not understand why you did not raise some of the points below earlier. Perhaps I misuderstood or overlooked something in what you said earlier, but to me your objection to that part of the code until now was mainly/purely "philosophical". > > - Not only you can't `widen` but you can't narrow either > (`narrow-to-region` just does nothing when the restriction is locked, > regardless if the call tries to grow or shrink the restriction). AFAIK > this is a plain bug, but given the fundamental disagreement about what > is "right" in this discussion, I can't be sure. > This (allowing narrow-to-region and widen to work within the bounds of the locked narrowing) is currently being implemented, after an off-list discussion with Alan. > > - The locking is global: any `widen` or `narrow-to-region` will fail > when a locked narrowing is in effect, even when it's applied to an > unrelated buffer. Again, it looks like a plain bug, but... > It's not global, given that it is controlled by symbol that is bound within a function called inside a specific buffer. But indeed, if inside that function we use narrow-to-region/widen in another buffer, that would fail. It seems easy to correct that bug, though: if (current_buffer->long_line_optimizations_p && ! NILP (Vrestrictions_locked)) ... > > - The doc for `restrictions-locked` says: > > This happens when `narrow-to-region', which see, is called from Lisp > with an optional argument LOCK non-nil. > > but the `narrow-to-region` function doesn't have any such LOCK > argument. > That should have been removed, indeed. In a previous iteration of the code a LOCK argument was added to that function, and later removed. > > - The `narrow_to_region_internal` function, when called with `lock=true` > oddly includes the functionality of save-restriction to restore the > restriction and point but not to restore the `restrictions-locked` > state. > This I do not understand. The comment above that function explains that it should be followed by "specbind (Qrestrictions_locked, Qt)". There is no need to restore the restrictions-locked state, or am I misunderstanding something? > > - In that same function the two branches of the `if (lock)` have a lot > of obvious redundancy. > Not "a lot", but indeed there's some redundancy there that could have been avoided. I'll fix those problems soon.