Function: widget-sexp-validate
widget-sexp-validate is a byte-compiled function defined in
wid-edit.el.gz.
Signature
(widget-sexp-validate WIDGET)
Source Code
;; Defined in /usr/src/emacs/lisp/wid-edit.el.gz
(defun widget-sexp-validate (widget)
;; Valid if we can read the string and there is no junk left after it.
(with-temp-buffer
(insert (widget-apply widget :value-get))
(goto-char (point-min))
(let (err)
(condition-case data ;Note: We get a spurious byte-compile warning here.
(progn
;; Avoid a confusing end-of-file error.
(skip-syntax-forward "-")
(if (eobp)
(setq err "Empty sexp -- use nil?")
(unless (widget-apply widget :match (read (current-buffer)))
(setq err (widget-get widget :type-error))))
;; Allow whitespace after expression.
(skip-syntax-forward "-")
(if (and (not (eobp))
(not err))
(setq err (format "Junk at end of expression: %s"
(buffer-substring (point)
(point-max))))))
(end-of-file ; Avoid confusing error message.
(setq err "Unbalanced sexp"))
(error (setq err (error-message-string data))))
(if (not err)
nil
(widget-put widget :error err)
widget))))