Beep when there are no matches

If avy--read-candidates doesn't find any candidates for the current
input, the user has surely made a typo.  In that case, beep at the user
to make him aware of that.
This commit is contained in:
Tassilo Horn 2015-10-22 15:25:13 +02:00
parent f28d238e0e
commit 0166808bc1

6
avy.el
View File

@ -1138,6 +1138,7 @@ This function obeys `avy-all-windows' setting."
(setq str (concat str (list char))))) (setq str (concat str (list char)))))
;; Highlight ;; Highlight
(when (>= (length str) 1) (when (>= (length str) 1)
(let (found)
(dolist (win (avy-window-list)) (dolist (win (avy-window-list))
(with-selected-window win (with-selected-window win
(dolist (pair (avy--find-visible-regions (dolist (pair (avy--find-visible-regions
@ -1151,9 +1152,12 @@ This function obeys `avy-all-windows' setting."
(let ((ov (make-overlay (let ((ov (make-overlay
(match-beginning 0) (match-beginning 0)
(match-end 0)))) (match-end 0))))
(setq found t)
(push ov overlays) (push ov overlays)
(overlay-put ov 'window (selected-window)) (overlay-put ov 'window (selected-window))
(overlay-put ov 'face 'avy-goto-char-timer-face)))))))))) (overlay-put ov 'face 'avy-goto-char-timer-face))))))))
;; No matches at all, so there's surely a typo in the input.
(unless found (beep)))))
(nreverse (mapcar (lambda (ov) (nreverse (mapcar (lambda (ov)
(cons (cons (overlay-start ov) (cons (cons (overlay-start ov)
(overlay-end ov)) (overlay-end ov))