diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el index 172da3db1e0..7fc9ac59b0a 100644 --- a/lisp/wid-edit.el +++ b/lisp/wid-edit.el @@ -1733,8 +1733,17 @@ widget-default-create (goto-char value-pos) (widget-apply widget :value-create))) (let ((from (point-min-marker)) - (to (point-max-marker))) - (set-marker-insertion-type from t) + (to (point-max-marker)) + ;; When WIDGET is a radio-button-choice widget and its first + ;; child radio-button widget is inserted, advancing the marker + ;; FROM would make the overlay setting the widget-inactive face + ;; begin right after the first radio button, which would hence + ;; incorrectly not be fontified with the widget-inactive face. + ;; To ensure it is correctly fontified, we set the marker + ;; insertion type of FROM to nil only when WIDGET is + ;; radio-button-choice, otherwise to t (bug#69941). + (from-mit (not (eq 'radio-button-choice (widget-type widget))))) + (set-marker-insertion-type from from-mit) (set-marker-insertion-type to nil) (widget-put widget :from from) (widget-put widget :to to))) diff --git a/test/lisp/wid-edit-tests.el b/test/lisp/wid-edit-tests.el index 4b049478b29..d416eb99022 100644 --- a/test/lisp/wid-edit-tests.el +++ b/test/lisp/wid-edit-tests.el @@ -336,7 +336,13 @@ widget-test-widget-move (widget-forward 2) (forward-char) (widget-backward 1) - (should (string= "Second" (widget-value (widget-at)))))) + (should (string= "Second" (widget-value (widget-at)))) + ;; Check that moving to a widget at beginning of buffer does not + ;; signal a beginning-of-buffer error (bug#69943). + (widget-backward 1) ; Should not signal beginning-of-buffer error. + (widget-forward 2) + (should (string= "Third" (widget-value (widget-at)))) + (widget-forward 1))) ; Should not signal beginning-of-buffer error. (ert-deftest widget-test-color-match () "Test that the :match function for the color widget works."