emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 0166808 47/78: Beep when there are no matches


From: Oleh Krehel
Subject: [elpa] master 0166808 47/78: Beep when there are no matches
Date: Sat, 23 Jan 2016 14:00:04 +0000

branch: master
commit 0166808bc1b25c9447ee16bc292e9f2e3faf14e5
Author: Tassilo Horn <address@hidden>
Commit: Tassilo Horn <address@hidden>

    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.
---
 avy.el |   36 ++++++++++++++++++++----------------
 1 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/avy.el b/avy.el
index 121630d..08a3f33 100644
--- a/avy.el
+++ b/avy.el
@@ -1138,22 +1138,26 @@ This function obeys `avy-all-windows' setting."
               (setq str (concat str (list char)))))
             ;; Highlight
             (when (>= (length str) 1)
-              (dolist (win (avy-window-list))
-                (with-selected-window win
-                  (dolist (pair (avy--find-visible-regions
-                                 (window-start)
-                                 (window-end (selected-window) t)))
-                    (save-excursion
-                      (goto-char (car pair))
-                      (setq regex (regexp-quote str))
-                      (while (re-search-forward regex (cdr pair) t)
-                        (unless (get-char-property (1- (point)) 'invisible)
-                          (let ((ov (make-overlay
-                                     (match-beginning 0)
-                                     (match-end 0))))
-                            (push ov overlays)
-                            (overlay-put ov 'window (selected-window))
-                            (overlay-put ov 'face 
'avy-goto-char-timer-face))))))))))
+              (let (found)
+                (dolist (win (avy-window-list))
+                  (with-selected-window win
+                    (dolist (pair (avy--find-visible-regions
+                                   (window-start)
+                                   (window-end (selected-window) t)))
+                      (save-excursion
+                        (goto-char (car pair))
+                        (setq regex (regexp-quote str))
+                        (while (re-search-forward regex (cdr pair) t)
+                          (unless (get-char-property (1- (point)) 'invisible)
+                            (let ((ov (make-overlay
+                                       (match-beginning 0)
+                                       (match-end 0))))
+                              (setq found t)
+                              (push ov overlays)
+                              (overlay-put ov 'window (selected-window))
+                              (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)
                               (cons (cons (overlay-start ov)
                                           (overlay-end ov))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]