Subject: Re: bug#70413: 30.0.50; FR: skip inactive widgets when tabbing

From: Stephen Berman <[email-masked]>
Date: Wed, 17 Apr 2024 00:04:33 +0200

On Tue, 16 Apr 2024 23:56:36 +0200 Stephen Berman <[email-masked]> wrote:

> On Tue, 16 Apr 2024 15:53:48 +0300 Eli Zaretskii <[email-masked]> wrote:
>
>>> Date: Tue, 16 Apr 2024 11:20:10 +0200
>>> From:  Stephen Berman via "Bug reports for GNU Emacs,
>>>  the Swiss army knife of text editors" <[email-masked]>
>>>
>>> In buffers containing widgets, such as the Customize buffers, the
>>> widgets can be either active or inactive: when you click (with the mouse
>>> or RET) on an active widget, its associated action is executed, and when
>>> you click on an inactive widget, this raises the error "Attempt to
>>> perform action on inactive widget".  You can navigate among the widgets
>>> by pressing TAB or S-TAB to move point to the next or previous widget.
>>>
>>> I think it would be useful and convenient to skip over inactive widgets
>>> when tabbing; e.g. you then avoid accidentally tabbing to an inactive
>>> widget, typing RET and getting the error, and in a buffer with many
>>> active and inactive widgets, you can tab more quickly to the desired
>>> active widget by skipping over the inactive ones.
>>>
>>> The attached patch implements this behavior.  Since tabbing to inactive
>>> widgets has always been the behavior in the widget library, skipping is
>>> conditioned on the value of a boolean defcustom, with the default being
>>> the current non-skipping.
>>
>> This is OK, but please announce this new option in NEWS.
>
> Thanks; see the attached patch.  I think this user option should also be
> documented in the Widget manual, so the patch includes that as well.
> The Widget manual has a node for widget customizations, so I added it
> there.  But I think it is helpful to mention it also in the node
> "Widgets and the Buffer", where the tabbing commands `widget-forward'
> and `widget-backward' are documented, so that patch does that too.  If
> you confirm this is ok, I'll push the code and doc changes to master.
>
> Steve Berman

... and here's the patch:

diff --git a/doc/misc/widget.texi b/doc/misc/widget.texi
index cfb9d2211cf..154d8446b75 100644
--- a/doc/misc/widget.texi
+++ b/doc/misc/widget.texi
@@ -795,6 +795,11 @@ Widgets and the Buffer
 @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 @@ Customization
 By default, its value is @code{nil}.
 @end defopt

+@defopt widget-skip-inactive
+If non-@code{nil}, navigating between widgets by @kbd{M-@key{TAB}}
+(@code{widget-forward}) or @kbd{S-@key{TAB}} (@code{widget-backward},
+also bound to @kbd{M-@key{TAB}}) skips over inactive 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
diff --git a/etc/NEWS b/etc/NEWS
index 99f33a7b8dd..7b87e0b17c5 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -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