comparison lisp/wid-edit.el @ 31361:cb09e02f0217

(widget-sexp-validate): Fix garbled code.
author Dave Love <fx@gnu.org>
date Mon, 04 Sep 2000 09:40:27 +0000
parents 7e7ba448ad10
children 48f674467ba6
comparison
equal deleted inserted replaced
31360:b8513fe83893 31361:cb09e02f0217
1633 :prompt-history 'widget-field-history 1633 :prompt-history 'widget-field-history
1634 :prompt-value 'widget-field-prompt-value 1634 :prompt-value 'widget-field-prompt-value
1635 :action 'widget-field-action 1635 :action 'widget-field-action
1636 :validate 'widget-field-validate 1636 :validate 'widget-field-validate
1637 :valid-regexp "" 1637 :valid-regexp ""
1638 :error "No match" 1638 :error "Field's value doesn't match allowed form"
1639 :value-create 'widget-field-value-create 1639 :value-create 'widget-field-value-create
1640 :value-delete 'widget-field-value-delete 1640 :value-delete 'widget-field-value-delete
1641 :value-get 'widget-field-value-get 1641 :value-get 'widget-field-value-get
1642 :match 'widget-field-match) 1642 :match 'widget-field-match)
1643 1643
2996 (defun widget-sexp-validate (widget) 2996 (defun widget-sexp-validate (widget)
2997 ;; Valid if we can read the string and there is no junk left after it. 2997 ;; Valid if we can read the string and there is no junk left after it.
2998 (with-temp-buffer 2998 (with-temp-buffer
2999 (insert (widget-apply widget :value-get)) 2999 (insert (widget-apply widget :value-get))
3000 (goto-char (point-min)) 3000 (goto-char (point-min))
3001 (condition-case data 3001 (let (err)
3002 (progn 3002 (condition-case data
3003 ;; Avoid a confusing end-of-file error. 3003 (progn
3004 (skip-syntax-forward "\\s-") 3004 ;; Avoid a confusing end-of-file error.
3005 (if (eobp) 3005 (skip-syntax-forward "\\s-")
3006 (error "Empty sexp -- use `nil'?")) 3006 (if (eobp)
3007 (if (eobp) 3007 (setq err "Empty sexp -- use `nil'?")
3008 (unless (widget-apply widget :match (read (current-buffer))) 3008 (unless (widget-apply widget :match (read (current-buffer)))
3009 (widget-put widget :error (widget-get widget :type-error)) 3009 (setq err (widget-get widget :type-error))))
3010 widget) 3010 (if (and (not (eobp))
3011 (widget-put widget 3011 (not err))
3012 :error (format "Junk at end of expression: %s" 3012 (setq err (format "Junk at end of expression: %s"
3013 (buffer-substring (point) 3013 (buffer-substring (point)
3014 (point-max)))) 3014 (point-max))))))
3015 widget)) 3015 (end-of-file ; Avoid confusing error message.
3016 (end-of-file ; Avoid confusing error message. 3016 (setq err "Unbalanced sexp"))
3017 (widget-put widget :error "Unbalanced sexp") 3017 (error (setq err (error-message-string data))))
3018 widget) 3018 (if (not err)
3019 (error (widget-put widget :error (error-message-string data)) 3019 nil
3020 widget)))) 3020 (widget-put widget :error err)
3021 widget))))
3021 3022
3022 (defvar widget-sexp-prompt-value-history nil 3023 (defvar widget-sexp-prompt-value-history nil
3023 "History of input to `widget-sexp-prompt-value'.") 3024 "History of input to `widget-sexp-prompt-value'.")
3024 3025
3025 (defun widget-sexp-prompt-value (widget prompt value unbound) 3026 (defun widget-sexp-prompt-value (widget prompt value unbound)