From: Mauro Aranda <maurooaranda@gmail.com>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: dieter@duenenhof-wilhelm.de, 25678@debbugs.gnu.org,
Noam Postavsky <npostavs@gmail.com>,
tim@tim-landscheidt.de
Subject: bug#25678: 25.1; defcustom type `(file :must-match t)' seems not to work
Date: Wed, 9 Sep 2020 14:21:11 -0300 [thread overview]
Message-ID: <CABczVwe9ZfTO6ymJTL45g0+4yECsuJUgWXo-aWqwZ0D49hNToQ@mail.gmail.com> (raw)
In-Reply-To: <87pn78s0e6.fsf@gnus.org>
[-- Attachment #1.1: Type: text/plain, Size: 805 bytes --]
Lars Ingebrigtsen <larsi@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.
>
> [...]
>
>> + :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.
[-- Attachment #1.2: Type: text/html, Size: 1096 bytes --]
[-- Attachment #2: 0001-Fix-match-function-for-the-file-widget.patch --]
[-- Type: text/x-patch, Size: 1064 bytes --]
From d6abe15da5ff39996ab4f5ebfbc3428e92017452 Mon Sep 17 00:00:00 2001
From: Mauro Aranda <maurooaranda@gmail.com>
Date: Wed, 9 Sep 2020 14:11:49 -0300
Subject: [PATCH] Fix :match function for the file widget
* lisp/wid-edit.el (file widget): Return nil if value is not a
string. (Bug#25678)
---
lisp/wid-edit.el | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index e9799dc00f..bc2afc6a6f 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -3162,8 +3162,9 @@ 'file
#'completion-file-name-table
(not read-file-name-completion-ignore-case))
:match (lambda (widget value)
- (or (not (widget-get widget :must-match))
- (file-exists-p value)))
+ (and (stringp value)
+ (or (not (widget-get widget :must-match))
+ (file-exists-p value))))
:validate (lambda (widget)
(let ((value (widget-value widget)))
(unless (widget-apply widget :match value)
--
2.28.0
next prev parent reply other threads:[~2020-09-09 17:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-10 18:32 bug#25678: 25.1; defcustom type `(file :must-match t)' seems not to work Drew Adams
2017-02-17 23:57 ` npostavs
2018-01-14 23:07 ` Tim Landscheidt
2020-03-21 17:36 ` H. Dieter Wilhelm
2020-08-29 15:33 ` Mauro Aranda
2020-08-30 13:56 ` Lars Ingebrigtsen
2020-08-30 15:22 ` Mauro Aranda
2020-09-09 17:21 ` Mauro Aranda [this message]
2020-09-10 13:13 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CABczVwe9ZfTO6ymJTL45g0+4yECsuJUgWXo-aWqwZ0D49hNToQ@mail.gmail.com \
--to=maurooaranda@gmail.com \
--cc=25678@debbugs.gnu.org \
--cc=dieter@duenenhof-wilhelm.de \
--cc=larsi@gnus.org \
--cc=npostavs@gmail.com \
--cc=tim@tim-landscheidt.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).