all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#70413: 30.0.50; FR: skip inactive widgets when tabbing
@ 2024-04-16  9:20 Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-04-16 12:53 ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-04-16  9:20 UTC (permalink / raw)
  To: 70413

[-- Attachment #1: Type: text/plain, Size: 1705 bytes --]

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.


In GNU Emacs 30.0.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version
 3.24.41, cairo version 1.18.0) of 2024-04-16 built on strobelfs
Repository revision: b436f430e3897e1aa6dcb5a39564a3553bbf631f
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101013
System Description: Linux From Scratch r12.1-41

Configured using:
 'configure 'CFLAGS=-Og -g3' PKG_CONFIG_PATH=/opt/qt5/lib/pkgconfig'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LCMS2 LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG
RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER
WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: skip inactive widgets patch --]
[-- Type: text/x-patch, Size: 954 bytes --]

diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index 172da3db1e0..b40d4bf8898 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -1219,11 +1219,20 @@ widget-button-press
 	(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)

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

* bug#70413: 30.0.50; FR: skip inactive widgets when tabbing
  2024-04-16  9:20 bug#70413: 30.0.50; FR: skip inactive widgets when tabbing Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-04-16 12:53 ` Eli Zaretskii
  2024-04-16 21:56   ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2024-04-16 12:53 UTC (permalink / raw)
  To: Stephen Berman; +Cc: 70413

> 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" <bug-gnu-emacs@gnu.org>
> 
> 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.





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

* bug#70413: 30.0.50; FR: skip inactive widgets when tabbing
  2024-04-16 12:53 ` Eli Zaretskii
@ 2024-04-16 21:56   ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-04-16 22:04     ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 9+ messages in thread
From: Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-04-16 21:56 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 70413

On Tue, 16 Apr 2024 15:53:48 +0300 Eli Zaretskii <eliz@gnu.org> 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" <bug-gnu-emacs@gnu.org>
>>
>> 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





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

* bug#70413: 30.0.50; FR: skip inactive widgets when tabbing
  2024-04-16 21:56   ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-04-16 22:04     ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-04-17 12:04       ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-04-16 22:04 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 70413

[-- Attachment #1: Type: text/plain, Size: 2042 bytes --]

On Tue, 16 Apr 2024 23:56:36 +0200 Stephen Berman <stephen.berman@gmx.net> wrote:

> On Tue, 16 Apr 2024 15:53:48 +0300 Eli Zaretskii <eliz@gnu.org> 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" <bug-gnu-emacs@gnu.org>
>>>
>>> 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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: widget doc and NEWS patch --]
[-- Type: text/x-patch, Size: 1633 bytes --]

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.
+
 \f
 * New Modes and Packages in Emacs 30.1


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

* bug#70413: 30.0.50; FR: skip inactive widgets when tabbing
  2024-04-16 22:04     ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-04-17 12:04       ` Eli Zaretskii
  2024-04-17 13:57         ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2024-04-17 12:04 UTC (permalink / raw)
  To: Stephen Berman; +Cc: 70413

> From: Stephen Berman <stephen.berman@gmx.net>
> Cc: 70413@debbugs.gnu.org
> Date: Wed, 17 Apr 2024 00:04:33 +0200
> 
> > 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:

LGTM, with 2 minor comments:

> +@defopt widget-skip-inactive
> +If non-@code{nil}, navigating between widgets by @kbd{M-@key{TAB}}
                                                    ^^^^^^^^^^^^^^^^^
This should probably be @kbd{key{TAB}}.

> +(@code{widget-forward}) or @kbd{S-@key{TAB}} (@code{widget-backward},
> +also bound to @kbd{M-@key{TAB}}) skips over inactive widgets.
                                   ^
I'd add a comma there.

Thanks.





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

* bug#70413: 30.0.50; FR: skip inactive widgets when tabbing
  2024-04-17 12:04       ` Eli Zaretskii
@ 2024-04-17 13:57         ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-04-17 15:42           ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-04-17 13:57 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 70413

On Wed, 17 Apr 2024 15:04:34 +0300 Eli Zaretskii <eliz@gnu.org> wrote:

>> From: Stephen Berman <stephen.berman@gmx.net>
>> Cc: 70413@debbugs.gnu.org
>> Date: Wed, 17 Apr 2024 00:04:33 +0200
>> 
>> > 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:
>
> LGTM, with 2 minor comments:
>
>> +@defopt widget-skip-inactive
>> +If non-@code{nil}, navigating between widgets by @kbd{M-@key{TAB}}
>                                                     ^^^^^^^^^^^^^^^^^

Oops, that was copy-pasta; thanks for catching it.

> This should probably be @kbd{key{TAB}}.

Or rather @key{TAB}, right?  That's what's used earlier in the Widget
manual and IIUC is what (info "(texinfo) @key") recommends.

>> +(@code{widget-forward}) or @kbd{S-@key{TAB}} (@code{widget-backward},
>> +also bound to @kbd{M-@key{TAB}}) skips over inactive widgets.
>                                    ^
> I'd add a comma there.

AFAIK, according to the usual rules of comma usage in English, a comma
should not be used there, since the entire phrase "navigating between
widgets by ‘<TAB>’ (‘widget-forward’) or ‘S-<TAB>’ (‘widget-backward’,
also bound to ‘M-<TAB>’)" is the subject of "skips".  But I grant that,
due to the length of this phrase and the parenthetical phrases it
includes, it does prosodically "feel" like there should be a comma.  The
following reformulation avoids this, and moreover conforms better to the
style of the Widget manual by using the imperative form "skip":

  If non-@code{nil}, skip over inactive widgets when using @key{TAB}
  (@code{widget-forward}) or @kbd{S-@key{TAB}} (@code{widget-backward},
  also bound to @kbd{M-@key{TAB}}) to navigate between widgets.

Is this formulation acceptable?

Steve Berman





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

* bug#70413: 30.0.50; FR: skip inactive widgets when tabbing
  2024-04-17 13:57         ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-04-17 15:42           ` Eli Zaretskii
  2024-04-17 17:36             ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2024-04-17 15:42 UTC (permalink / raw)
  To: Stephen Berman; +Cc: 70413

