GNU bug report logs - #25678
25.1; defcustom type `(file :must-match t)' seems not to work

Previous Next

Package: emacs;

Reported by: Drew Adams <drew.adams <at> oracle.com>

Date: Fri, 10 Feb 2017 18:33:02 UTC

Severity: normal

Tags: fixed

Found in versions 25.1, 26.3

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 25678 in the body.
You can then email your comments to 25678 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#25678; Package emacs. (Fri, 10 Feb 2017 18:33:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Drew Adams <drew.adams <at> oracle.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 10 Feb 2017 18:33:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.1; defcustom type `(file :must-match t)' seems not to work
Date: Fri, 10 Feb 2017 10:32:23 -0800 (PST)
(defcustom foo-file ""
  ""
  :type '(file :must-match t) :group 'convenience)

M-x customize-option foo-file

I don't see anything that prevents you from using a file name that
corresponds to no existing file.  I don't see that completion (`M-TAB') 
enforces it to name an existing file.  And I don't see that simply 
inserting a bad file name is prevented, nor is setting the option to a
bad file name or saving it prevented.

What effect does (file :must-match t) actually have, if any?

If this is just confusion on my part, please consider clarifying the
description of the behavior in the doc: (elisp) `Simple Types'.

(I see the same behavior if `(file :must-match t)' is used within a
complex type, e.g. as the :value-type of an alist entry.)


In GNU Emacs 25.1.1 (x86_64-w64-mingw32)
 of 2016-11-15
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --without-dbus --without-compress-install 'CFLAGS=-O2
 -static -g3''




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25678; Package emacs. (Fri, 17 Feb 2017 23:57:02 GMT) Full text and rfc822 format available.

Message #8 received at 25678 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 25678 <at> debbugs.gnu.org
Subject: Re: bug#25678: 25.1;
 defcustom type `(file :must-match t)' seems not to work
Date: Fri, 17 Feb 2017 18:57:56 -0500
Drew Adams <drew.adams <at> oracle.com> writes:

> (defcustom foo-file ""
>   ""
>   :type '(file :must-match t) :group 'convenience)
>
> M-x customize-option foo-file
>
> I don't see anything that prevents you from using a file name that
> corresponds to no existing file.  I don't see that completion (`M-TAB') 
> enforces it to name an existing file.  And I don't see that simply 
> inserting a bad file name is prevented, nor is setting the option to a
> bad file name or saving it prevented.
>
> What effect does (file :must-match t) actually have, if any?

It looks like `widget-file-prompt-value' consults it, but I can't tell
when this function is called.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25678; Package emacs. (Sun, 14 Jan 2018 23:08:02 GMT) Full text and rfc822 format available.

Message #11 received at 25678 <at> debbugs.gnu.org (full text, mbox):

From: Tim Landscheidt <tim <at> tim-landscheidt.de>
To: npostavs <at> users.sourceforge.net
Cc: 25678 <at> debbugs.gnu.org, Drew Adams <drew.adams <at> oracle.com>
Subject: Re: bug#25678: 25.1;
 defcustom type `(file :must-match t)' seems not to work
Date: Sun, 14 Jan 2018 23:07:12 +0000
AFAICT, this setting is only obeyed when executing M-x
customize-set-value RET foo-file RET.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25678; Package emacs. (Sat, 21 Mar 2020 17:37:02 GMT) Full text and rfc822 format available.

Message #14 received at 25678 <at> debbugs.gnu.org (full text, mbox):

From: dieter <at> duenenhof-wilhelm.de (H. Dieter Wilhelm)
To: Tim Landscheidt <tim <at> tim-landscheidt.de>
Cc: 25678 <at> debbugs.gnu.org, Drew Adams <drew.adams <at> oracle.com>,
 npostavs <at> users.sourceforge.net
