From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: Major modes using `widen' is a good, even essential, programming practice. Date: Mon, 22 Aug 2022 11:26:59 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15537"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org, Gregory Heytings To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Aug 22 13:29:23 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 1oQ5cQ-0003xB-RS for ged-emacs-devel@m.gmane-mx.org; Mon, 22 Aug 2022 13:29:22 +0200 Original-Received: from localhost ([::1]:56260 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQ5cP-0003Bh-VP for ged-emacs-devel@m.gmane-mx.org; Mon, 22 Aug 2022 07:29:21 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48284) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQ5aT-0001pn-L4 for emacs-devel@gnu.org; Mon, 22 Aug 2022 07:27:24 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:34136 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.90_1) (envelope-from ) id 1oQ5aR-0006II-Lm for emacs-devel@gnu.org; Mon, 22 Aug 2022 07:27:21 -0400 Original-Received: (qmail 32917 invoked by uid 3782); 22 Aug 2022 11:27:00 -0000 Original-Received: from acm.muc.de (p4fe15977.dip0.t-ipconnect.de [79.225.89.119]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Mon, 22 Aug 2022 13:27:00 +0200 Original-Received: (qmail 7075 invoked by uid 1000); 22 Aug 2022 11:26:59 -0000 Content-Disposition: inline In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de Received-SPF: pass client-ip=193.149.48.1; envelope-from=acm@muc.de; helo=mail.muc.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=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:293791 Archived-At: Hello, Dmitry. A bit late, but .... On Sun, Aug 07, 2022 at 20:57:59 +0300, Dmitry Gutov wrote: > On 06.08.2022 23:13, Alan Mackenzie wrote: > > Narrowing is primarily a user feature. Users can arbitrarily narrow a > > buffer to ANY contiguous region of text. So when a major mode needs to > > examine text even slightly distant from point, it MUST widen, to be sure > > that the text to be examined is within the visible region. > Now wouldn't it have been nice if user-level narrowing didn't create an > *actual* narrowing but only some visual perception of it? IIRC there is > a third-party package which implements this approach. I'm not convinced, given how well narrowing currently works. I don't think it's useful to debate how things _would_ have been, when they are currently very different. > From what I've seen of feature requests related to narrowing in my > packages, it's always along the lines of "please add (save-restriction > (widen) ...) around the whole implementation". > Are there actually user-level commands which should not ignore > narrowing? Yes, lots and lots of them. goto-char, isearch, occur, and many others. It might be easier to answer the question which user-level commands are not restricted by narrowing. > If not, it would be better if user-level narrowing was implemented as > something else (e.g. two invisible overlays). Then all other code > wouldn't have to bother with undoing it. But "all" other code would instead have to take account of the invisible overlays instead. I don't think this would be better. It would involve a _lot_ of work to implement and we'd be left with some other inconveniences instead of the currently perceived ones. -- Alan Mackenzie (Nuremberg, Germany).