Subject: RE: bug#44078: 26.3; `tabulated-list-mode': Use it in any mode and for part of a buffer

From: Drew Adams <[email-masked]>
Date: Tue, 20 Oct 2020 09:20:30 -0700 (PDT)

> > But for `tabulated-list-mode' I think we need more than just to add a
> > minor-mode version.  We really need a way to confine its effect to a
> > part of a buffer.
> 
> Whenever I've done some work on tabulated-list-mode, I've been kinda
> frustrated by its design.  You'd ideally just be able to have a
> functional interface where you just call a function with all the data
> (and some commands to apply to the data), and then everything would
> work.  But instead it's a strange mixture of functional, buffer-local
> data and updating functions.
> 
> A side effect of this is that the table isn't an "object" you can do
> operations on -- there can only be one table per buffer, and it wants to
> control the entire buffer.
> 
> So I'd welcome a more functional rewrite of tabulated-list-mode that
> would constrain all actions to the area of the buffer where the table
> is, and leave the rest of the buffer alone.  And stash the table data in
> the table instead of using the buffer-local variables.

I agree with all that you say.  And this is a great
summary of my feelings about the failings of t-m-mode:

  there can only be one table per buffer,
  and it wants to control the entire buffer

I don't expect this enhancement request to get traction
anytime soon.  And in fact I think that ultimately this
is related to the real need for some kind of reasonable,
robust, multiple-major-modes feature.

That might not be the best name, and there are multiple
ways to envision such things.  But wrt this request,
I'm thinking of an ability to, in the same buffer, have
tables that are governed by something like t-m-mode, but
without impacting the buffer mode in general or at least
other parts of the buffer.

The key-bindings part could likely be dealt with using
a `keymap' text property.  But t-m-mode is a major mode
so far, and there are its local variables to be dealt
with (and a mode hook, and maybe other buffer-related 
stuff).

Variables with values specific to a given span of text,
i.e., realized via text properties, might be a way to
deal with some of this.  Dunno, and dunno how that
might be realized.

Just thinking out loud.  I'm sure that others, who've
spent a lot of time trying to think about multiple
major modes, have a much better view of the obstacles
and possibilities in this regard.

It just seems to me that making t-m-mode a major mode
is a mistake.  You can't even add any additional text
to the buffer, outside the table - not even a heading.
It just kind of takes over a buffer, and that's quite
limiting.