[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 34e7617 1/2: Respect :must-match for file types in customization
From: |
Lars Ingebrigtsen |
Subject: |
master 34e7617 1/2: Respect :must-match for file types in customization buffers |
Date: |
Sun, 30 Aug 2020 11:03:18 -0400 (EDT) |
branch: master
commit 34e7617365f16f9dfa6f31f968a0b5dee6d7d54b
Author: Mauro Aranda <maurooaranda@gmail.com>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
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 ea7e266..f58a0fb 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -3161,6 +3161,15 @@ It reads a file name from an editable text field."
: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.