From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#73911: Issue with `widget-specify-button' Date: Sat, 14 Dec 2024 11:35:59 +0200 Message-ID: <86zfkyvc74.fsf@gnu.org> References: <075599db-7d78-4475-aa71-daba0e06cf9e@orange.fr> <864j4pzwxx.fsf@gnu.org> <86bjyfguns.fsf@gnu.org> <861pyt9hdo.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31121"; mail-complaints-to="usenet@ciao.gmane.io" Cc: da_vid@orange.fr, 73911@debbugs.gnu.org To: maurooaranda@gmail.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Dec 14 10:37:16 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 1tMOaJ-0007vO-GK for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 14 Dec 2024 10:37:15 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tMOa9-0001Ki-5L; Sat, 14 Dec 2024 04:37:05 -0500 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 1tMOa7-0001KT-Az for bug-gnu-emacs@gnu.org; Sat, 14 Dec 2024 04:37:03 -0500 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 1tMOa7-0000VU-2a for bug-gnu-emacs@gnu.org; Sat, 14 Dec 2024 04:37:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=5UOpZvQ4KtIMZgG9kkdQ6O5sqYAdVT7DGKXSMuHvDi4=; b=KKXEIXjoZWA9qitpQLyM0FuFHFGl/eaQ6nD5Vpt8KvURJd2tOQiOuDbZisPT/nWeIC9l0AYEzU5j7kx7cKeO5DfQxi2EGoqVMEA9QJLg9zn3Ug9heLkZFnq2zRVbW1X3zgcfoJIn9J00iLkBK7Rv2AtXk9ENy1TGUDWWIN6Xe0ieBZzCMjnCxC2FiOoWgBM8egR6MgQzdtAd+mb8cq7RNRILjaJ61rHbqA0uD22yEzrzuYBwq/97yeA0PhCYeokPEGZzKFaiUS3niGcT0Hb4WTrL1Qnmv0kiAmHk6TWJ0bbJdeqlBDb6fryXhBHaubpD04YICN/ur0cdtgFqz9vsQA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tMOa5-0006jh-UT for bug-gnu-emacs@gnu.org; Sat, 14 Dec 2024 04:37:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 14 Dec 2024 09:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73911 X-GNU-PR-Package: emacs Original-Received: via spool by 73911-submit@debbugs.gnu.org id=B73911.173416897325823 (code B ref 73911); Sat, 14 Dec 2024 09:37:01 +0000 Original-Received: (at 73911) by debbugs.gnu.org; 14 Dec 2024 09:36:13 +0000 Original-Received: from localhost ([127.0.0.1]:45464 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tMOZJ-0006iR-7S for submit@debbugs.gnu.org; Sat, 14 Dec 2024 04:36:13 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:35160) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tMOZE-0006hs-7m for 73911@debbugs.gnu.org; Sat, 14 Dec 2024 04:36:11 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tMOZ8-0000R2-7m; Sat, 14 Dec 2024 04:36:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=5UOpZvQ4KtIMZgG9kkdQ6O5sqYAdVT7DGKXSMuHvDi4=; b=ReiF84zO7l5l duhEPVpyzh9NlfzByfttyTf3vi3WJLo+Jkta7B35TbuyWt09i7ClZDWcd/bybdSulr9JJKSinZd/6 J8lCP6iPMyeZ4cCRyafbNnkktLYOwj5MzifINfQir3stHGol2RtKS6jQgEtXlfOPJOI6ljC+UeWgC dW4Ljqp2m5/2zC1wqRuxwua1o3/xgiN5z+6tkJV1Xr+N9YYeWUPlDRDcBB/3s45ierX8LoIHZJrPE 75IgQ7eLemUIqkOkkk9+y496zs7E1Ur5bYdrWIreHNdd4QYP+xkMbFpsOnlS7fFJNMU+/myfpZKrq NxdPZeZfP60cx581FABzhg==; In-Reply-To: <861pyt9hdo.fsf@gnu.org> (message from Eli Zaretskii on Sat, 30 Nov 2024 11:54:11 +0200) 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:297021 Archived-At: Ping! Ping! Mauro, please respond. > Cc: da_vid@orange.fr, 73911@debbugs.gnu.org > Date: Sat, 30 Nov 2024 11:54:11 +0200 > From: Eli Zaretskii > > Ping! Ping! Mauro, are you there? > > > Cc: da_vid@orange.fr, 73911@debbugs.gnu.org > > Date: Sat, 16 Nov 2024 15:44:39 +0200 > > From: Eli Zaretskii > > > > Ping! Mauro, could you please respond? > > > > > Cc: 73911@debbugs.gnu.org > > > Date: Sat, 02 Nov 2024 13:39:38 +0200 > > > From: Eli Zaretskii > > > > > > > Date: Sun, 20 Oct 2024 15:01:47 +0200 > > > > From: David Ponce via "Bug reports for GNU Emacs, > > > > the Swiss army knife of text editors" > > > > > > > > I found that `widget-specify-button' produces unexpected result when > > > > button prefix string has a space (and maybe others) display > > > > properties. > > > > > > > > To illustrate the issue with emacs -Q, evaluate the below code in the > > > > *scratch* buffer: > > > > > > > > (require 'wid-edit) > > > > (let* ((thin-space (propertize " " 'display '(space :width 0.5))) > > > > (widget-push-button-prefix thin-space) > > > > (widget-push-button-suffix thin-space)) > > > > (widget-create 'push-button > > > > :notify #'ignore > > > > :button-face '( ;;:background "lightgrey" > > > > :box t) > > > > ;;:suppress-face t > > > > "OK") > > > > (insert "\n")) > > > > > > > > I found that the culprit is the invisible space that > > > > `widget-specify-button' puts at the beginning of the button (no idea > > > > why) using a 'before-string overlay property, at line 467: > > > > > > > > (overlay-put overlay 'before-string #(" " 0 1 (invisible t))) > > > > > > > > Giving this invisible space the same face property as the rest of the > > > > button fixed the issue for me. This is what I propose in the below > > > > patch. With this fix the above test will give the expected result. > > > > > > > > Thanks > > > > > > > > diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el > > > > index 1d47f80b0dd..fd1747d3562 100644 > > > > --- a/lisp/wid-edit.el > > > > +++ b/lisp/wid-edit.el > > > > @@ -460,17 +460,20 @@ widget-specify-button > > > > "Specify button for WIDGET between FROM and TO." > > > > (let ((overlay (make-overlay from to nil t nil)) > > > > (follow-link (widget-get widget :follow-link)) > > > > - (help-echo (widget-get widget :help-echo))) > > > > + (help-echo (widget-get widget :help-echo)) > > > > + (face (unless (widget-get widget :suppress-face) > > > > + (widget-apply widget :button-face-get)))) > > > > (widget-put widget :button-overlay overlay) > > > > (when (functionp help-echo) > > > > (setq help-echo 'widget-mouse-help)) > > > > - (overlay-put overlay 'before-string #(" " 0 1 (invisible t))) > > > > + (overlay-put overlay 'before-string > > > > + (propertize " " 'invisible t 'face face)) > > > > (overlay-put overlay 'button widget) > > > > (overlay-put overlay 'keymap (widget-get widget :keymap)) > > > > (overlay-put overlay 'evaporate t) > > > > ;; We want to avoid the face with image buttons. > > > > - (unless (widget-get widget :suppress-face) > > > > - (overlay-put overlay 'face (widget-apply widget :button-face-get)) > > > > + (when face > > > > + (overlay-put overlay 'face face) > > > > (overlay-put overlay 'mouse-face > > > > ;; Make new list structure for the mouse-face value > > > > ;; so that different widgets will have > > > > > > Thanks. > > > > > > Mauro, any comments? > > > > > > > > > > > > > > > > > > > > > > > >