> From: Stephen Berman <stephen.berman@gmx.net>
> Cc: 70413@debbugs.gnu.org
> Date: Wed, 17 Apr 2024 15:57:56 +0200
> 
> On Wed, 17 Apr 2024 15:04:34 +0300 Eli Zaretskii <eliz@gnu.org> wrote:
> 
> >> +@defopt widget-skip-inactive
> >> +If non-@code{nil}, navigating between widgets by @kbd{M-@key{TAB}}
> >                                                     ^^^^^^^^^^^^^^^^^
> 
> Oops, that was copy-pasta; thanks for catching it.
> 
> > This should probably be @kbd{key{TAB}}.
> 
> Or rather @key{TAB}, right?  That's what's used earlier in the Widget
> manual and IIUC is what (info "(texinfo) @key") recommends.

No, @kbd{@key{TAB}} is correct when you are talking about user typing
something (as opposed to talking about the key TAB).

Texinfo explicitly tells you that @key is for naming a key, not for
describing user input.

>   If non-@code{nil}, skip over inactive widgets when using @key{TAB}
>   (@code{widget-forward}) or @kbd{S-@key{TAB}} (@code{widget-backward},
>   also bound to @kbd{M-@key{TAB}}) to navigate between widgets.
> 
> Is this formulation acceptable?

Yes, thanks.





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

* bug#70413: 30.0.50; FR: skip inactive widgets when tabbing
  2024-04-17 15:42           ` Eli Zaretskii
@ 2024-04-17 17:36             ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-04-17 17:37               ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 9+ messages in thread
From: Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-04-17 17:36 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 70413

On Wed, 17 Apr 2024 18:42:49 +0300 Eli Zaretskii <eliz@gnu.org> wrote:

>> From: Stephen Berman <stephen.berman@gmx.net>
>> Cc: 70413@debbugs.gnu.org
>> Date: Wed, 17 Apr 2024 15:57:56 +0200
>>
>> On Wed, 17 Apr 2024 15:04:34 +0300 Eli Zaretskii <eliz@gnu.org> wrote:
>>
>> >> +@defopt widget-skip-inactive
>> >> +If non-@code{nil}, navigating between widgets by @kbd{M-@key{TAB}}
>> >                                                     ^^^^^^^^^^^^^^^^^
>>
>> Oops, that was copy-pasta; thanks for catching it.
>>
>> > This should probably be @kbd{key{TAB}}.
>>
>> Or rather @key{TAB}, right?  That's what's used earlier in the Widget
>> manual and IIUC is what (info "(texinfo) @key") recommends.
>
> No, @kbd{@key{TAB}} is correct when you are talking about user typing
> something (as opposed to talking about the key TAB).
>
> Texinfo explicitly tells you that @key is for naming a key, not for
> describing user input.

Ah, ok.  I guess I misunderstood that, and also I misinterpreted the use
of @key{TAB} in (info "(widget) Widgets and the Buffer") that I referred
to above: it is in a table that begins with @table @kbd, so the effect
is that of @kbd{@key{TAB}}.  (But I do think there are several typos or
incorrect markup in that node and possibly elsewhere in the Widget
manual; but I'll make a separate bug report about that.)

>>   If non-@code{nil}, skip over inactive widgets when using @key{TAB}
>>   (@code{widget-forward}) or @kbd{S-@key{TAB}} (@code{widget-backward},
>>   also bound to @kbd{M-@key{TAB}}) to navigate between widgets.
>>
>> Is this formulation acceptable?
>
> Yes, thanks.

Thanks, I've pushed the changes to master as commit 91333dacfa1.

Steve Berman





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

* bug#70413: 30.0.50; FR: skip inactive widgets when tabbing
  2024-04-17 17:36             ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-04-17 17:37               ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 9+ messages in thread
From: Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-04-17 17:37 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 70413-done

On Wed, 17 Apr 2024 19:36:04 +0200 Stephen Berman <stephen.berman@gmx.net> wrote:

> On Wed, 17 Apr 2024 18:42:49 +0300 Eli Zaretskii <eliz@gnu.org> wrote:
[...]
>>>   If non-@code{nil}, skip over inactive widgets when using @key{TAB}
>>>   (@code{widget-forward}) or @kbd{S-@key{TAB}} (@code{widget-backward},
>>>   also bound to @kbd{M-@key{TAB}}) to navigate between widgets.
>>>
>>> Is this formulation acceptable?
>>
>> Yes, thanks.
>
> Thanks, I've pushed the changes to master as commit 91333dacfa1.

And now closing the bug.

Steve Berman





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

end of thread, other threads:[~2024-04-17 17:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-16  9:20 bug#70413: 30.0.50; FR: skip inactive widgets when tabbing Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-16 12:53 ` Eli Zaretskii
2024-04-16 21:56   ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-16 22:04     ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-17 12:04       ` Eli Zaretskii
2024-04-17 13:57         ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-17 15:42           ` Eli Zaretskii
2024-04-17 17:36             ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-17 17:37               ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors

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.