From: Mauro Aranda <maurooaranda@gmail.com>
To: 25678@debbugs.gnu.org
Cc: dieter@duenenhof-wilhelm.de, 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: Sat, 29 Aug 2020 12:33:15 -0300 [thread overview]
Message-ID: <CABczVwd_HPcFdUw32Sr45AVu2Qeb18i5PzAWxQQ3T1WP5b6qgw@mail.gmail.com> (raw)
In-Reply-To: <77a3abe9-258c-4863-a87d-2f236babafe4@default>
[-- Attachment #1.1: Type: text/plain, Size: 115 bytes --]
I think it makes sense to expand the impact of :must-match t to
Customization buffers, like in the attached patch.
[-- Attachment #1.2: Type: text/html, Size: 139 bytes --]
[-- Attachment #2: 0001-Respect-must-match-for-file-types-in-customization-b.patch --]
[-- Type: text/x-patch, Size: 1361 bytes --]
From 10896dedfc6861dcc64dd8705818dacc6aaa0a98 Mon Sep 17 00:00:00 2001
From: Mauro Aranda <maurooaranda@gmail.com>
Date: Wed, 26 Aug 2020 12:49:58 -0300
Subject: [PATCH] Respect :must-match for file types in customization buffers
* lisp/wid-edit.el (file widget): Add a :match and a :validate
function to the 'file widget, to be able to check if the widget
value is an existent file, when required. (Bug#25678)
---
lisp/wid-edit.el | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index ea7e266e0d..1015f010ce 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -3161,6 +3161,15 @@ 'file
:completions (completion-table-case-fold
#'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)))
+ :validate #'(lambda (widget)
+ (let ((value (widget-value widget)))
+ (unless (widget-apply widget :match value)
+ (widget-put widget
+ :error (format "File %s does not exist" value))
+ widget)))
:prompt-value 'widget-file-prompt-value
:format "%{%t%}: %v"
;; Doesn't work well with terminating newline.
--
2.28.0
next prev parent reply other threads:[~2020-08-29 15:33 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 [this message]
2020-08-30 13:56 ` Lars Ingebrigtsen
2020-08-30 15:22 ` Mauro Aranda
2020-09-09 17:21 ` Mauro Aranda
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=CABczVwd_HPcFdUw32Sr45AVu2Qeb18i5PzAWxQQ3T1WP5b6qgw@mail.gmail.com \
--to=maurooaranda@gmail.com \
--cc=25678@debbugs.gnu.org \
--cc=dieter@duenenhof-wilhelm.de \
--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).