From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stephen Berman via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#69942: 30.0.50; Fontification of radio-button widget labels Date: Fri, 26 Apr 2024 14:47:26 +0200 Message-ID: <87o79wl28x.fsf@gmx.net> References: <87frwinw9c.fsf@rub.de> <864jcy1dt3.fsf@gnu.org> <259fef2b-e0bf-46c4-8b42-5e26f906accb@gmail.com> <87v85bqxfv.fsf@gmx.net> <87msqnqh2z.fsf@gmx.net> <871q7pw1l4.fsf@gmx.net> <861q7i50f3.fsf@gnu.org> <3c8e0d62-4a92-413f-9064-a06514948860@gmail.com> <8634rjf2il.fsf@gnu.org> <5d36ff4c-fea8-4f64-b401-1351f91446a1@gmail.com> <877cguhjux.fsf@gmx.net> <87y196lctq.fsf@gmx.net> Reply-To: Stephen Berman Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14420"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 69942@debbugs.gnu.org, Eli Zaretskii To: Mauro Aranda Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Apr 26 14:50:25 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1s0L21-0003Us-7b for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 26 Apr 2024 14:50:25 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s0L1Z-00069C-63; Fri, 26 Apr 2024 08:49:57 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s0L1W-00066g-MR for bug-gnu-emacs@gnu.org; Fri, 26 Apr 2024 08:49:54 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s0L1V-0003AP-Mr for bug-gnu-emacs@gnu.org; Fri, 26 Apr 2024 08:49:54 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s0L1n-00039K-84 for bug-gnu-emacs@gnu.org; Fri, 26 Apr 2024 08:50:11 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stephen Berman Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 26 Apr 2024 12:50:10 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69942 X-GNU-PR-Package: emacs Original-Received: via spool by 69942-submit@debbugs.gnu.org id=B69942.171413574411302 (code B ref 69942); Fri, 26 Apr 2024 12:50:10 +0000 Original-Received: (at 69942) by debbugs.gnu.org; 26 Apr 2024 12:49:04 +0000 Original-Received: from localhost ([127.0.0.1]:34299 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s0L0X-0002uP-MS for submit@debbugs.gnu.org; Fri, 26 Apr 2024 08:49:03 -0400 Original-Received: from mout.gmx.net ([212.227.17.22]:56753) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s0KzY-0002h7-2Y for 69942@debbugs.gnu.org; Fri, 26 Apr 2024 08:48:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1714135647; x=1714740447; i=stephen.berman@gmx.net; bh=O7P7K2PoSctPMoXXx5eh4zyiJsdipKkdzqwsucXpufM=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=eVz6ciu95/s77Cji0FsMl9SydT5HrimkTnq9hjI2licUMVdbmeHYrr7vItS610dj HOZmo5uv8iiRRbqz6/SVjmkcWe2MV/BLbzITYgf8omqStqeqZ3G6CNXZOFF5hemYL am5e8aHPdF42sc0Oh7s3fleiY18t7sPTLhzGbE3r/EnUW3ZEdgYZyXwaGoBJHEnwL 5A77nXXuFmF/wVsh1bBgEig/YbFB2mfwN98EDiDMuDhV9V6ibM9SZwgHK8hYO5LjF zxxiKr5xA9NSxpJrJeW+Ljk5pQ7mobQb+J+5TfbwndghIeYLPCUsL32sRBE1nb+xt 2H/pLP+6zOljjznBuQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from strobelfs ([94.134.94.5]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MrQEx-1sVG9o1TgV-00oTVs; Fri, 26 Apr 2024 14:47:27 +0200 In-Reply-To: <87y196lctq.fsf@gmx.net> (Stephen Berman's message of "Sun, 21 Apr 2024 21:45:21 +0200") X-Provags-ID: V03:K1:XZr7aoBWrKnzOgKO332PQmAfvKdXTGKPf+cKXh0AY2H6tCoEncM RgsqEtu2vSjlAI5Vh+pqRLA/dfa8b1B9GDT+skNwo7AABV+UbKMJiAPXQlheDJBVmB5LPQl +gnBpUK/9bjS4I9X8/6x2okmNwRU3y07ESkGqkHwcJhWXjbA3Eyt3fZT3++hbTTBQalAKZ4 gJNbyazHIJep+az8uoq0w== UI-OutboundReport: notjunk:1;M01:P0:zsbrJPaIsV8=;f10gKNjateD2fgcrGKnrRaOJmEt 72vzuCgRkG8lgEHlCRHSpfI8mepAiekd2AaegPbVkES+pwHL7BZ/ARQdvOip+EA7c8LQ5Gkj+ sXCd//ccId+I4mhzfNsH8T4IKBKbGlYBr4aMwPRv1e0FQu6mSTUge74lDulMj6C6WVsnrWLAm yr4HiJ5U37bAguLC5ywft7Nk+N/4VThwS5Q3ra6qh1kZBVBZzjggJhrAJx2SVmMB1zOFX2jcA nKDU+I/SKa2G2X1aZMQOgBkLeg9RLhI49WTgexvwCFmdw5OrGfNCO5K6SrMO/VGdcGwfTmCJP +CUJx7Vr5mtoL6r10s6ZRmKAMhozMHYdTn0Hi5XrGN2RnEwexvvfHfLiAei/L+y5rg8BVyAcG E8k+YNpw5JjAWoOsD7fr1W+qD4bbnPYCfbkTiI6bKTXzSdfCZTYZnFjVPup9iW9nawCI9obSQ Ck/uIJNiL2eevFtoUiYGjRBfBe/mdlTfqGjtITi6Ik8HYdXwwhf9LTo7AWkf5nEAuPVqLMdMg V3y3R8PUg3Ydn6AUPyIZAIaNjbKeaF+RaA0zarHYvlqOhbQnRcn5miNy3uZVw8FFnO3e+eYHq ht4ddRZECA+HmyYSRvt9AepPJBBOd3lpMojp2VimP6r3WHg8SgXCbZy78JtFmxCrUe/QVt9xS tK+jt2nNkGnVmMlbrflqOKJ9KaiIt3gZGZJu8WEhfUKNOdqC0Efi+D8PXmnsN4KLbp9YVwEvy pG5V/2vcZafYsXEoJOwgk7my3PwQCZQOo7Pq1XNaeHOHB7KoUTDSCCwNMB2Q7UjmoUUmBtNC X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:283990 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Sun, 21 Apr 2024 21:45:21 +0200 Stephen Berman = wrote: > On Thu, 18 Apr 2024 15:37:58 +0200 Stephen Berman wrote: > >> On Thu, 18 Apr 2024 07:07:43 -0300 Mauro Aranda = wrote: >> >>> Eli Zaretskii writes: >>> >>>>> Date: Mon, 8 Apr 2024 07:58:44 -0300 >>>>> Cc: 69942@debbugs.gnu.org >>>>> From: Mauro Aranda >>>>> >>>>> On 6/4/24 06:02, Eli Zaretskii wrote: >>>>>=C2=A0 >> From: Stephen Berman >>>>>=C2=A0 >> Cc: Eli Zaretskii , 69942@debbugs.gnu.org >>>>>=C2=A0 >> Date: Mon, 01 Apr 2024 17:21:27 +0200 >>>>>=C2=A0 >> >>>>>=C2=A0 >> On Mon, 25 Mar 2024 01:40:36 +0100 Stephen Berman >>>>> wrote: >>>>>=C2=A0 >> >>>>>=C2=A0 >>> Ok, I've gotten further with implementing disinguishing by = faces >>>>>=C2=A0 >>> selected (chosen) and unselected radio buttons in radio-but= ton-choice >>>>>=C2=A0 >>> widgets and check boxes in checklist widgets, see the attac= hed patch. >>>>>=C2=A0 >>> Initial tests seem ok, but it definitely needs more testing. >>>>>=C2=A0 >> >>>>>=C2=A0 >> Any comments on this patch for using a widget-unselected fac= e?=C2=A0 I have >>>>>=C2=A0 >> been detained from further testing this past week, but can n= ow resume. >>>>>=C2=A0 > >>>>>=C2=A0 > Mauro, any further comments? >>>>> >>>>> Hi Eli and Stephen, >>>>> >>>>> Please forgive me, for the past 2 weeks I haven't been able to do any >>>>> computer stuff.=C2=A0 If it's OK, please give me until the weekend so= I >>>>> can catch up with this and the other 2 bug reports by Stephen. >>>> >>>> Mauro, were you able to find time to look into this and the other 2 >>>> bugs? >>> >>> I have, just now.=C2=A0 The patch looks good to me.=C2=A0 It'll be grea= t if >>> Stephen can add some documentation to the manual, so it stays updated. >>> If not, I can do that in a few days. >> >> Sure, I'll add documentation and post it here for approval before >> pushing the changes. > > I've encountered some problems with the patch. One is that it breaks > the display of all face attributes in the customize-face buffer. I've > determined the part of the patch that triggers this, though I haven't > yet figured out just why this bit of code breaks the display. Also, it > appears that the widget-unselected face does not completely replace > widget-inactive where it's intended to do so, but I need to do more > testing and debugging here to find out why. Until I've fixed these > issues the patch is not suitable for installing, so I'm also holding off > with the accompanying documentation. (But in preparation for the > documentation I looked more closely at the Widget manual and found > several typos and other issues, for which I opened bug#70502.) The breakage in displaying all face attributes in the customize-face buffer was caused by the invocation of `(widget-specify-selected child)' in widget-checklist-add-item in the cond-clause satisfying `(widget-inline-p type t)'. I still don't understand why it has this effect, and I have to admit that I don't understand what an inline widget is. But simply omitting the invocation of `(widget-specify-selected child)' at this point in the patch does avoid the customize-face breakage and I have not noticed any problems due to this omission. As for the problematic interaction between the widget-unselected and widget-inactive faces, this seems to have been due to my having copied most of the definition of widget-specify-unselected from that of widget-specify-inactive, and specifically, copying the overlay priority. In the attached patch, widget-specify-unselected now uses a lower overlay priority than the one used in widget-specify-inactive, and in my tests this yields the desired results: the labels of active checkboxes and radio-buttons have widget-unselected face but when these widgets are deactivated, the labels have widget-inactive face. Another change I've made in the attached patch is to have the default value of widget-unselected face inherit from widget-inactive instead of inheriting from shadow face, like widget-inactive does by default. This way, if a user customizes widget-inactive, that will also apply by default to widget-unselected, thus retaining the current default widget UI where the labels of checkboxes and radio-buttons have widget-inactive face. (Thus, the "desired results" in the preceding paragraph are only visible when widget-unselected face is customized to differ from widget-unselected face.) Finally, regarding documentation of widget-unselected face in the Widget manual, I think it would be helpful for the documentation to mention the use case that motivated introducing it (following Mauro's suggestion to use a face instead of a defcustom), namely, to visually distinguish the labels of unselected and inactive widgets. Here is what I suggest: @deffn Face widget-unselected Face used for unselected widgets. This face is also used on the text labels of radio-button and checkbox widgets. The default value inherits @code{widget-inactive} face. If you want to visually distinguish the labels of unselected active radio-button or checkbox widgets from the labels of unselected inactive widgets, customize this face to a non-default value. @end deffn Since the recent widget.texi changes that include documenting widget-inactive face have not yet been merged to master, I haven't included the propopsed documentaton of widget-unselected in the attached patch, but if approved, will of course add it after the merge. Steve Berman --=-=-= Content-Type: text/x-patch Content-Disposition: attachment Content-Description: widget-unselected patch Content-Transfer-Encoding: quoted-printable diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el index dc481d4d0a5..b7673b01c73 100644 =2D-- a/lisp/wid-edit.el +++ b/lisp/wid-edit.el @@ -555,6 +555,29 @@ widget-specify-active (delete-overlay inactive) (widget-put widget :inactive nil)))) +(defface widget-unselected + '((t :inherit widget-inactive)) + "Face used for unselected widgets." + :group 'widget-faces + :version "30.1") + +(defun widget-specify-unselected (widget from to) + "Fontify WIDGET as unselected (not chosen)." + (let ((overlay (make-overlay from to nil t nil))) + (overlay-put overlay 'face 'widget-unselected) + (overlay-put overlay 'evaporate t) + ;; The overlay priority here should be lower than the priority in + ;; `widget-specify-active' (bug#69942). + (overlay-put overlay 'priority 90) + (widget-put widget :unselected overlay))) + +(defun widget-specify-selected (widget) + "Remove fontification of WIDGET as unselected (not chosen)." + (let ((unselected (widget-get widget :unselected))) + (when unselected + (delete-overlay unselected) + (widget-put widget :unselected nil)))) + ;;; Widget Properties. (defsubst widget-type (widget) @@ -2439,10 +2462,16 @@ 'checkbox (defun widget-checkbox-action (widget &optional event) "Toggle checkbox, notify parent, and set active state of sibling." (widget-toggle-action widget event) - (let ((sibling (widget-get-sibling widget))) + (let* ((sibling (widget-get-sibling widget)) + (from (widget-get sibling :from)) + (to (widget-get sibling :to))) (when sibling - (widget-apply sibling - (if (widget-value widget) :activate :deactivate)) + (if (widget-value widget) + (progn + (widget-apply sibling :activate) + (widget-specify-selected sibling)) + :deactivate + (widget-specify-unselected sibling from to)) (widget-clear-undo)))) ;;; The `checklist' Widget. @@ -2498,15 +2527,18 @@ widget-checklist-add-item ((eq escape ?v) (setq child (cond ((not chosen) - (let ((child (widget-create-child widget type))) - (widget-apply child :deactivate) + (let* ((child (widget-create-child widget type)) + (from (widget-get child :from)) + (to (widget-get child :to))) + (widget-specify-unselected child from to) child)) ((widget-inline-p type t) (widget-create-child-value widget type (cdr chosen))) (t (widget-create-child-value - widget type (car (cdr chosen))))))) + widget type (car (cdr chosen))) + (widget-specify-selected child))))) (t (error "Unknown escape `%c'" escape))))) ;; Update properties. @@ -2677,8 +2709,11 @@ widget-radio-add-item (widget-create-child-value widget type value) (widget-create-child widget type))) - (unless chosen - (widget-apply child :deactivate))) + (if chosen + (widget-specify-selected child) + (let ((from (widget-get child :from)) + (to (widget-get child :to))) + (widget-specify-unselected child from to)))) (t (error "Unknown escape `%c'" escape))))) ;; Update properties. @@ -2728,14 +2763,17 @@ widget-radio-value-set (dolist (current (widget-get widget :children)) (let* ((button (widget-get current :button)) (match (and (not found) - (widget-apply current :match value)))) + (widget-apply current :match value))) + (from (widget-get current :from)) + (to (widget-get current :to))) (widget-value-set button match) (if match - (progn - (widget-value-set current value) - (widget-apply current :activate)) - (widget-apply current :deactivate)) - (setq found (or found match)))))) + (progn + (widget-value-set current value) + (widget-apply current :activate) + (widget-specify-selected current)) + (widget-specify-unselected current from to)) + (setq found (or found match)))))) (defun widget-radio-validate (widget) ;; Valid if we have made a valid choice. @@ -2755,13 +2793,16 @@ widget-radio-action (let ((buttons (widget-get widget :buttons))) (when (memq child buttons) (dolist (current (widget-get widget :children)) - (let* ((button (widget-get current :button))) + (let* ((button (widget-get current :button)) + (from (widget-get current :from)) + (to (widget-get current :to))) (cond ((eq child button) (widget-value-set button t) - (widget-apply current :activate)) + (widget-apply current :activate) + (widget-specify-selected current)) ((widget-value button) (widget-value-set button nil) - (widget-apply current :deactivate))))))) + (widget-specify-unselected current from to))))))) ;; Pass notification to parent. (widget-apply widget :notify child event)) --=-=-=--