unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Alan Mackenzie <acm@muc.de>
Cc: emacs-devel@gnu.org, Gregory Heytings <gregory@heytings.org>
Subject: Re: Major modes using `widen' is a good, even essential, programming practice.
Date: Tue, 23 Aug 2022 02:59:35 +0300	[thread overview]
Message-ID: <c8420b67-693c-4421-18c1-fd04a053c06e@yandex.ru> (raw)
In-Reply-To: <YwNoA1cvCNs03Jlw@ACM>

Hi Alan,

On 22.08.2022 14:26, Alan Mackenzie wrote:
> A bit late, but ....

Not at all.

> On Sun, Aug 07, 2022 at 20:57:59 +0300, Dmitry Gutov wrote:
>> On 06.08.2022 23:13, Alan Mackenzie wrote:
>>> 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.
> 
>> Now wouldn't it have been nice if user-level narrowing didn't create an
>> *actual* narrowing but only some visual perception of it? IIRC there is
>> a third-party package which implements this approach.
> 
> I'm not convinced, given how well narrowing currently works.  I don't
> think it's useful to debate how things _would_ have been, when they are
> currently very different.

I admit the migration path looks murky.

>>   From what I've seen of feature requests related to narrowing in my
>> packages, it's always along the lines of "please add (save-restriction
>> (widen) ...) around the whole implementation".
> 
>> Are there actually user-level commands which should not ignore
>> narrowing?
> 
> Yes, lots and lots of them.  goto-char, isearch, occur, and many others.
> It might be easier to answer the question which user-level commands are
> not restricted by narrowing.

You might want to take a look at the patch I posted in 
https://lists.gnu.org/archive/html/emacs-devel/2022-08/msg00644.html

It handles a bunch of commands OOTB (namely, simple navigation and 
editing), and Isearch support took about 2 lines of code.

Occur should require attention, one way or the other (it's not obvious 
to me that Occur should limit itself to accessible region, but if not, 
navigation to inaccessible parts should undo soft-narrowing), but the 
implementation should likewise be trivial.

The work in choosing the desired behavior for various commands should 
take the most part of the effort.

>> If not, it would be better if user-level narrowing was implemented as
>> something else (e.g. two invisible overlays). Then all other code
>> wouldn't have to bother with undoing it.
> 
> But "all" other code would instead have to take account of the invisible
> overlays instead.  I don't think this would be better.  It would involve
> a _lot_ of work to implement and we'd be left with some other
> inconveniences instead of the currently perceived ones.

Some of the code would be handled automagically. A lot of the code 
doesn't want to obey user-level narrowing anyway. And the rest, yes, 
would need to be updated.



      reply	other threads:[~2022-08-22 23:59 UTC|newest]

Thread overview: 136+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-06 20:13 Major modes using `widen' is a good, even essential, programming practice Alan Mackenzie
2022-08-06 21:05 ` Stefan Monnier
2022-08-07  6:03 ` Eli Zaretskii
2022-08-07 13:31 ` Gregory Heytings
2022-08-07 14:13   ` Alan Mackenzie
2022-08-07 14:20     ` Eli Zaretskii
2022-08-07 14:59       ` Alan Mackenzie
2022-08-07 15:13         ` Eli Zaretskii
2022-08-07 17:01           ` Alan Mackenzie
2022-08-07 17:23             ` Eli Zaretskii
2022-08-07 17:53               ` Dmitry Gutov
2022-08-07 18:00                 ` Eli Zaretskii
2022-08-07 18:05                   ` Dmitry Gutov
2022-08-07 18:37                     ` Eli Zaretskii
2022-08-07 23:02                       ` Stefan Monnier
2022-08-07 18:49                   ` Óscar Fuentes
2022-08-07 18:59                     ` Eli Zaretskii
2022-08-07 18:56                   ` Lars Ingebrigtsen
2022-08-07 19:20               ` Alan Mackenzie
2022-08-07 19:26                 ` Dmitry Gutov
2022-08-08  2:36                 ` Eli Zaretskii
2022-08-08  9:58                   ` Alan Mackenzie
2022-08-08 11:39                     ` Eli Zaretskii
2022-08-08 15:05                       ` CC Mode with font-lock-maximum-decoration 2 [Was Major modes using `widen' is a good, even essential, programming practice.] Alan Mackenzie
2022-08-08 15:51                         ` Gregory Heytings
2022-08-08 16:05                           ` CC Mode with font-lock-maximum-decoration 2 Alan Mackenzie
2022-08-08 16:50                             ` Gregory Heytings
2022-08-09 19:49                               ` Gregory Heytings
2022-08-08 17:15                         ` CC Mode with font-lock-maximum-decoration 2 [Was Major modes using `widen' is a good, even essential, programming practice.] Eli Zaretskii
2022-08-08 17:41                           ` Eli Zaretskii
2022-08-08 18:41                             ` CC Mode with font-lock-maximum-decoration 2 Alan Mackenzie
2022-08-08 18:51                               ` Eli Zaretskii
2022-08-08 19:09                                 ` Alan Mackenzie
2022-08-09  2:24                                   ` Eli Zaretskii
2022-08-09  8:00                                     ` Alan Mackenzie
2022-08-09 11:07                                       ` Eli Zaretskii
2022-08-09 11:24                                         ` Alan Mackenzie
2022-08-09 11:57                                           ` Eli Zaretskii
2022-08-09 16:36                                             ` Alan Mackenzie
2022-08-09 16:59                                               ` Eli Zaretskii
2022-08-09 17:43                                                 ` Alan Mackenzie
2022-08-09 17:55                                                   ` Eli Zaretskii
2022-08-10  0:22                                                     ` Why tree-sitter instead of Semantic? (was Re: CC Mode with font-lock-maximum-decoration 2) Lynn Winebarger
2022-08-10  2:14                                                       ` Po Lu
2022-08-10  2:42                                                         ` Eli Zaretskii
2022-08-10 10:05                                                           ` Lynn Winebarger
2022-08-10 10:49                                                             ` Po Lu
2022-08-10 11:31                                                             ` Eli Zaretskii
2022-08-12 12:37                                                               ` Lynn Winebarger
2022-08-12 12:50                                                                 ` Eli Zaretskii
2022-08-12 21:50                                                                   ` Ideal performance of ELisp (was: Why tree-sitter instead of Semantic? (was Re: CC Mode with font-lock-maximum-decoration 2)) Stefan Monnier
2022-08-12 23:26                                                                     ` Lynn Winebarger
2022-08-13  2:11                                                                       ` Ideal performance of ELisp Stefan Monnier
2022-08-13 10:51                                                                         ` Lynn Winebarger
2022-08-13 11:13                                                                           ` Lynn Winebarger
2022-08-13 14:07                                                                           ` Stefan Monnier
2022-08-13 14:56                                                                             ` Lynn Winebarger
2022-08-16 16:46                                                                               ` Lynn Winebarger
2022-08-16 17:22                                                                                 ` Stefan Monnier
2022-08-17 12:41                                                                                   ` Lynn Winebarger
2022-08-17 14:04                                                                                     ` Stefan Monnier
2022-08-17 14:19                                                                                       ` Mattias Engdegård
2022-08-17 22:18                                                                                         ` Stefan Monnier
2022-08-17 14:25                                                                                       ` Lynn Winebarger
2022-08-13  4:39                                                                     ` Ideal performance of ELisp (was: Why tree-sitter instead of Semantic? (was Re: CC Mode with font-lock-maximum-decoration 2)) Ihor Radchenko
2022-08-13  7:45                                                                       ` Ideal performance of ELisp Philip Kaludercic
2022-08-13 11:58                                                                         ` Ihor Radchenko
2022-08-13 14:15                                                                       ` Stefan Monnier
2022-08-14  9:25                                                                         ` Andrea Corallo
2022-08-14  9:34                                                                           ` Ihor Radchenko
2022-08-14 13:01                                                                             ` Eli Zaretskii
2022-08-16 19:23                                                                             ` Andrea Corallo
2022-08-14 13:01                                                                           ` Stefan Monnier
2022-08-16  8:59                                                                             ` Andrea Corallo
2022-08-16  9:50                                                                               ` Ihor Radchenko
2022-08-16 18:21                                                                                 ` Andrea Corallo
2022-08-17  9:48                                                                                   ` Ihor Radchenko
2022-08-17 12:02                                                                                     ` Eli Zaretskii
2022-08-16 15:06                                                                               ` Lynn Winebarger
2022-08-16 18:24                                                                                 ` Andrea Corallo
2022-08-17 13:04                                                                                   ` Lynn Winebarger
2022-08-17 14:18                                                                                     ` Andrea Corallo
2022-08-18 12:17                                                                                       ` Lynn Winebarger
2022-08-12 16:00                                                                 ` Why tree-sitter instead of Semantic? (was Re: CC Mode with font-lock-maximum-decoration 2) Akib Azmain Turja
2022-08-12 19:06                                                                   ` tomas
2022-08-13  4:41                                                                     ` Akib Azmain Turja
2022-08-13  5:14                                                                       ` tomas
2022-08-13 11:57                                                                   ` Lynn Winebarger
2022-08-13 14:28                                                                     ` Akib Azmain Turja
2022-08-14 19:24                                                         ` Eric Ludlam
2022-08-16 10:42                                                           ` Lynn Winebarger
2022-08-17  1:56                                                             ` Eric Ludlam
2022-08-10 17:03                                                       ` Tassilo Horn
2022-08-13 14:40                                                       ` Jostein Kjønigsen
2022-08-14  1:23                                                         ` Po Lu
2022-08-16  9:06                                                           ` Lynn Winebarger
2022-08-16 11:05                                                             ` Po Lu
2022-08-16 11:41                                                             ` Eli Zaretskii
2022-08-16 16:33                                                               ` Lynn Winebarger
2022-08-16 17:19                                                                 ` Stefan Monnier
2022-08-16 17:40                                                                   ` Lynn Winebarger
2022-08-17  1:41                                                                     ` Eric Ludlam
2022-08-18 12:34                                                                       ` Lynn Winebarger
2022-08-20 13:15                                                                         ` Eric Ludlam
2022-08-08 18:20                           ` CC Mode with font-lock-maximum-decoration 2 Alan Mackenzie
2022-08-07 20:17     ` Major modes using `widen' is a good, even essential, programming practice Gregory Heytings
2022-08-07 20:46       ` Alan Mackenzie
2022-08-07 20:53         ` Gregory Heytings
2022-08-08  2:37         ` Eli Zaretskii
2022-08-08 10:33           ` Alan Mackenzie
2022-08-08 11:41             ` Eli Zaretskii
2022-08-07 23:21     ` Stefan Monnier
2022-08-08  2:29       ` Eli Zaretskii
2022-08-08  9:25         ` Stefan Monnier
2022-08-08 11:16           ` Lynn Winebarger
2022-08-08 11:47             ` Eli Zaretskii
2022-08-08 14:24               ` Lynn Winebarger
2022-08-08 11:30           ` Eli Zaretskii
2022-08-08 12:05             ` Stefan Monnier
2022-08-08 12:40               ` Eli Zaretskii
2022-08-08 17:22                 ` Stefan Monnier
2022-08-08 17:34                   ` Eli Zaretskii
2022-08-08 21:16             ` Dmitry Gutov
2022-08-09 11:30               ` Eli Zaretskii
2022-08-09 14:38                 ` Dmitry Gutov
2022-08-09 16:12                   ` Eli Zaretskii
2022-08-09 16:52                     ` Dmitry Gutov
2022-08-09 17:05                       ` Eli Zaretskii
2022-08-09 18:52                         ` Dmitry Gutov
2022-08-09 19:46                           ` Gregory Heytings
2022-08-08 10:38       ` Alan Mackenzie
2022-08-08 11:49         ` Eli Zaretskii
2022-08-08 10:41       ` Gregory Heytings
2022-08-07 17:57 ` Dmitry Gutov
2022-08-22 11:26   ` Alan Mackenzie
2022-08-22 23:59     ` Dmitry Gutov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c8420b67-693c-4421-18c1-fd04a053c06e@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    --cc=gregory@heytings.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).