branch: externals/iso-date
commit a2a62022356282e18fee0a60aa76c35833342cfc
Author: Lucas Quintana <lm...@protonmail.com>
Commit: Lucas Quintana <lm...@protonmail.com>

    Tolerate typos and give the user another chance when reading date
    
    Idea and original implementation from Philip Kaludercic.
---
 iso-date.el | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/iso-date.el b/iso-date.el
index 3e6c749cad..8629a22bd0 100644
--- a/iso-date.el
+++ b/iso-date.el
@@ -197,10 +197,13 @@ This is an alternative to the plist-based modification 
offered by
 
 (defun iso-date--read ()
   "Read date in YYYY-MM-DD format."
-  (let ((date (read-string "Date (YYYY-MM-DD): ")))
-    (unless (string-match-p iso-date-regexp date)
-      (user-error "Date not in YYYY-MM-DD format"))
-    date))
+  (catch :ok
+    (while (let ((date (read-string "Date (YYYY-MM-DD): ")))
+             (when (string-match iso-date-regexp date)
+               (throw :ok (match-string-no-properties 0 date)))
+             (message "Date not in YYYY-MM-DD format")
+             (sit-for 1)
+             t))))
 
 (defun iso-date-show-calendar (date)
   "Display calendar and go to DATE."

Reply via email to