From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#56682: feature/improved-locked-narrowing 9dee6df39c: Reworked locked narrowing. Date: Fri, 30 Dec 2022 12:01:48 -0500 Message-ID: References: <166939872890.18950.12581667269687468681@vcs2.savannah.gnu.org> <20221125175209.51166C004B6@vcs2.savannah.gnu.org> <6c9d91cffc1bfd801530@heytings.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34846"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 56682@debbugs.gnu.org To: Gregory Heytings Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Dec 30 18:03:10 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 1pBImj-0008pg-HX for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 30 Dec 2022 18:03:09 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pBIlm-00030u-M6; Fri, 30 Dec 2022 12:02:10 -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 1pBIlf-0002vx-DR for bug-gnu-emacs@gnu.org; Fri, 30 Dec 2022 12:02: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 1pBIle-0002j2-DQ for bug-gnu-emacs@gnu.org; Fri, 30 Dec 2022 12:02:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pBIld-0004mK-Uf for bug-gnu-emacs@gnu.org; Fri, 30 Dec 2022 12:02:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 30 Dec 2022 17:02:01 +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.167241972118361 (code B ref 56682); Fri, 30 Dec 2022 17:02:01 +0000 Original-Received: (at 56682) by debbugs.gnu.org; 30 Dec 2022 17:02:01 +0000 Original-Received: from localhost ([127.0.0.1]:36039 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pBIlc-0004m3-U9 for submit@debbugs.gnu.org; Fri, 30 Dec 2022 12:02:01 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:31669) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pBIla-0004lk-SH for 56682@debbugs.gnu.org; Fri, 30 Dec 2022 12:01:59 -0500 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 0D990101403; Fri, 30 Dec 2022 12:01:53 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 5ECAC100FF3; Fri, 30 Dec 2022 12:01:51 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1672419711; bh=SJ8U4ifPxvfd3k9M110myWzM+ZPivCZYSrqrOvnSYok=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=XhQ/+nZKdj2KkMSTlIN752pyIay75gJH6ReJ8dsj2n2p7d41x3Lqzv3WgIEVLApQS DDoPmjZhlsSgMeq8jPsBH1C1YvdcAs/sOWPbT55DCebTsOfH9jkBSkT4EOT9tsX61L v4y8UwmrAspfD2xQMnyEsoW7+MWT0Qg5Tf0x5Hh3WmXhiMTQ0e5aKXTbSoWfvY2fJ3 txlHmG+CJ9cNT87I5gjO4cr9ZZyjr+8abnODvDwAnGMWIfTYy9GWXocD5Ipn0b3MR9 2wjBvDQ2WIlaASF5nbxf5YsnDOExMvpv1bb6j2pgI1+nCPB3yidB/hQEUmq0a2rr6h 3mV5te3PGV9bQ== Original-Received: from alfajor (unknown [45.44.229.252]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 0E95C12086D; Fri, 30 Dec 2022 12:01:51 -0500 (EST) In-Reply-To: <6c9d91cffc1bfd801530@heytings.org> (Gregory Heytings's message of "Fri, 30 Dec 2022 16:38:34 +0000") 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:252142 Archived-At: >> - I don't see any mention of those new features in etc/NEWS. > Yes, that's something I still need to do. I think it's quite urgent (it's all too easy to forget: better a subpar entry than no entry at all). >> - In `nlinum--line-number-at-pos`, I want to circumvent the narrowing lock >> due to long lines (since its performance is only affected by buffer size >> but not by line length), but I can't see how to do that. The only >> primitive I see which would let me get out of the locked narrowing is >> `narrowing-unlock` but: >> >> - I don't know which tag(s) to use. > > That depends on the place where 'nlinum--line-number-at-pos' is called, or > IOW where/by which function the narrowing was locked, or IOW again which tag > was used to unlock the narrowing. Hmm... I understand that part but that doesn't tell me how I (the coder) or the function can find out which tag to use :-( >> - I don't want to remove the lock, I only want to circumvent it >> temporarily, and I can't see how to re-install a lock after removing it >> (`narrowing-lock` doesn't fit the bill because I don't know the bounds of >> the lock and because that would not preserve the stacking order of locks). > > That's part of the improvements you suggested, and I implemented. > Simply do a: > > (save-restriction > (narrowing-unlock 'the-appropriate-tag) > (widen) > ... your code ...) > > Upon return from the save-restriction, the narrowing locks are restored. Ah, great, I had missed that, thanks. So the remaining issue is to find the (set of) tags to unlock. 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? Stefan