[Top][All Lists]

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

Re: forward-comment and syntax-ppss

From: Clément Pit--Claudel
Subject: Re: forward-comment and syntax-ppss
Date: Fri, 9 Dec 2016 17:33:09 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1

On 2016-12-09 13:47, Stefan Monnier wrote:
>> There is nothing in the notion of narrowing which suggests that it
>> should change the syntactic context of any text - if a certain buffer
>> position is inside a string, it is inside the string; it doesn't
>> suddenly become outside the string by virtue of where the buffer is
>> narrowed.  Were that not the case, the notion "inside a string" would
>> become meaningless.

> Let's take sm-c-mode as an example: it marks CPP preprocessor elements
> as being comments.  Yet, it also wants to know if there are strings
> inside that "comment", so it narrows to the "comment" and then
> parses the result as a chunk of C code.
> Other examples come from the context of multiple-major-modes-in-a-buffer.

I'm not directly involved in this discussion, but thanks to both of you for 
these explanations.  I didn't clearly understand the distinction at hand up to 
this point.

Alan, is it valid to say that you view narrowing as a convenient editing 
feature that lets you restrict operations to a subsection of the buffer?  
Something like a "window" over the buffer (or maybe "stencil" would be a better 
term?), which doesn't change any of semantic meaning, but just conveniently 
restricts motion?
In that sense, your vision of narrowing is similar to my applying two overlays 
to make the beginning of the buffer invisible up to a point, and the end of the 
buffer invisible starting from a point, right?

Stefan, am I correct in thinking that the narrowing that you mention above is 
of a different nature, in the sense that if I narrow a buffer to the range a…b 
it's just as if I had copied that portion of the buffer to a totally separate, 
disconnected buffer (possibly running a different mode), and the text would get 
copied back into the original buffer when I widen?

Maybe the solution is to just give these two things a different name? It seems 
that in the first case we're narrowing to a region without forgetting about the 
context — let's call this "context-aware narrowing", or "focusing".  In the 
second case we're narrowing to a region and forgetting about the context 
entirely — let's call this "context-oblivious narrowing", or "sub-buffer 

Context-aware narrowing allows one to work on just one function easily; 
Context-oblivious narrowing makes things like 
http://demonastery.org/2013/04/emacs-narrow-to-region-indirect/ possible.


Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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