branch: elpa/meow
commit f1bfad9518c2756375e16cd3f9f38235c3f57df8
Author: eshrh <e...@gatech.edu>
Commit: eshrh <e...@gatech.edu>

    meow-util: fix meow-visit empty-string bug by re-prompting
    
    Fixes the meow-visit empty string bug by re-prompting the user (with
    an error message) when they give empty input.
---
 meow-command.el | 2 +-
 meow-util.el    | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/meow-command.el b/meow-command.el
index ec56b8283c..e400a10164 100644
--- a/meow-command.el
+++ b/meow-command.el
@@ -1394,7 +1394,7 @@ To search backward, use \\[negative-argument]."
          (pos (point))
          (text (meow--prompt-symbol-and-words
                 (if arg "Visit backward: " "Visit: ")
-                (point-min) (point-max)))
+                (point-min) (point-max) t))
          (visit-point (meow--visit-point text reverse)))
     (if visit-point
         (let* ((m (match-data))
diff --git a/meow-util.el b/meow-util.el
index 76c3a3a3bf..98cc048b54 100644
--- a/meow-util.el
+++ b/meow-util.el
@@ -272,7 +272,7 @@ Looks up the state in meow-replace-state-name-list"
 (defun meow--string-join (sep s)
   (string-join s sep))
 
-(defun meow--prompt-symbol-and-words (prompt beg end)
+(defun meow--prompt-symbol-and-words (prompt beg end &optional disallow-empty)
   "Completion with PROMPT for symbols and words from BEG to END."
   (let ((completions))
     (save-mark-and-excursion
@@ -285,6 +285,11 @@ Looks up the state in meow-replace-state-name-list"
               (push (format "\\_<%s\\_>" (regexp-quote result)) 
completions))))))
     (setq completions (delete-dups completions))
     (let ((selected (completing-read prompt completions nil nil)))
+      (while (and (string-empty-p selected)
+                  disallow-empty)
+        (setq selected (completing-read
+                        (concat "[Input must be non-empty] " prompt)
+                        completions nil nil)))
       (if meow-visit-sanitize-completion
           (or (cdr (assoc selected completions))
               (regexp-quote selected))

Reply via email to