Fix infinite loop on invalid answer to straight prompts

This commit is contained in:
Henrik Lissner 2019-11-14 02:37:24 -05:00
parent 2a01a9dcdf
commit 6599388f00
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -161,15 +161,20 @@ missing) and shouldn't be deleted.")
(push func options) (push func options)
(print! "%2s) %s" (length options) desc))))) (print! "%2s) %s" (length options) desc)))))
(terpri) (terpri)
(let ((answer (let ((options (nreverse options))
(read-number (format! "How to proceed? (%s) " answer fn)
(mapconcat #'number-to-string (while
(number-sequence 1 (length options)) (not
", ")))) (setq
fn) fn (ignore-errors
(setq options (nreverse options)) (nth (1- (setq answer
(while (not (setq fn (nth (1- answer) options))) (read-number
(print! "%s is not a valid answer, try again." answer)) (format! "How to proceed? (%s) "
(mapconcat #'number-to-string
(number-sequence 1 (length options))
", ")))))
options))))
(print! (warn "%s is not a valid answer, try again.") answer))
(funcall fn)))))) (funcall fn))))))