Skip to content

Commit

Permalink
meow-util: fix meow-visit empty-string bug by re-prompting
Browse files Browse the repository at this point in the history
Fixes the meow-visit empty string bug by re-prompting the user (with
an error message) when they give empty input.
  • Loading branch information
eshrh committed Jun 2, 2024
1 parent 6a0dc2d commit f1bfad9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion meow-command.el
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
7 changes: 6 additions & 1 deletion meow-util.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand Down

0 comments on commit f1bfad9

Please sign in to comment.