all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Interactively edit a list of strings
@ 2018-07-22 23:55 Joe Riel
  2018-07-23  2:39 ` Eric Abrahamsen
  0 siblings, 1 reply; 8+ messages in thread
From: Joe Riel @ 2018-07-22 23:55 UTC (permalink / raw)
  To: Help GNU Emacs

Am looking for a good way to interactively edit a list of strings,
that is, to allow the user to selectively delete strings from the list.
Any suggestions on how to implement this?  

My first thought is to write each string on a separate line in a
temporary buffer, allow the user to edit that, then reassemble the
buffer into a list, however, that isn't ideal, it allows too much
freedom to modify the content.  I could restrict the allowable
commands to deleting lines, but am wondering if there is a better way.

-- 
Joe Riel




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Interactively edit a list of strings
       [not found] <mailman.4060.1532303750.1292.help-gnu-emacs@gnu.org>
@ 2018-07-23  1:05 ` Ben Bacarisse
  2018-07-23  4:22   ` Marcin Borkowski
  2018-07-24  8:51   ` Stephen Berman
  0 siblings, 2 replies; 8+ messages in thread
From: Ben Bacarisse @ 2018-07-23  1:05 UTC (permalink / raw)
  To: help-gnu-emacs

Joe Riel <joer@san.rr.com> writes:

> Am looking for a good way to interactively edit a list of strings,
> that is, to allow the user to selectively delete strings from the list.
> Any suggestions on how to implement this?  
>
> My first thought is to write each string on a separate line in a
> temporary buffer, allow the user to edit that, then reassemble the
> buffer into a list, however, that isn't ideal, it allows too much
> freedom to modify the content.  I could restrict the allowable
> commands to deleting lines, but am wondering if there is a better way.

You might consider using widgets:

https://www.gnu.org/software/emacs/manual/html_mono/widget.html

You could write the strings as an "editable-list" widget without the
[INS] buttons so only a [DEL] button available.

-- 
Ben.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Interactively edit a list of strings
  2018-07-22 23:55 Joe Riel
@ 2018-07-23  2:39 ` Eric Abrahamsen
  2018-07-23  4:21   ` Marcin Borkowski
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Abrahamsen @ 2018-07-23  2:39 UTC (permalink / raw)
  To: help-gnu-emacs

Joe Riel <joer@san.rr.com> writes:

> Am looking for a good way to interactively edit a list of strings,
> that is, to allow the user to selectively delete strings from the list.
> Any suggestions on how to implement this?  

You could try using `tabulated-list-mode', display your list of strings.
Then you could write a short command to remove a string from the list
and redisplay, and bind that in the local keymap. It's tiny bit
overkill, but would make it possible to do a bunch of other stuff with
the strings.




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Interactively edit a list of strings
  2018-07-23  2:39 ` Eric Abrahamsen
@ 2018-07-23  4:21   ` Marcin Borkowski
  2018-07-23  5:39     ` Joe Riel
  0 siblings, 1 reply; 8+ messages in thread
From: Marcin Borkowski @ 2018-07-23  4:21 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: help-gnu-emacs


On 2018-07-23, at 04:39, Eric Abrahamsen <eric@ericabrahamsen.net> wrote:

> Joe Riel <joer@san.rr.com> writes:
>
>> Am looking for a good way to interactively edit a list of strings,
>> that is, to allow the user to selectively delete strings from the list.
>> Any suggestions on how to implement this?
>
> You could try using `tabulated-list-mode', display your list of strings.
> Then you could write a short command to remove a string from the list
> and redisplay, and bind that in the local keymap. It's tiny bit
> overkill, but would make it possible to do a bunch of other stuff with
> the strings.

I would derive from special-mode.  You get read-only, scrolling and
a few other things for free, and you only have to (re)implement C-k to
delete lines (and creating the buffer/deriving the list from it again,
of course).  And much simpler than tabulated-list-mode.

OTOH, TLM is not /that/ complicated, as I wrote here:
http://mbork.pl/2015-07-18_TLM_vs_EWOC%2C_or_there_and_back_again
a few years ago.

Out of curiosity: what is the use-case?

Hth,

--
Marcin Borkowski
http://mbork.pl



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Interactively edit a list of strings
  2018-07-23  1:05 ` Interactively edit a list of strings Ben Bacarisse
@ 2018-07-23  4:22   ` Marcin Borkowski
  2018-07-24  8:51   ` Stephen Berman
  1 sibling, 0 replies; 8+ messages in thread
From: Marcin Borkowski @ 2018-07-23  4:22 UTC (permalink / raw)
  To: Ben Bacarisse; +Cc: help-gnu-emacs


On 2018-07-23, at 03:05, Ben Bacarisse <ben.lists@bsb.me.uk> wrote:

> Joe Riel <joer@san.rr.com> writes:
>
>> Am looking for a good way to interactively edit a list of strings,
>> that is, to allow the user to selectively delete strings from the list.
>> Any suggestions on how to implement this?
>>
>> My first thought is to write each string on a separate line in a
>> temporary buffer, allow the user to edit that, then reassemble the
>> buffer into a list, however, that isn't ideal, it allows too much
>> freedom to modify the content.  I could restrict the allowable
>> commands to deleting lines, but am wondering if there is a better way.
>
> You might consider using widgets:
>
> https://www.gnu.org/software/emacs/manual/html_mono/widget.html
>
> You could write the strings as an "editable-list" widget without the
> [INS] buttons so only a [DEL] button available.

