From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mauro Aranda Newsgroups: gmane.emacs.bugs Subject: bug#63838: 28.2; 'wid-edit.el' problems with 'integer' (and 'sexp') widgets. Date: Sun, 16 Jul 2023 08:50:28 -0300 Message-ID: <174623a9-45bf-10d1-8b59-cb5b816026bc@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21353"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Cc: 63838@debbugs.gnu.org To: Marco Antoniotti Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jul 16 13:51:26 2023 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 1qL0He-0005PE-Dx for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 16 Jul 2023 13:51:26 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qL0HI-0002oF-IH; Sun, 16 Jul 2023 07:51:04 -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 1qL0HH-0002nv-5y for bug-gnu-emacs@gnu.org; Sun, 16 Jul 2023 07:51:03 -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 1qL0HG-0008LU-Un for bug-gnu-emacs@gnu.org; Sun, 16 Jul 2023 07:51:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qL0HG-0008UG-K6 for bug-gnu-emacs@gnu.org; Sun, 16 Jul 2023 07:51:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Mauro Aranda Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 16 Jul 2023 11:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63838 X-GNU-PR-Package: emacs Original-Received: via spool by 63838-submit@debbugs.gnu.org id=B63838.168950824332578 (code B ref 63838); Sun, 16 Jul 2023 11:51:02 +0000 Original-Received: (at 63838) by debbugs.gnu.org; 16 Jul 2023 11:50:43 +0000 Original-Received: from localhost ([127.0.0.1]:46975 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qL0Gx-0008TO-9u for submit@debbugs.gnu.org; Sun, 16 Jul 2023 07:50:43 -0400 Original-Received: from mail-oa1-x32.google.com ([2001:4860:4864:20::32]:48384) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qL0Gt-0008T9-HJ for 63838@debbugs.gnu.org; Sun, 16 Jul 2023 07:50:41 -0400 Original-Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-1b06da65bdbso2701015fac.1 for <63838@debbugs.gnu.org>; Sun, 16 Jul 2023 04:50:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689508233; x=1692100233; h=content-transfer-encoding:subject:from:cc:to:content-language :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=2W4AW/cMS89SKdHvzaPHhwuA0qRpfsgdb/OMEdnHtdg=; b=C/WH72Vdkz4nbuqMrMWPIvLV6lcoOOe0tIhR4ORuDGdGn35ncd3ISewhi6onHESiyX b45zz8BYhZZ53SHKctTNdWbtx3XaGMo9vUnHw80Vey7ZYeNGRjilhUqi9Q6hHwjo4Hi0 gYR8N97WgK0tcjCvlglqok/+NQXQ02lxOtcWxOliNb73w05hLX1LQAijC2jMK+Kxj4rJ xjAVxeJQwsnBF3kdrDoF+ohaVtXvpXySFPOpmq6Y7cmBp79JGg/BsVn3gnJnrPiG0rZU mA53JV25V5ykYk92Vo35gpqPdbWQSRmeAXJOIASSnko14b3mKLfQrKWIb7g5C8RdwKKw 0Q3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689508233; x=1692100233; h=content-transfer-encoding:subject:from:cc:to:content-language :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=2W4AW/cMS89SKdHvzaPHhwuA0qRpfsgdb/OMEdnHtdg=; b=REcg9Mfyf9TIuOvwGt7DpIMB2SMGpGeILYPmeH+9grCEtMqqFndztu77rRnn9SO3Fi MtiX/ZPFNd/KpPPW29eBdg3Pmwisfp2jRDOHWLzwc+T9oMgaJUAv79cPa9IUQx8fVvBX gc3Diwc2W3hqfDIvMlMX8ci85M/GjEem9dYfnO/9TCu9HXN+cyHsD4T8tlSjxIFUISKH nVhffC99gHK+5gLWRdG+qWrSS90Ih9oT/Y70VjUWeVlQJmsqS3fX08sOG0j85jldfgoH gIjQZDX9DlWze/z0sSNxmedzvr5pXLY1q50Lix0nDGUJvO4Ac+jtLCx6+cGY1j2CUSZu 1Rgw== X-Gm-Message-State: ABy/qLZ2vOkKg4pI/NJS/+JB6M1Iav7tsHaEpYm9hwYH3doSeoPeBVtW n1dCzviIF8vQJvtr6D+cZYk= X-Google-Smtp-Source: APBJJlEWaD7KSYpnAQatCMaWMfnOYhXA2t80NKOBdvEgJ+Rrn2EY/AUlpCGyu30tosm9EW+Bh3MKtg== X-Received: by 2002:a05:6870:b616:b0:1b0:3e54:948 with SMTP id cm22-20020a056870b61600b001b03e540948mr9970376oab.37.1689508233648; Sun, 16 Jul 2023 04:50:33 -0700 (PDT) Original-Received: from [192.168.0.234] ([186.127.128.249]) by smtp.gmail.com with ESMTPSA id p5-20020a056870868500b0019ea8771fb0sm6031836oam.13.2023.07.16.04.50.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 16 Jul 2023 04:50:33 -0700 (PDT) Content-Language: en-US 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:265320 Archived-At: Marco Antoniotti writes: > Hi Thanks for the bug report! > The issue is with the following code that tries to use the Widget > library.  The slots of the widget are actually not necessary to see the > problem. > >  (widget-create 'integer >                 :help-echo "Enter an integer..." >                 :notify (lambda (w1 &rest ws) >                            (ignore ws) >                            (message "WIFT: IF: %s" >                                     (widget-value w1) >                            )) >                 :size 4 >   ) The :notify value is kind of necessary, right? I mean, the bug doesn't manifest as long as code doesn't try to access the value of a restricted-sexp widget while its empty. > Specializing the widget with a hack like the function below fixes the > problem, but a > good solution may need some more work to get all the corner cases. > Note that setting a "widget buffer" in overwrite mode goes a long way to > mitigate these problems: maybe having widget-setup switch to it would > be another good thing to do. I don't think we want to do that. >  :value-to-external >   (lambda (widget value) >     ;; Lifted, and fixed, from `:value-to-external' in >     ;; `restricted-sexp'. > >     (unless (stringp value) >       (display-warning >        'widget-bad-default-value >        (format-message >         "\nA widget of type %S has a bad default value. > value: %S > match function: %S > match-alternatives: %S" >         (widget-type widget) >         value >         (widget-get widget :match) >         (widget-get widget :match-alternatives)) >        :warning)) >     (if (and (stringp value) (string-equal "" value)) >         ;; Oooops, we cannot just `read'. >         (widget-get widget :default-value) >       (read value)) >     ) I don't think this is a good place to do this.  And there's no :default-value property in the widget library, just :value. I think it'd be much better if we specialize the :value-get function for the restricted-sexp widget, defaulting to return :value when the widget is empty.