Function: hargs:read
hargs:read is a byte-compiled function defined in hargs.el.
Signature
(hargs:read PROMPT &optional PREDICATE DEFAULT ERR VAL-TYPE)
Documentation
PROMPT without completion for a value matching PREDICATE and return it.
PREDICATE is an optional boolean function of one argument. Optional DEFAULT
is a string to insert after PROMPT as the default return value. Optional
ERR is a string to display temporarily when an invalid value is given.
Optional VAL-TYPE is a symbol indicating the type of value to be read. If
VAL-TYPE equals sexpression, then return that type; otherwise return the
string read or nil.
Source Code
;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hargs.el
(defun hargs:read (prompt &optional predicate default err val-type)
"PROMPT without completion for a value matching PREDICATE and return it.
PREDICATE is an optional boolean function of one argument. Optional DEFAULT
is a string to insert after PROMPT as the default return value. Optional
ERR is a string to display temporarily when an invalid value is given.
Optional VAL-TYPE is a symbol indicating the type of value to be read. If
VAL-TYPE equals `sexpression', then return that type; otherwise return the
string read or nil."
(let ((bad-val) (val) (stringify)
(prev-reading-p hargs:reading-type)
(read-func)
(owind (selected-window))
(obuf (current-buffer)))
(unwind-protect
(progn
(cond ((or (null val-type) (eq val-type 'sexpression))
(setq read-func 'read-minibuffer
hargs:reading-type 'sexpression))
(t (setq read-func 'read-string hargs:reading-type val-type
stringify t)))
(while (progn (and default (not (stringp default))
(setq default (prin1-to-string default)))
(condition-case ()
(or bad-val (setq val (funcall read-func prompt default)))
(error (setq bad-val t)))
(if bad-val
t
(and stringify
;; Remove any double quoting of strings.
(string-match "\\`\"\\([^\"]*\\)\"\\'" val)
(setq val (match-string 1 val)))
(and predicate (not (funcall predicate val)))))
(if bad-val (setq bad-val nil) (setq default val))
(beep)
(when err
(message err)
(sit-for 3)))
val)
(setq hargs:reading-type prev-reading-p)
(select-window owind)
(switch-to-buffer obuf))))