(let ((new (widget-tabable-at)))
(while (and (eq (widget-tabable-at) new) (not (bobp)))
(backward-char)))
- (unless (bobp) (forward-char)))
+ ;; If the widget is at BOB, point is already at the widget's
+ ;; starting position; otherwise, advance point to put it at the
+ ;; start of the widget (cf. bug#69943 and bug#72995).
+ (unless (and (widget-tabable-at) (bobp)) (forward-char)))
(unless suppress-echo
(widget-echo-help (point)))
(run-hooks 'widget-move-hook))
(should (string= "Third" (widget-value (widget-at))))
(widget-forward 1))) ; Should not signal beginning-of-buffer error.
+(ert-deftest widget-test-widget-move-bug72995 ()
+ "Test moving to a widget that starts at buffer position 2."
+ (with-temp-buffer
+ ;; The first tabable widget begins at position 2 (bug#72995).
+ (widget-insert " ")
+ (dolist (el '("First" "Second" "Third"))
+ (widget-create 'push-button el))
+ (widget-insert "\n")
+ (use-local-map widget-keymap)
+ (widget-setup)
+ ;; Make sure there is no tabable widget at BOB.
+ (goto-char (point-min))
+ (should-not (widget-tabable-at))
+ ;; Check that we can move to the first widget after BOB.
+ (widget-forward 1)
+ (should (widget-tabable-at))))
+
(ert-deftest widget-test-color-match ()
"Test that the :match function for the color widget works."
(let ((widget (widget-convert 'color)))