]> git.eshelyaron.com Git - emacs.git/commitdiff
Allow tabbing between widgets to skip inactive widgets (bug#70413)
authorStephen Berman <stephen.berman@gmx.net>
Wed, 17 Apr 2024 17:33:24 +0000 (19:33 +0200)
committerEshel Yaron <me@eshelyaron.com>
Sat, 20 Apr 2024 11:03:21 +0000 (14:03 +0300)
* 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.

(cherry picked from commit 91333dacfa1b9f1041ceeebb3d46e8e04048c4c9)

doc/misc/widget.texi
etc/NEWS
lisp/wid-edit.el

index cfb9d2211cfbd7f504ae3095b34062c450f43c65..f74605c92c000f7fe7e5b6b5fca7346b60369b18 100644 (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
index 5ff82c99a522645a4e40baa507f5eff45e9974d8..d88314ddd3fc4140c615c42fbc369b6a4d860e4a 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1701,6 +1701,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
 
index 4bc1ebc406af2e57d9b60a0fa7b5adf6def8a64f..cb6d8ebc2c4b2023313dc1b82e3537c6ab83aa3e 100644 (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)