[Top][All Lists]

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

Re: Extend tabulated-list-mode to support marks

From: Dirk-Jan C. Binnema
Subject: Re: Extend tabulated-list-mode to support marks
Date: Sat, 25 Jul 2020 16:46:32 +0300
User-agent: mu4e 1.5.5; emacs 28.0.50

On Friday Jul 24 2020, Yuri Khan wrote:

> On Fri, 24 Jul 2020 at 22:05, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>> > and (2) if maybe tabulated-list-mode would benefit from a generic
>> > implementation of multiple marking, unmarking, marking-for-deletion,
>> > and command application.
>> Maybe "for deletion" is too application-specific (some uses of
>> `tabulated-list-mode` can't "delete" or at least not conveniently enough
>> that it's a common use case), but a definite +1 for the rest.
> My point is that there are many instances of a generic scenario:
> Display a list of items; enable the user to perform operations on a
> single item at point or to mark multiple items and operate on them as
> a subset. Currently, each mode derived from ‘tabulated-list-mode’ has
> to reimplement marking, unmarking, mark preservation over refresh,
> iterating over marked items, and fallback to the item at point when no
> marks are set. One high-visible derived mode hijacks the “unmark all”
> key for “mark upgradable packages”. I think they would benefit from a
> common implementation and the unification of the UI stemming from
> that.
> One possibility would be for a derived mode to set some buffer-local
> variables to inform ‘tabulated-list-mode’ which marks it supports.
> E.g.:
> * Set ‘tabulated-list-delete-function’ to a non-nil function that will
> delete the item at point or signal an error. Then the command bound to
> ‘D’ will invoke that function and remove its visual representation
> from the buffer; ‘d’ will mark the item at point for deletion; ‘x’
> will go through all the items marked for deletion and actually delete
> and remove them; ‘u’ will unmark the item at point; and ‘U’ will
> unmark all items.
> * Set ‘tabulated-list-marks’ to a string of characters. If that string
> contains ‘>’, ‘m’ will mark the item at point with ‘>’. Other marks
> listed in the string can be set by the derived mode binding a key to a
> function that will call (tabulated-list-set-mark CHAR). ‘u’ and ‘U’
> will unmark the item at point or all items, respectively. A helper
> function, (tabulated-list-map CHAR FUNC), will execute FUNC on each
> item marked CHAR or on the item at point if no items are marked,
> optionally removing the item or unmarking it depending on FUNC’s
> return value; this can be invoked in any commands bound in the derived
> mode keymap.
> I might implement something if this general direction is deemed
> desirable. Details can be discussed.

Something like that would be most welcome; I'm using a custom
'dired-like' implementation for mu4e's header-view, and I need the
marking / unmarking, applying commands, adding/removing entries etc.; if
emacs were to gain some standard facility for that, that would really

Some bonus items would be to allow for a tree-view, with
expand/collapse, and multi-line items.

Kind regards,

Dirk-Jan C. Binnema                  Helsinki, Finland
e:djcb@djcbsoftware.nl           w:www.djcbsoftware.nl
gpg: 6987 9CED 1745 9375 0F14 DA98 11DD FEA9 DCC4 A036

reply via email to

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