aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Berman2024-04-17 19:33:24 +0200
committerStephen Berman2024-04-17 19:33:24 +0200
commit91333dacfa1b9f1041ceeebb3d46e8e04048c4c9 (patch)
tree4252bf855a528a2abb192f70774b48c84442fd8e
parent523aca13a45159711d7d9d7561e69d38acdac12a (diff)
downloademacs-91333dacfa1b9f1041ceeebb3d46e8e04048c4c9.tar.gz
emacs-91333dacfa1b9f1041ceeebb3d46e8e04048c4c9.zip
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.
-rw-r--r--doc/misc/widget.texi14
-rw-r--r--etc/NEWS7
-rw-r--r--lisp/wid-edit.el13
3 files changed, 32 insertions, 2 deletions
diff --git a/doc/misc/widget.texi b/doc/misc/widget.texi
index cfb9d2211cf..f74605c92c0 100644
--- a/doc/misc/widget.texi
+++ b/doc/misc/widget.texi
@@ -795,6 +795,11 @@ Move point @var{count} buttons or editing fields backward.
795@end deffn 795@end deffn
796@end table 796@end table
797 797
798@noindent
799By default, tabbing can put point on an inactive widget. To skip over
800inactive widgets when tabbing, set the user option
801@code{widget-skip-inactive} to a non-@code{nil} value.
802@xref{Customization}.
798 803
799When editing an @code{editable-field} widget, the following commands 804When editing an @code{editable-field} widget, the following commands
800are available: 805are available:
@@ -3321,6 +3326,15 @@ If non-@code{nil}, toggle when there are just two options.
3321By default, its value is @code{nil}. 3326By default, its value is @code{nil}.
3322@end defopt 3327@end defopt
3323 3328
3329@defopt widget-skip-inactive
3330If non-@code{nil}, skip over inactive widgets when using @kbd{@key{TAB}}
3331(@code{widget-forward}) or @kbd{S-@key{TAB}} (@code{widget-backward},
3332also bound to @kbd{M-@key{TAB}}) to navigate between widgets.
3333
3334By default, its value is @code{nil} and tabbing does not skip over
3335inactive widgets.
3336@end defopt
3337
3324@defopt widget-documentation-links 3338@defopt widget-documentation-links
3325If non-@code{nil}, add hyperlinks to documentation strings. 3339If non-@code{nil}, add hyperlinks to documentation strings.
3326@end defopt 3340@end defopt
diff --git a/etc/NEWS b/etc/NEWS
index bc8be557711..e6f8eb5ba46 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1603,6 +1603,13 @@ This allows disabling JavaScript in xwidget Webkit sessions.
1603'insert-directory', now supports the '--time=TIME' and '--sort=time' 1603'insert-directory', now supports the '--time=TIME' and '--sort=time'
1604options of GNU 'ls'. 1604options of GNU 'ls'.
1605 1605
1606** Widget
1607
1608+++
1609*** New user option 'widget-skip-inactive'.
1610If non-nil, moving point forward or backward between widgets by typing
1611TAB or S-TAB skips over inactive widgets. The default value is nil.
1612
1606 1613
1607* New Modes and Packages in Emacs 30.1 1614* New Modes and Packages in Emacs 30.1
1608 1615
diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index 4bc1ebc406a..cb6d8ebc2c4 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -1234,11 +1234,20 @@ If nothing was called, return non-nil."
1234 (when (commandp command) 1234 (when (commandp command)
1235 (call-interactively command)))))) 1235 (call-interactively command))))))
1236 1236
1237(defcustom widget-skip-inactive nil
1238 "If non-nil, skip inactive widgets when tabbing through buffer."
1239 :version "30.1"
1240 :group 'widgets
1241 :type 'boolean)
1242
1237(defun widget-tabable-at (&optional pos) 1243(defun widget-tabable-at (&optional pos)
1238 "Return the tabable widget at POS, or nil. 1244 "Return the tabable widget at POS, or nil.
1239POS defaults to the value of (point)." 1245POS defaults to the value of (point). If user option
1246`widget-skip-inactive' is non-nil, inactive widgets are not tabable."
1240 (let ((widget (widget-at pos))) 1247 (let ((widget (widget-at pos)))
1241 (if widget 1248 (if (and widget (if widget-skip-inactive
1249 (widget-apply widget :active)
1250 t))
1242 (let ((order (widget-get widget :tab-order))) 1251 (let ((order (widget-get widget :tab-order)))
1243 (if order 1252 (if order
1244 (if (>= order 0) 1253 (if (>= order 0)