[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: locked narrowing in ELisp

From: Stefan Monnier
Subject: Re: locked narrowing in ELisp
Date: Tue, 16 Aug 2022 20:55:31 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

> Have you given any thought to the "soft widen" alternative
> I voiced recently?
> https://lists.gnu.org/archive/html/emacs-devel/2022-08/msg00291.html
> If the user-level narrow/widen commands didn't use _actual_ narrowing, but
> display engine tricks or whatever (example:
> https://github.com/Malabarba/fancy-narrow/), "other parts of the major mode"
> wouldn't have to do the usual (save-restriction (widen) ...) dance, which
> a lot of code is littered with.
> Then there would be no need for "hard" or "locked" narrowing to restrict
> those calls to 'widen', because there wouldn't be any. The
> 'narrow-to-region' and 'widen' would be restricted to lower-level uses, like
> mmm-mode, Info-mode, and the display engine long-line wrangling magic.
> The migration path seems difficult, but the result might be worth it.

Such a display-only narrowing might be a good alternative for many uses
of narrowing, but narrowing is also used quite commonly (either by the
end-user or in ELisp code) in order to restrict the effect of an
operation (like search&replace) to a particular region.

> 'widen-function' can work too. IIRC various 'multi-mode' packages have tried
> to advice 'widen', without much of a reliable success.

`widen` is one of those functions that has its own bytecode (I'm far
from convinced that it's used frequently enough to justify it, but that's
another issue), so indeed advising it is unlikely to give good results.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]