Closed cyberthal closed 4 years ago
Thanks, please test.
I don't understand what you mean. I am using the code block successfully for personal use, and plan to submit it as part of a MELPA package within a month.
I meant that this code now works:
(let ((avy-all-windows nil)
(avy-case-fold-search nil)
(isearch-string "avy"))
(unless (eq 1 (length (avy--regex-candidates (regexp-quote isearch-string))))
(goto-char (point-min))
(let ((res (avy-isearch)))
(message "res: %S" res))))
In case there's a C-g, res
will be nil
.
(avy-isearch) always returned nil before, so it was impossible to tell whether the nil was the result of a C-g or not. It still does the same thing, in my test. Call (avy-isearch) with eval-expression and it will return "nil" to the minibuffer.
But now, when you don't press C-g, res
will store the point position. So you can detect C-g.
That was the first time I'd tested someone's fix of an issue I opened on their package, and I didn't do it correctly. Your fix definitely works, thanks.
Instead of always returning nil, it returns e.g. "res: (69 . 72)" for a successful invocation and "res: nil" for a C-g quit.
Avy commands such as avy-isearch do not indicate that the user quit with C-g. This makes it difficult for other elisp authors who use avy functions in their code to distinguish between a user selecting the current location and the user quitting. In the latter case, the program should respond to the user's desire to abort.
I made a workaround to detect a quit within avy-isearch: