mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
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).
This commit is contained in:
parent
dd910dd2f8
commit
34e7617365
1 changed files with 9 additions and 0 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue