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#25678: 25.1; defcustom type `(file :must-match t)' seems not to work Date: Wed, 9 Sep 2020 14:21:11 -0300 Message-ID: References: <77a3abe9-258c-4863-a87d-2f236babafe4@default> <87pn78s0e6.fsf@gnus.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="00000000000056940205aee4ae95" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7530"; mail-complaints-to="usenet@ciao.gmane.io" Cc: dieter@duenenhof-wilhelm.de, 25678@debbugs.gnu.org, Noam Postavsky , tim@tim-landscheidt.de To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Sep 09 19:22:11 2020 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 1kG3nO-0001rv-UR for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 09 Sep 2020 19:22:11 +0200 Original-Received: from localhost ([::1]:51230 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kG3nN-00062H-VX for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 09 Sep 2020 13:22:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43892) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kG3nG-00060k-Gs for bug-gnu-emacs@gnu.org; Wed, 09 Sep 2020 13:22:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49872) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kG3nG-0007v0-7k for bug-gnu-emacs@gnu.org; Wed, 09 Sep 2020 13:22:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kG3nG-0008Mq-2h for bug-gnu-emacs@gnu.org; Wed, 09 Sep 2020 13:22:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mauro Aranda Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 09 Sep 2020 17:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25678 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed Original-Received: via spool by 25678-submit@debbugs.gnu.org id=B25678.159967209132128 (code B ref 25678); Wed, 09 Sep 2020 17:22:02 +0000 Original-Received: (at 25678) by debbugs.gnu.org; 9 Sep 2020 17:21:31 +0000 Original-Received: from localhost ([127.0.0.1]:33185 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kG3ml-0008M8-Hh for submit@debbugs.gnu.org; Wed, 09 Sep 2020 13:21:31 -0400 Original-Received: from mail-wr1-f67.google.com ([209.85.221.67]:46952) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kG3mk-0008Lv-5Z for 25678@debbugs.gnu.org; Wed, 09 Sep 2020 13:21:30 -0400 Original-Received: by mail-wr1-f67.google.com with SMTP id o5so3769124wrn.13 for <25678@debbugs.gnu.org>; Wed, 09 Sep 2020 10:21:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lGXxNnwxDMyiXocPiSfV+7T/7Mm6vIis77jvx8QFFCk=; b=MWKwfRf1uWHKrCLKubzlnql1EdHab/y9YXCEMpU2a5sSTUNDdLo2SfqhJwO402afm7 qYkqBZfOsF4b8OFk1jPWpJmE3XTIr8NCeTZWylgXWibP1S0B5YhJRsoasiPxQBp2KfYV MOnXosMZt3ea6JHQ+pr4yMDFEWi+bkxnHDwaap9Zpb3WqAbpd4sCV6BKFErdBUvPlzCP kVkAmjylwb6K5+IEkTcc9kzoh9ul77bpivGxMdhE1ZZoUWulyNZSnywOFCZkVzVy5uvo ml8aSUvpdHb4Cx+PEEL4slo+f8cA97JQo1RxGBPJW7kmSbWTSgEVjNE346RS/Oo8XUSa lulA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=lGXxNnwxDMyiXocPiSfV+7T/7Mm6vIis77jvx8QFFCk=; b=CZcEIea+/5RFz7kukLTnP1ZZ6Cbh8vLam2o2jaTAgd1Nw9pplwpeYz7FmWlouCojd0 Wn/l/Ra732D18jTZdaIHpavwvkMJSUPxh3qksR5bcKydQ8b/+/1OY8b4zl5zCAwI5ITp vQrk5I2lwyKMekWaI01XFkfTl2hx8W18tDT5c2ws+RinBowaInpRhAfyZ+lqb8UZX2cE mmcLE4lBvrQ4EalrNea4SwFRwoix0noLm251sOt8ibd1BTuUVlaO5QRDDyiR7r7EaFtp OeUe04JtN06/kxVm9344684SPqRSZpG/y/LOuWf1nTpPFl/R9LkX/U7U8ifQGgVJCusz weQg== X-Gm-Message-State: AOAM532/EhNXSyXKlttwZdN7gqoX5fBX5fvNGzmm+lOab+ATRS1lXSfi 0/9H2LVNWpVveoHcbso/lLfL8hl9wOf8uFaN2ao= X-Google-Smtp-Source: ABdhPJwuBIfg7TT6pk6q3LSkcFNxq0cHBdGih5WutcImNxDI/A+oBzt+p1C0rCpbBLTV/DXjqRtjoifMuPxey/s/Ec8= X-Received: by 2002:adf:9f10:: with SMTP id l16mr5216988wrf.77.1599672084230; Wed, 09 Sep 2020 10:21:24 -0700 (PDT) In-Reply-To: <87pn78s0e6.fsf@gnus.org> 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" Xref: news.gmane.io gmane.emacs.bugs:187684 Archived-At: --00000000000056940205aee4ae95 Content-Type: multipart/alternative; boundary="00000000000056940005aee4ae93" --00000000000056940005aee4ae93 Content-Type: text/plain; charset="UTF-8" Lars Ingebrigtsen writes: > Mauro Aranda writes: > >> I think it makes sense to expand the impact of :must-match t to >> Customization buffers, like in the attached patch. > > [...] > >> + :match #'(lambda (widget value) >> + (or (not (widget-get widget :must-match)) >> + (file-exists-p value))) > > Makes sense to me. I've now applied this to Emacs 28 (but I removed the > #''s before the lambdas first (they're superfluous)). I found that the :match function will return false positives when :must-match is nil and value is not a string. This can happen is the defcustom is of type: :type '(choice file (const nil))), and the value is nil, because we check if nil matches with the widget file first. Here's a patch to fix it. --00000000000056940005aee4ae93 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Lars Ingebrigtsen <la= rsi@gnus.org> writes:

