emacs-devel
[Top][All Lists]
Advanced

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

Major modes using `widen' is a good, even essential, programming practic


From: Alan Mackenzie
Subject: Major modes using `widen' is a good, even essential, programming practice.
Date: Sat, 6 Aug 2022 20:13:13 +0000

Hello, Emacs, hello, Gregory.

In the thread for bug #56682 "Fix the long lines font locking related
slowdowns" on Wednesday 2022-08-03 09:04:03 +0000, you (Gregory) posted
this:

> .... based on the observation that half of the programming language
> modes in core do use widen, which they weren't supposed to do.

You are entirely wrong there, and I suspect you personally don't use
narrowing (as a user), so don't really understand it.

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.

Also, in font locking, a major mode might need to examine text
arbitrarily far from the fontification region.  For example, to know
whether or not a particular place is inside a comment or a string, or to
know whether to fontify a string opener with f-l-warning-face (when the
string is unterminated) or f-l-string-face (for a validly terminated
string).

There's no "weren't supposed to do" involved anywhere.  Major modes,
like all Emacs Lisp programs, have, by design, access to the full range
of Emacs's facilities.  Should it make your task more difficult (and I
don't see that it does), that's your problem, not the major modes'
maintainers'.

I've recently spent many hours reading the discussion for bug #56682 and
its predecessor bug, and if I recall correctly, you have put the
`widen'/ `narrow-to-region' "bug" into other hooks called from
redisplay.  If I'm right, there, was there any specific reason for this?
Like, did it dramatically speed anything up (and I'm not talking about a
mere 10%, say, here)?  Otherwise, this will just make programs fail for
no good reason.  If I'm right about this, could you please restore those
hooks to full functionality by removing the "bug" from them.

Several times in the thread when other posters have complained about the
new long lines facility, you have invited them to "set
long-line-threshold to nil".  That doesn't allow them to use the other
benefits of the facility whilst retaining fully functional `widen',
'narrow-to-region' and font-locking.  Would it be possible, please, to
add an option to enable such a mix of features?  Thanks!

-- 
Alan Mackenzie (Nuremberg, Germany).



reply via email to

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