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#69941: 30.0.50; Faulty fontification of radio button widgets Date: Fri, 26 Apr 2024 14:45:54 +0200 Message-ID: <87plucl2bh.fsf@gmx.net> References: <87h6gynx49.fsf@rub.de> <865xxe1dwd.fsf@gnu.org> <51c20b56-4b82-4f5c-9559-cdbd0146df22@gmail.com> <87wmprqxj3.fsf@gmx.net> <8734s5w1mf.fsf@gmx.net> <941f6565-203b-47bf-82a9-2bb7b0788b6a@gmail.com> <86h6fyewgq.fsf@gnu.org> <875xwehjty.fsf@gmx.net> <87wmoqlcso.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="4247"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 69941@debbugs.gnu.org, Mauro Aranda , monnier@iro.umontreal.ca To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Apr 26 14:48:29 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 1s0L09-0000rD-JT for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 26 Apr 2024 14:48:29 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s0Kyp-0002yo-O9; Fri, 26 Apr 2024 08:47:07 -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 1s0KyX-0002v2-7O for bug-gnu-emacs@gnu.org; Fri, 26 Apr 2024 08:46:57 -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 1s0KyW-0002qC-Vf for bug-gnu-emacs@gnu.org; Fri, 26 Apr 2024 08:46:48 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s0Kyo-0002a0-W5 for bug-gnu-emacs@gnu.org; Fri, 26 Apr 2024 08:47:07 -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:47:06 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69941 X-GNU-PR-Package: emacs Original-Received: via spool by 69941-submit@debbugs.gnu.org id=B69941.17141356089703 (code B ref 69941); Fri, 26 Apr 2024 12:47:06 +0000 Original-Received: (at 69941) by debbugs.gnu.org; 26 Apr 2024 12:46:48 +0000 Original-Received: from localhost ([127.0.0.1]:34293 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s0KyK-0002Ua-My for submit@debbugs.gnu.org; Fri, 26 Apr 2024 08:46:46 -0400 Original-Received: from mout.gmx.net ([212.227.17.22]:53055) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s0KyB-0002Rh-3Z for 69941@debbugs.gnu.org; Fri, 26 Apr 2024 08:46:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1714135555; x=1714740355; i=stephen.berman@gmx.net; bh=AnRUioFZuIh5w5N8f0TgiKqr3A4B/BEJO2TwQ2vO25E=; 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=Ubd8UYNidzZFlesjnsxoIMqYBbepezqUedivCOrIYi+7GnWE62JOHMjSlE6S8Ix/ 5VS65GCt3RUWc0voNHQ9FKQ/gjm5qLp5WQWYwjknZxi9S8ufsDqY7FxlfRNvex1wD 9588vhVtRDohs/fpjgr1dxAOxLneKCl2ai5dkZVBWTGqcMvTY1Fa0nK0ZS26n1tgn o8Fbgr2YXaLr9/w6A67ZyYbiDHlvCIPQrgUN7Kx0ZXLIOD7hYz/86GqTeTOm7fQXq lAdDCqspCQbOC5apT8MUGyLUyY207zT6Ft0koo9kZOU8SAzkFF+Gs+5CKLTIfssFJ HQwAl8KDyv+dn5gAtA== 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 1MBDnC-1rpreH2npW-00Cfof; Fri, 26 Apr 2024 14:45:55 +0200 In-Reply-To: <87wmoqlcso.fsf@gmx.net> (Stephen Berman's message of "Sun, 21 Apr 2024 21:45:59 +0200") X-Provags-ID: V03:K1:WKp7GSBn+Q1oEf6ok4wUb7eDgDyfaDIrqU4GZV90Os4ls1qtmuH zauhslO0y5An4yVCfgbFctauZAzSC2mccWzuXeMJNz7GPcx4Y1JHBTlgenJwWpz4FTYrz2s ISYjLAoz/lrGpXRgT8Lc/tvprTEjqsoghP2YmzJcthNobedmYQxH0AhURPqzLI1KAEKYrZZ KcdqlplE+UkdrLpEGHFmQ== UI-OutboundReport: notjunk:1;M01:P0:QoH3/B5O/1M=;UkM2oqKni68JhnFTiHwI6/l5SgI 6pXqSFo+9ecYZlH9yJHPrwvILXrQkL44Wq6yM05xHpqn1yOd+Hno5oLQg0svm/ihGFYjMn55o 0Mbr5qBTDcfhEGrP1EtaRUQSCYxrRWKE7MAUiw7ziQ58AKabE8zzHdeQTDtG6h76UVcKZ4tsj bo1jLf9bTnhsyi2BQqKpPW2h83RvPAx8R+q+nr4Niof+1kSCSFGb6UjrwoYAx1OdBg+utaIet TCmjthj9ZkH3zOjylxcU8ZQyucwNktBnBmGFNVJIUr3ulR44T/w5Y3GkknFWmUIbIKJZz9w3e GQiivyt/gPVdMKLUXkaJyPqDDBLaVu9sepBUrsVLdLkSuA8QOK9BCeK40JofwwE9NWyrdPpWs l59xd1tb64GvGCJWPQqHTmqDbliIrDJi+rVVhWgJQmhn/7BOBPfeVHfLPg9q/ONqjm9FWwszp Gi/kK48qnygtrINFm6U6iNrTknnKAn1z1EkRWz4MI7th/2JwMXcd/DB9Azo3Px6NTJc8EQHtr s8SdiN5ohai6lkgpBI4fsId/HndSmrf1E2GxzNt96RZub2IqWoBx5fUFISklnFu4zJ8Pl07hH LSvnIoK0HWYDLZaznE/2aWm3B+oRi1bdi9BweOv3zHdlK3C3HI8QW60Of2ZwskBa5v1loNmgt MwcwI409Fy+4Jxl/ZRGbsq8bynNweoWl6WTJY4OrsFJHZczweVS9UKf8nuQGeHVl1+0HH/dus Fp51eflHCO8J/kBgcn+UtkPQTq8pm7Op9Xbs24dl0sgBYOpzWeVXdEHmHnK7gzsnf3rWEfHR 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:283989 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Sun, 21 Apr 2024 21:45:59 +0200 Stephen Berman = wrote: > On Thu, 18 Apr 2024 15:38:33 +0200 Stephen Berman wrote: > >> On Thu, 18 Apr 2024 14:33:57 +0300 Eli Zaretskii wrote: >> >>>> Date: Thu, 18 Apr 2024 07:18:29 -0300 >>>> Cc: Eli Zaretskii , 69941@debbugs.gnu.org, >>>> Stefan Monnier >>>> From: Mauro Aranda >>>>=20 >>>> > To fix this bug, do you have a preference between this patch for >>>> > widget-specify-inactive and the attached patch for >>>> > widget-default-create?=C2=A0 Or do you have a better fix? >>>> > >>>> > Steve Berman >>>>=20 >>>> I don't really have a better fix.=C2=A0 I mean, ideally, we'd find the= reason >>>> why the setting behaves differently for the radio-button-choice widget, >>>> and only for the first one in a radio widget, as it seems to me. But >>>> I'll need more time to be able to look into that. >>>>=20 >>>> That said, if Eli is OK with installing a minor hack (with a FIXME, >>>> please), I don't have problems.=C2=A0 And since it's a hack (and hopef= ully >>>> temporary), it's better if we keep it at widget-default-create then. >>> >>> My opinion doesn't matter much in this case. If you two agree on a >>> solution, feel free to install it, even if it is not 110% clean. >> >> I've been using the patch for for widget-specify-inactive in an >> application I'm developing that exercises radio-button-choice widgets, >> but I'll switch to using the patch for widget-default-create instead. >> I've been encountering inconsistent behavior in combination with the use >> of widget-unselected face that I haven't tracked down the cause of yet. >> I don't expect using the patch for widget-default-create will improve >> this issue, but I'll find out. I also plan to test that patch in >> combination with widget-unselected face with checklist widgets, which my >> application currently does not use. I'll report back here before >> committing the patch for widget-default-create (or something else, >> depending on the outcome of further testing). > > Just a brief status report: My testing does indeed indicate that the > fontification problem with radio-button-choice also occurs with > checklist widgets, though the pattern appears not to be identical; I > need to do more testing and debugging. Further testing confirms that checklists are subject to this problem, so I've added them to the attached patch. The rest of this post reports results from and speculations based on my debugging efforts, which remain somewhat inconclusive. According to my tests, checklists and radio-button-choice widgets do indeed display the same problem with the first checkbox or radio-button, respectively: if it's selected and then the parent widget is deactivated, then the button/checkbox incorrectly does not have widget-inactive face. I think the reason for this is that selecting inserts "[X]" for the checkbox and "(*)" for the radio-button, and since the parent widget's :from property has marker insertion type `t', its position advances to after the insertion (I guess this is because the starting position of the first checkbox/button coincides with the parent widget's :from), so the overlay with the widget-inactive face beginning at :from does not cover the checkbox/button. But checklists and radio-button-choice widgets differ when a non-initial checkbox/button is selected. With checklists, multiple checkboxes can be selected, and selecting the second checkbox does not advance the parent widget's :from position, unlike with radio-button-choice widget's when selecting the second radio-button, as I reported in my OP. I think this is because in radio-button-choice widgets only one radio-button can be selected, so selecting any one triggers the :from marker's advancing. I could not verify this hypothesis through debugging because I was unable to find out exactly when this happens. The marker advance is done in the C code, I think at adjust_markers_for_insert in insdel.c; I set a gdb breakpoint there and this triggers when I select a radio button, but it's too early: a lot happens in wid-edit.el between selecting a button and the selection becoming visible, and the breakpoint triggered so often that I gave up. Is there a way to make a breakpoint in the C code trigger only when a specific part of wid-edit.el is evaluated? Nevertheless, by assigning the :from marker the insertion type nil in widget-default-create when the widget is either a checklist or radio-button-choice, does result in the correct fontification of the first checkbox/radio-button in all tests I've conducted with varying the selection. And conceptually it seems to me correct that :from should not advance with these widgets: selecting a checkbox or button is operationally quite different from inserting text (e.g. in an editable-field widget), even though the implementation technically involves insertion. So I think the attached patch is at least a viable stopgap, until a better (or at least less ad hoc) fix is found. Steve Berman --=-=-= Content-Type: text/x-patch Content-Disposition: attachment Content-Description: widget-default-create patch diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el index dc481d4d0a5..9304002ff52 100644 --- a/lisp/wid-edit.el +++ b/lisp/wid-edit.el @@ -1757,8 +1757,16 @@ 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)) + ;; Advancing the `:from' marker of a checklist or + ;; radio-button-choice widget on selecting a checkbox or a + ;; radio-button, which inserts "[X]" or "(*)", can result in + ;; misfontifying the first checkbox (bug#69941). To ensure + ;; correct fontification, assign `:from' the marker insertion + ;; type `nil', so it does not advance. + (from-mit (not (memq (widget-type widget) + '(checklist radio-button-choice))))) + (set-marker-insertion-type from from-mit) (set-marker-insertion-type to nil) (widget-put widget :from from) (widget-put widget :to to))) --=-=-=--