help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: How to use `narrow'?


From: Stefan Monnier
Subject: Re: How to use `narrow'?
Date: Fri, 21 Oct 2005 00:29:03 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

>> > No, it does not help.  font-lock widens unconditionally.
>> >
>> >> ,----[ C-h v font-lock-dont-widen RET ]
>> >
>> > I would prefer a solution which works in real world, not in some
>> > imaginary settings...  However, it is nice that somebody realized that
>> > widening is a problem.

Thanks Ilya for the compliment ;-)

>> > When will we see it, in 22.1?
>> I'm sorry, i forgot to mention that I'm running emacs from CVS.
> Well, I guessed this.  But anyway, just font-lock-dont-widen is not
> enough to have robust support for narrowing.  Obviously, there are
> cases when this widen() *is* useful.  And there are cases when it is
> harmful.

> The only way I see which may be usable is a way to mark a *particular*
> narrowing operation as requiring (or not) widen() during
> fontification.  E.g., one could put some text property on the narrowed
> region (as far as widen() is smart enough to remove this text property
> afterwards...).

Indeed, you're right.

> Is there anything like this in CVS?

No.  Narrowing is fairly badly defined in Emacs.  Sometimes it's used to
pretend the rest of the buffer doesn't exist at all, and other times it's
only meant to hide the rest of the buffer from some operations (e.g. from
display) without pretending the rest doesn't exist.

So, e.g. font-lock doesn't know whether to widen or not.  Same thing for
indentation, etc... it's pretty messy.  I personally try to stay away from
narrow except as an elisp tool for things like emulating the presence of
a `limit' argument to `looking-at'.

As for your original problem.  There are several packages that try to
provide support for multi-mode operation.  The approach they take to do that
vary, but I think they all end up using changing
font-lock-fontify-region-function so they can better control what is
highlighted how.  Maybe you could simply add support for mmm-mode or
multi-mode.el or somesuch and forget about narrowing ;-)


        Stefan



reply via email to

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