Skip to content

The menu-choice Widget

Syntax:

bash
type ::= (menu-choice [keyword argument]... type ... )

A widget to represent a menu of options. Its super is the default widget.

The type argument represents each possible choice. The widget’s value will be that of the chosen type argument.

It either overrides or adds the following properties:

:convert-widget

A function that takes care of converting each possible choice.

:copy

A function to copy each possible choice.

:format

By default, buttonize the tag and show the value.

:void

Widget type used as a fallback when the value does not match any of the specified type arguments.

By default this is an item widget.

:case-fold

If nil don’t ignore case when prompting for a choice through the minibuffer.

By default, its value is t.

:children

A list whose CAR is the widget representing the currently chosen type in the buffer.

:choice

The current chosen type.

:args

The list of types.

:value-create

The function that inserts the current value for the widget.

It inserts the first choice that matches, as with the :match function, the value of the widget.

:value-get

Returns the value of the first child for the widget (see the description for :children above).

:value-inline

Returns the inline value of the first child for the widget.

:default-get

The default value for this widget is the default value for the first choice, in case :value is missing.

This means that if you want a specific default value for the menu-choice widget, you should either pass a :value property when creating it, or arrange the choices so that the first one can hold your desired default value.

:mouse-down-action

A function that takes care of showing a menu, if possible and desired.

:action

A function that takes care of getting a new choice for the widget.

Depending on the number of choices available, it may show a menu or just toggle the choices, or even do nothing at all.

After getting the choice, it recreates the widget and notifies it.

:validate

Returns nil if the widget’s value is a valid choice.

:match

This widget will match any value matching at least one of the specified type arguments.

:match-inline

A function that returns non-nil if the values match the widget, taking into account the :inline property.