Subject: Re: bug#25678: 25.1;
 defcustom type `(file :must-match t)' seems not to work
Date: Sat, 21 Mar 2020 18:36:07 +0100
Tim Landscheidt <tim <at> tim-landscheidt.de> writes:

> AFAICT, this setting is only obeyed when executing M-x
> customize-set-value RET foo-file RET.

Right, customize-set-value is working but Easy Customizations claims:

(info (emacs) Changing a Variable)

     [State]: SET for current session only.

 You don’t have to worry about specifying a value that is not valid; the
 ‘Set for Current Session’ operation checks for validity and will not
 install an unacceptable value.

Which is clearly not the case in Emacs-26.3

Thanky you

   Dieter

-- 
Best wishes
H. Dieter Wilhelm
Zwingenberg, Germany




bug Marked as found in versions 26.3. Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Sat, 21 Mar 2020 17:39:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25678; Package emacs. (Sat, 29 Aug 2020 15:34:02 GMT) Full text and rfc822 format available.

Message #19 received at 25678 <at> debbugs.gnu.org (full text, mbox):

From: Mauro Aranda <maurooaranda <at> gmail.com>
To: 25678 <at> debbugs.gnu.org
Cc: dieter <at> duenenhof-wilhelm.de, Noam Postavsky <npostavs <at> gmail.com>,
 Drew Adams <drew.adams <at> oracle.com>, tim <at> tim-landscheidt.de
Subject: Re: bug#25678: 25.1; defcustom type `(file :must-match t)' seems not
 to work
Date: Sat, 29 Aug 2020 12:33:15 -0300
[Message part 1 (text/plain, inline)]
I think it makes sense to expand the impact of :must-match t to
Customization buffers, like in the attached patch.
[Message part 2 (text/html, inline)]
[0001-Respect-must-match-for-file-types-in-customization-b.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25678; Package emacs. (Sun, 30 Aug 2020 13:57:01 GMT) Full text and rfc822 format available.

Message #22 received at 25678 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Mauro Aranda <maurooaranda <at> gmail.com>
Cc: dieter <at> duenenhof-wilhelm.de, 25678 <at> debbugs.gnu.org,
 Noam Postavsky <npostavs <at> gmail.com>, Drew Adams <drew.adams <at> oracle.com>,
 tim <at> tim-landscheidt.de
Subject: Re: bug#25678: 25.1; defcustom type `(file :must-match t)' seems
 not to work
Date: Sun, 30 Aug 2020 15:56:17 +0200
Mauro Aranda <maurooaranda <at> 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)).

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 30 Aug 2020 13:57:01 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 25678 <at> debbugs.gnu.org and Drew Adams <drew.adams <at> oracle.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 30 Aug 2020 13:57:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25678; Package emacs. (Sun, 30 Aug 2020 15:23:02 GMT) Full text and rfc822 format available.

Message #29 received at 25678 <at> debbugs.gnu.org (full text, mbox):

From: Mauro Aranda <maurooaranda <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: dieter <at> duenenhof-wilhelm.de, 25678 <at> debbugs.gnu.org,
 Noam Postavsky <npostavs <at> gmail.com>, Drew Adams <drew.adams <at> oracle.com>,
 tim <at> tim-landscheidt.de
Subject: Re: bug#25678: 25.1; defcustom type `(file :must-match t)' seems not
 to work
Date: Sun, 30 Aug 2020 12:22:34 -0300
[Message part 1 (text/plain, inline)]
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Mauro Aranda <maurooaranda <at> 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)).

Noted.  Thanks for taking the trouble!
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25678; Package emacs. (Wed, 09 Sep 2020 17:22:02 GMT) Full text and rfc822 format available.

Message #32 received at 25678 <at> debbugs.gnu.org (full text, mbox):

From: Mauro Aranda <maurooaranda <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: dieter <at> duenenhof-wilhelm.de, 25678 <at> debbugs.gnu.org,
 Noam Postavsky <npostavs <at> gmail.com>, Drew Adams <drew.adams <at> oracle.com>,
 tim <at> tim-landscheidt.de
Subject: Re: bug#25678: 25.1; defcustom type `(file :must-match t)' seems not
 to work
Date: Wed, 9 Sep 2020 14:21:11 -0300
[Message part 1 (text/plain, inline)]
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Mauro Aranda <maurooaranda <at> 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.
[Message part 2 (text/html, inline)]
[0001-Fix-match-function-for-the-file-widget.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25678; Package emacs. (Thu, 10 Sep 2020 13:14:02 GMT) Full text and rfc822 format available.

Message #35 received at 25678 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Mauro Aranda <maurooaranda <at> gmail.com>
Cc: dieter <at> duenenhof-wilhelm.de, 25678 <at> debbugs.gnu.org,
 Noam Postavsky <npostavs <at> gmail.com>, Drew Adams <drew.adams <at> oracle.com>,
 tim <at> tim-landscheidt.de
Subject: Re: bug#25678: 25.1; defcustom type `(file :must-match t)' seems
 not to work
Date: Thu, 10 Sep 2020 15:13:10 +0200
Mauro Aranda <maurooaranda <at> gmail.com> writes:

> 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.

Thanks; applied to the trunk.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 09 Oct 2020 11:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 199 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.