What problem does it solve?
The Emacs Widget Library enables creating rich, interactive UI elements directly in text buffers, simplifying configuration interfaces, dialogs, and data entry without external UI frameworks.
Core Features & Use Cases
- Widget Lifecycle: Create, setup, interact, and read values from widgets.
- Widget Types: Text inputs (editable-field, text), buttons (push-button, link), and selection controls (checkbox, radio-button-choice, menu-choice, etc.).
- Value Retrieval: Obtain user input via
widget-value and widget-value-set.
- Navigation & Interaction: Move between widgets with
widget-forward and widget-backward.
- Use Cases: Built-in forms, settings editors, and lightweight UI components in Emacs buffers.
Quick Start
To start:
- Require the library:
(require 'widget) and (eval-when-compile (require 'wid-edit))
- Create a simple form, then enable widgets with
widget-setup:
(defun simple-form ()
(interactive)
(switch-to-buffer "*Simple Form*")
(kill-all-local-variables)
(erase-buffer)
(remove-overlays)
(widget-insert "Name:\
")
(setq my-name (widget-create 'editable-field :size 20))
(widget-create 'push-button
:notify (lambda (&rest _)
(message "Submitted: %s" (widget-value my-name)))
"Submit")
(use-local-map widget-keymap)
(widget-setup))