aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Aranda2025-02-24 19:39:43 -0300
committerMauro Aranda2025-02-24 19:55:31 -0300
commit363adcc69d322bdede1934b47e9dd1fbc3148ab9 (patch)
tree180c3ab8282d1121bedb0a7d312b1dc059f37218
parent60232a30e360c00fb303cb033d4aec15a9e41342 (diff)
downloademacs-363adcc69d322bdede1934b47e9dd1fbc3148ab9.tar.gz
emacs-363adcc69d322bdede1934b47e9dd1fbc3148ab9.zip
Fix bad fontification of inactive widgets
* lisp/wid-edit.el (widget-specify-inactive): When a widget is already inactive, still move the overlay to the desired positions. Improve docstring. (Bug#69941) * doc/misc/widget.texi (default): Document the need to call the :deactivate function when modifying an inactive widget. * test/lisp/wid-edit-tests.el (widget-test-modification-of-inactive-widget): New test
-rw-r--r--doc/misc/widget.texi3
-rw-r--r--lisp/wid-edit.el11
-rw-r--r--test/lisp/wid-edit-tests.el14
3 files changed, 26 insertions, 2 deletions
diff --git a/doc/misc/widget.texi b/doc/misc/widget.texi
index 68d53a42025..f84e81bce77 100644
--- a/doc/misc/widget.texi
+++ b/doc/misc/widget.texi
@@ -1333,6 +1333,9 @@ modifications.
1333Function that takes a widget and makes it inactive for user 1333Function that takes a widget and makes it inactive for user
1334modifications. 1334modifications.
1335 1335
1336If you modify a widget that is not active, you should make sure the
1337:deactivate function gets called again after the modifications.
1338
1336@vindex action@r{ keyword} 1339@vindex action@r{ keyword}
1337@item :action 1340@item :action
1338Function that takes a widget and optionally an event, and handles a 1341Function that takes a widget and optionally an event, and handles a
diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index 38d065a7d65..38c8d34792a 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -549,8 +549,15 @@ With CHECK-AFTER non-nil, considers also the content after point, if needed."
549 :group 'widget-faces) 549 :group 'widget-faces)
550 550
551(defun widget-specify-inactive (widget from to) 551(defun widget-specify-inactive (widget from to)
552 "Make WIDGET inactive for user modifications." 552 "Make WIDGET inactive for user modifications.
553 (unless (widget-get widget :inactive) 553
554If WIDGET is already inactive, moves the :inactive overlay to the positions
555indicated by FROM and TO, either numbers or markers.
556
557If WIDGET is not inactive, creates an overlay that spans from FROM to TO,
558and saves that overlay under the :inactive property for WIDGET."
559 (if (widget-get widget :inactive)
560 (move-overlay (widget-get widget :inactive) from to)
554 (let ((overlay (make-overlay from to nil t nil))) 561 (let ((overlay (make-overlay from to nil t nil)))
555 (overlay-put overlay 'face 'widget-inactive) 562 (overlay-put overlay 'face 'widget-inactive)
556 ;; This is disabled, as it makes the mouse cursor change shape. 563 ;; This is disabled, as it makes the mouse cursor change shape.
diff --git a/test/lisp/wid-edit-tests.el b/test/lisp/wid-edit-tests.el
index e34aa64f8d1..755bd12201f 100644
--- a/test/lisp/wid-edit-tests.el
+++ b/test/lisp/wid-edit-tests.el
@@ -481,4 +481,18 @@ markers (and so on) as well."
481 (should (= ofrom2 (widget-get group2 :from))) 481 (should (= ofrom2 (widget-get group2 :from)))
482 (should (= oto2 (widget-get group2 :to)))))) 482 (should (= oto2 (widget-get group2 :to))))))
483 483
484(ert-deftest widget-test-modification-of-inactive-widget ()
485 "Test that modifications to an inactive widget keep all of it inactive."
486 (with-temp-buffer
487 (let* ((radio (widget-create 'radio-button-choice
488 '(item "One") '(item "Two") '(item "Confirm")))
489 (from (widget-get radio :from))
490 (to (widget-get radio :to))
491 (ov (progn (widget-apply radio :deactivate)
492 (widget-get radio :inactive))))
493 (widget-value-set radio "")
494 (widget-apply radio :deactivate)
495 (should (= (overlay-start ov) from))
496 (should (= (overlay-end ov) to)))))
497
484;;; wid-edit-tests.el ends here 498;;; wid-edit-tests.el ends here