Nice idea, though a bit of work.  But widget.el is very powerful!  (I
wrote about it also in 2015:
http://mbork.pl/2015-11-21_The_Emacs_widget_library_and_automatic_modification_of_editing_fields)

Best,

--
Marcin Borkowski
http://mbork.pl



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Interactively edit a list of strings
  2018-07-23  4:21   ` Marcin Borkowski
@ 2018-07-23  5:39     ` Joe Riel
  2018-07-23 11:33       ` Yuri Khan
  0 siblings, 1 reply; 8+ messages in thread
From: Joe Riel @ 2018-07-23  5:39 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: Eric Abrahamsen, help-gnu-emacs

On Mon, 23 Jul 2018 06:21:05 +0200
Marcin Borkowski <mbork@mbork.pl> wrote:

> On 2018-07-23, at 04:39, Eric Abrahamsen <eric@ericabrahamsen.net> wrote:
> 
> > Joe Riel <joer@san.rr.com> writes:
> >  
> >> Am looking for a good way to interactively edit a list of strings,
> >> that is, to allow the user to selectively delete strings from the list.
> >> Any suggestions on how to implement this?  
> >
> > You could try using `tabulated-list-mode', display your list of strings.
> > Then you could write a short command to remove a string from the list
> > and redisplay, and bind that in the local keymap. It's tiny bit
> > overkill, but would make it possible to do a bunch of other stuff with
> > the strings.  
> 
> I would derive from special-mode.  You get read-only, scrolling and
> a few other things for free, and you only have to (re)implement C-k to
> delete lines (and creating the buffer/deriving the list from it again,
> of course).  And much simpler than tabulated-list-mode.

Will take a look, thanks.

> OTOH, TLM is not /that/ complicated, as I wrote here:
> http://mbork.pl/2015-07-18_TLM_vs_EWOC%2C_or_there_and_back_again
> a few years ago.
> 
> Out of curiosity: what is the use-case?

It's part of a syntax checker/corrector for the Maple language.  A
tool (mint, analogous to lint) generates a buffer of the variables
that are undeclared in the source.  I grab the list and allow the user
to either quote them in the source or declare them as locals or
globals.  Being able to delete selected items from the list allows
performing a common operation on the remaining.  The typical case is
that almost all the variables should be quoted, but a few should be
declared as locals.


-- 
Joe Riel




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Interactively edit a list of strings
  2018-07-23  5:39     ` Joe Riel
@ 2018-07-23 11:33       ` Yuri Khan
  0 siblings, 0 replies; 8+ messages in thread
From: Yuri Khan @ 2018-07-23 11:33 UTC (permalink / raw)
  To: joer; +Cc: Eric Abrahamsen, help-gnu-emacs

On Mon, Jul 23, 2018 at 12:40 PM Joe Riel <joer@san.rr.com> wrote:
>
> It's part of a syntax checker/corrector for the Maple language.  A
> tool (mint, analogous to lint) generates a buffer of the variables
> that are undeclared in the source.  I grab the list and allow the user
> to either quote them in the source or declare them as locals or
> globals.  Being able to delete selected items from the list allows
> performing a common operation on the remaining.  The typical case is
> that almost all the variables should be quoted, but a few should be
> declared as locals.

For that case, there is a better UI idiom. You could let the user mark
multiple items with ‘m’, unmark with ‘u’, and perform common
operations on the marked items. For instances of this workflow, see
Dired, Ibuffer, and bookmark-bmenu-list.

The easiest implementation is probably still tabulated-list-mode and
you’ll have to implement marking, unmarking and
act-on-marked-items-or-item-at-point.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Interactively edit a list of strings
  2018-07-23  1:05 ` Interactively edit a list of strings Ben Bacarisse
  2018-07-23  4:22   ` Marcin Borkowski
@ 2018-07-24  8:51   ` Stephen Berman
  1 sibling, 0 replies; 8+ messages in thread
From: Stephen Berman @ 2018-07-24  8:51 UTC (permalink / raw)
  To: help-gnu-emacs

On Mon, 23 Jul 2018 02:05:57 +0100 Ben Bacarisse <ben.lists@bsb.me.uk> wrote:

> Joe Riel <joer@san.rr.com> writes:
>
>> Am looking for a good way to interactively edit a list of strings,
>> that is, to allow the user to selectively delete strings from the list.
>> Any suggestions on how to implement this?  
>>
>> My first thought is to write each string on a separate line in a
>> temporary buffer, allow the user to edit that, then reassemble the
>> buffer into a list, however, that isn't ideal, it allows too much
>> freedom to modify the content.  I could restrict the allowable
>> commands to deleting lines, but am wondering if there is a better way.
>
> You might consider using widgets:

That's what recentf-mode does to delete items from recentf-list, see the
function recentf-edit-list.

Steve Berman



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-07-24  8:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.4060.1532303750.1292.help-gnu-emacs@gnu.org>
2018-07-23  1:05 ` Interactively edit a list of strings Ben Bacarisse
2018-07-23  4:22   ` Marcin Borkowski
2018-07-24  8:51   ` Stephen Berman
2018-07-22 23:55 Joe Riel
2018-07-23  2:39 ` Eric Abrahamsen
2018-07-23  4:21   ` Marcin Borkowski
2018-07-23  5:39     ` Joe Riel
2018-07-23 11:33       ` Yuri Khan

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.