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, 22 Mar 2024 15:45:42 +0100 Message-ID: <87h6gynx49.fsf@rub.de> 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="23381"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: 69941@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Mar 22 16:00:48 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 1rngO0-0005rX-Ji for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 22 Mar 2024 16:00:48 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rngNj-0002uE-VB; Fri, 22 Mar 2024 11:00:31 -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 1rngNd-0002tN-03 for bug-gnu-emacs@gnu.org; Fri, 22 Mar 2024 11:00:28 -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 1rngNZ-00079o-Ka for bug-gnu-emacs@gnu.org; Fri, 22 Mar 2024 11:00:23 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rngOE-0001eZ-3z for bug-gnu-emacs@gnu.org; Fri, 22 Mar 2024 11:01:02 -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, 22 Mar 2024 15:01:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 69941 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.17111196116159 (code B ref -1); Fri, 22 Mar 2024 15:01:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 22 Mar 2024 15:00:11 +0000 Original-Received: from localhost ([127.0.0.1]:58670 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rngNO-0001bG-RX for submit@debbugs.gnu.org; Fri, 22 Mar 2024 11:00:11 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:60984) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rngNK-0001Xf-E8 for submit@debbugs.gnu.org; Fri, 22 Mar 2024 11:00:09 -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 1rng9T-0004sX-3B for bug-gnu-emacs@gnu.org; Fri, 22 Mar 2024 10:45:49 -0400 Original-Received: from mout.gmx.net ([212.227.15.19]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rng9R-0003jY-4T for bug-gnu-emacs@gnu.org; Fri, 22 Mar 2024 10:45:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1711118743; x=1711723543; i=stephen.berman@gmx.net; bh=9HnrS87+V75EG/mi/0+z2oI2w28pTBuld2yM4V3Qox8=; h=X-UI-Sender-Class:From:To:Subject:Date; b=Gft1R80KTQiBRe311sniDocD6FJpZZmqzmrRE6nBdsUiLqe6T1KHiVVOJ5s0iXML s/nxxR+qCX3Uq85anL0JHbHzyOQazmodky27Uj0bXus4MBy9YMMlM+m6eCiRKVdYI HCXI6k6t7BOwQDRpMCLzOx+dL4r9iqWZyTzXKbK/2rH0+SOzQkECbGhdOEt4UH3en 6yxRj20vimXxfmRVnBwU7fLaUOlIMMNfBj1wVqKs7Dg+bDgNsdYMftnV4Y7Sw8f6O jv+W2dyxnV8lapJg6/S1Lmp8iN5xFhS924Li+XRUbAVpfRPDT8D/bWLSTsAj9mdXp +Ptj3GMRBr3RylWSPA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from strobelfs2 ([88.130.50.228]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N8ob6-1qj5VJ1ft8-015sjs for ; Fri, 22 Mar 2024 15:45:43 +0100 X-Provags-ID: V03:K1:r3Wjr09sdLqkknsiYCL5cGFHCX/DGR3vBs470dPAA5Xys7FM1tx aBsERhAzhM8KTAtbPuUaotMhc1HLikZ4XOH2YNIm9mI3sIu9AIhnpEowLox4ybrqU4aw5hn imvdCmtcenBR6UQYbh9I3gHQ5iGdjyGz8DDc6LrrrLakOICcJtAootRxdmnC9usQuVLmgCS RnPB2AgGwskcNS+dg2sfw== UI-OutboundReport: notjunk:1;M01:P0:zOlArsquE3M=;+A0VjoyWeOC5R7oyOJRwiQ7mVao a2YXFlf+dW+kAj2SsayzTkzooqCwg1bbDha5516sOc59XLaWLPkdEIs8d1CculuUYgY4a9U6H DRNWLtFJlW0tDTP8A13lD1pzNAeR13v8N4GwXP7HIdLLE8W/3d6RhxU/GFKJ8OrvQGS/ZTuFC yOT32ZWzvASgVYHkGz66nKn+Yt3ynA/Z2tM+nA1EPZDvqAs4MOrGDYC7VYDldYPwMVSCTd2qN 82GPgipsVufxqlXtfNOXaPSTilIgk8lXV69KiRTo2MzHFW8S42PWXX+VYQs3rEUhLSzOSYMcL X1sLCTM7LktGuuhAqYRU1Zkg1ko4wSbRgd5p7ceSuHAK5kDrsLg1VjMv0T3nnh2hOF5YB4EKY qHYiw5PJgeyJloK9qQR1s6K3D2TAz6ogLiCO0VAhdhtKnK79YhiWRN2Twop1rQnG0LSscoNWf +N1UeALGdJTsIVbNv1VSQN/tGsn/2dtJgtU/4GLHH/zhqw+Ju7NAM7+QScoUgCIUW0fXjydYY SNkUPKtxlJjQYWeSvdF5UUP4qNmFs0Gn2QMzLLionwE1dOknp4RKP+NvxzZffx4eka+XMWckg ZAfcx55ABOxb+dLRFLTGSwleZ6GgVBpT0xl4iWgNLtSgaGiF7ji0uhLk5AsnU/zp02Mw25Nhb 2kzPrAsdwbfHfr9XRD0izJrkQILynjP5YA5GH+UFNItLLb2egtZduj0MNbKekk1HK/r0TYwp6 FnKBvR6QeF/ZNpB6sVC/sncx8E+P2FtWf7ZvXj+I30gHa9t7DqSNb1DcD9wHS3s+2Bx2iwGs Received-SPF: pass client-ip=212.227.15.19; envelope-from=stephen.berman@gmx.net; helo=mout.gmx.net X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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:281942 Archived-At: --=-=-= Content-Type: text/plain 0. Save the following code (attached here to circumvent line breaks added by the mail program) as widget-example.el: --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=widget-example.el Content-Transfer-Encoding: quoted-printable (custom-set-faces '(widget-inactive ((t (:foreground "magenta" :background "yellow"))))) (defvar my-radio-widget) (defvar my-activate-button) (defun my-widget-example () (interactive) (switch-to-buffer "*My Widget Example*") (kill-all-local-variables) (let ((inhibit-read-only t)) (erase-buffer)) (remove-overlays) (setq my-radio-widget (widget-create 'radio-button-choice :notify (lambda (widget &rest _) (widget-apply widget :deactivate) (widget-apply my-activate-button :activate)) '(item "One") '(item "Two"))) (setq my-activate-button (widget-create 'push-button :notify (lambda (widget &rest _) (widget-value-set my-radio-widget "") (widget-apply my-radio-widget :activate) (widget-apply widget :deactivate)) "Activate")) (widget-apply my-activate-button :deactivate) (use-local-map widget-keymap) (widget-setup)) --=-=-= Content-Type: text/plain 1. emacs -Q -l widget-example.el 2. M-x my-widget-example In the buffer "*My Widget Example*" it easy to see (due to value of the widget-inactive face set in widget-example.el) that the push-button widget "Activate" is inactive and the radio-button widgets labelled "One" and "Two" are active (the buttons have the default face; that the labels next to the buttons have the widget-inactive face may seem odd, but that's not the bug I'm reporting here; I address that issue in a separate bug report). 3. Press TAB (or S-TAB) twice to put point on the radio button "Two", then press RET. As the fontification shows, now both radio buttons are inactive (so pressing RET on either raises the error "Attempt to perform action on inactive widget"), and the "Activate" button is now active. After tabbing to the "Activate" button and pressing RET, the initial state is restored, with the two radio buttons active and "Activate" inactive. 4. Now tab up to the radio buttone "One" and press RET. => While radio button "Two" agains has the widget-inactive face, radio button "One" (just the button, not its label) has the default face used for active widgets, though it is in fact inactive (as pressing RET and getting the corresponding error verifies). 5. Tab back to "Activate" and press RET, again restoring the initial state. Now tab to radio button "Two" and press RET. => The fontification is the same as in step 4: radio button "Two" has the widget-inactive face but radio button "One" has the default (active) face, though it is again inactive. Repeatedly pressing either of the radio buttons (after activating them), does not change the fontification of "One" again. The faulty fontification of radio button "One" also obtains if there is just one radio button instead of two, and if there are more than two radio buttons, it is only the first one that displays the odd fontification (admittedly, I've only test up to three radio buttons). I've tried to debug this and found that the problem seems to be due to the sexp (set-marker-insertion-type from t) near the end of widget-default-create, which advances the marker specified by the widget's :from property. Changing t to nil fixes the faulty fontification of the first radio button. I investigated the history of this code, and while the value t for the marker insertion type was used in the initial commit, it was changed to nil in commit e0f956935, with the message "Insert new text at the :from marker _after_ the marker, not before it." But 18 days later it was changed back to t in commit 3bff434b8, that also added "Document need to put some text before the %v escape in :format string" of editable-field widgets. (I looked at the bug-gnu-emacs and emacs-devel mailing list archives but found nothing relevant at the time just prior to these commits.) So evidently the advancing marker insertion type is needed for at least some widgets, though it seems to be problematic for radio buttons. So I tried to conditionalize the choice of t or nil on the type of the widget. I used (not (eq 'radio-button (widget-type widget))), since the argument `widget' of widget-default-create is, according to Edebug, indeed radio-button, so negating the eq sexp returns nil, which I had found to be the value of the marker insertion type that fixes the fontification (however, I couldn't think of a way of limiting the conditioning to only the first radio button, but in my testing so far that lack doesn't appear to make a difference). But in fact, using the negation of the value of the eq sexp results in the same faulty fontification, while omitting the negation (as in the attached patch), which yields the advancing insertion type t, gives the correct fontification, just like using nil does. This makes no sense to me, yet it is reliably reproducible. The only possible explanation that occurs to me is that the bug is triggered elsewhere in the Emacs code and somehow using the sexp that evaluates to t as the marker insertion type affects that code, while using t itself does not (or rather, has the opposite effect); but how that could be and where the culpable code is, I don't know (as a guess, perhaps in the C code that adds faces, but I don't know how to debug that). If anyone knows or has an idea what's going on here, please communicate it. In the meantime I will continue to use the widget library with the patch to see whether it has unwanted consequences. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=widget-default-create.diff diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el index 172da3db1e0..c2cd48e1551 100644 --- a/lisp/wid-edit.el +++ b/lisp/wid-edit.el @@ -1733,8 +1733,9 @@ 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)) + (from-mit (eq 'radio-button (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))) --=-=-= Content-Type: text/plain In GNU Emacs 30.0.50 (build 3, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version 1.18.0) of 2024-03-22 built on strobelfs2 Repository revision: c1530a2e4973005633ebe00d447f1f3aa1200301 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12101009 System Description: Linux From Scratch r12.0-112 Configured using: 'configure -C --with-xwidgets 'CFLAGS=-Og -g3' PKG_CONFIG_PATH=/opt/qt5/lib/pkgconfig' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM XWIDGETS GTK3 ZLIB --=-=-=--