emacs-devel
[Top][All Lists]
Advanced

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

Re: Major modes using `widen' is a good, even essential, programming pra


From: Eli Zaretskii
Subject: Re: Major modes using `widen' is a good, even essential, programming practice.
Date: Mon, 08 Aug 2022 14:47:41 +0300

> From: Lynn Winebarger <owinebar@gmail.com>
> Date: Mon, 8 Aug 2022 07:16:44 -0400
> Cc: Eli Zaretskii <eliz@gnu.org>, Alan Mackenzie <acm@muc.de>, 
> gregory@heytings.org, 
>       emacs-devel <emacs-devel@gnu.org>
> 
> I know CC mode relies on heuristics to identify syntactic structures, and not 
> a full parser (whether from
> semantic or LSP), but it seems the issue is that you don't have a parse state 
> for the beginning of the
> narrowed buffer, where an initial parse state is inappropriate.  Assuming 
> that text outside the narrowing is
> not allowed to change, determining the appropriate parse state should only be 
> required once on narrowing.
> So, could there be a pre-narrowing hook to run before narrowing takes effect 
> to allow a major mode to
> determine the appropriate parse state for the beginning of the narrowed 
> buffer?

Why do you need a hook?  When the mode is first enabled in the buffer,
there will be no narrowing in effect yet, so the mode could do
whatever it wants at that time.

Of course, this won't help us to solve the issues discussed here,
because scanning the entire buffer at any time is slow and
non-scalable.

> Also, as I'm not a big user of explicit narrowing, the only place I've 
> noticed it happening is in info mode, where
> the focus is narrowed to a particular syntactic unit.
> Is there a way for a major mode to let the user signal the syntactic unit 
> that they believe they are narrowing
> to, either with command variants or an interrogative(with a list of options 
> supplied by the mode) when
> narrowing is performed by the user interactively?  With the fall-back of 
> either having the mode determine the
> correct initial state or turning off fontification during the narrowing?

We are not talking about user narrowing here.



reply via email to

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