> Mauro Aranda <maurooaranda@gmail.com> writes:
>
= >> I think it makes sense to expand the impact of :must-match t to>> Customization buffers, like in the attached patch.
>
>= ; [...]
>
>> + =C2=A0:match #'(lambda (widget value)
= >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (or (not (widget-get w= idget :must-match))
>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 (file-exists-p value)))
>
> Makes sense to me.= =C2=A0 I've now applied this to Emacs 28 (but I removed the
> #&#= 39;'s before the lambdas first (they're superfluous)).

I fou= nd that the :match function will return false positives when
:must-match= is nil and value is not a string.=C2=A0 This can happen is
the defcusto= m is of type:
:type '(choice file (const nil))), and the value is ni= l, because we
check if nil matches with the widget file first.

He= re's a patch to fix it.


--00000000000056940005aee4ae93-- --00000000000056940205aee4ae95 Content-Type: text/x-patch; charset="US-ASCII"; name="0001-Fix-match-function-for-the-file-widget.patch" Content-Disposition: attachment; filename="0001-Fix-match-function-for-the-file-widget.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_kevnelsm0 RnJvbSBkNmFiZTE1ZGE1ZmYzOTk5NmFiNGY1ZWJmYmMzNDI4ZTkyMDE3NDUyIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBNYXVybyBBcmFuZGEgPG1hdXJvb2FyYW5kYUBnbWFpbC5jb20+ CkRhdGU6IFdlZCwgOSBTZXAgMjAyMCAxNDoxMTo0OSAtMDMwMApTdWJqZWN0OiBbUEFUQ0hdIEZp eCA6bWF0Y2ggZnVuY3Rpb24gZm9yIHRoZSBmaWxlIHdpZGdldAoKKiBsaXNwL3dpZC1lZGl0LmVs IChmaWxlIHdpZGdldCk6IFJldHVybiBuaWwgaWYgdmFsdWUgaXMgbm90IGEKICBzdHJpbmcuICAo QnVnIzI1Njc4KQotLS0KIGxpc3Avd2lkLWVkaXQuZWwgfCA1ICsrKy0tCiAxIGZpbGUgY2hhbmdl ZCwgMyBpbnNlcnRpb25zKCspLCAyIGRlbGV0aW9ucygtKQoKZGlmZiAtLWdpdCBhL2xpc3Avd2lk LWVkaXQuZWwgYi9saXNwL3dpZC1lZGl0LmVsCmluZGV4IGU5Nzk5ZGMwMGYuLmJjMmFmYzZhNmYg MTAwNjQ0Ci0tLSBhL2xpc3Avd2lkLWVkaXQuZWwKKysrIGIvbGlzcC93aWQtZWRpdC5lbApAQCAt MzE2Miw4ICszMTYyLDkgQEAgJ2ZpbGUKICAgICAgICAgICAgICAgICAjJ2NvbXBsZXRpb24tZmls ZS1uYW1lLXRhYmxlCiAgICAgICAgICAgICAgICAgKG5vdCByZWFkLWZpbGUtb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