1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-30 04:10:54 -08:00

Allow tabbing between widgets to skip inactive widgets (bug#70413)

* doc/misc/widget.texi (Widgets and the Buffer, Customization):
Document it.

* etc/NEWS: Announce it.

* lisp/wid-edit.el (widget-skip-inactive): New user option.
(widget-tabable-at): Use it.
This commit is contained in:
Stephen Berman 2024-04-17 19:33:24 +02:00
parent 523aca13a4
commit 91333dacfa
3 changed files with 32 additions and 2 deletions

View file

@ -795,6 +795,11 @@ Move point @var{count} buttons or editing fields backward.
@end deffn
@end table
@noindent
By default, tabbing can put point on an inactive widget. To skip over
inactive widgets when tabbing, set the user option
@code{widget-skip-inactive} to a non-@code{nil} value.
@xref{Customization}.
When editing an @code{editable-field} widget, the following commands
are available:
@ -3321,6 +3326,15 @@ If non-@code{nil}, toggle when there are just two options.
By default, its value is @code{nil}.
@end defopt
@defopt widget-skip-inactive
If non-@code{nil}, skip over inactive widgets when using @kbd{@key{TAB}}
(@code{widget-forward}) or @kbd{S-@key{TAB}} (@code{widget-backward},
also bound to @kbd{M-@key{TAB}}) to navigate between widgets.
By default, its value is @code{nil} and tabbing does not skip over
inactive widgets.
@end defopt
@defopt widget-documentation-links
If non-@code{nil}, add hyperlinks to documentation strings.
@end defopt

View file

@ -1603,6 +1603,13 @@ This allows disabling JavaScript in xwidget Webkit sessions.
'insert-directory', now supports the '--time=TIME' and '--sort=time'
options of GNU 'ls'.
** Widget
+++
*** New user option 'widget-skip-inactive'.
If non-nil, moving point forward or backward between widgets by typing
TAB or S-TAB skips over inactive widgets. The default value is nil.
* New Modes and Packages in Emacs 30.1

View file

@ -1234,11 +1234,20 @@ If nothing was called, return non-nil."
(when (commandp command)
(call-interactively command))))))
(defcustom widget-skip-inactive nil
"If non-nil, skip inactive widgets when tabbing through buffer."
:version "30.1"
:group 'widgets
:type 'boolean)
(defun widget-tabable-at (&optional pos)
"Return the tabable widget at POS, or nil.
POS defaults to the value of (point)."
POS defaults to the value of (point). If user option
`widget-skip-inactive' is non-nil, inactive widgets are not tabable."
(let ((widget (widget-at pos)))
(if widget
(if (and widget (if widget-skip-inactive
(widget-apply widget :active)
t))
(let ((order (widget-get widget :tab-order)))
(if order
(if (>= order 0)