]> code.delx.au - gnu-emacs-elpa/blobdiff - swiper.el
swiper.el (swiper-avy): Don't start on empty input
[gnu-emacs-elpa] / swiper.el
index 51af8e0250d708aaf9b81c7aa48db92856a19c3c..698e5dddec98921e47a1dc0be9a7757a2bf61fd0 100644 (file)
--- a/swiper.el
+++ b/swiper.el
@@ -4,7 +4,7 @@
 
 ;; Author: Oleh Krehel <ohwoeowho@gmail.com>
 ;; URL: https://github.com/abo-abo/swiper
-;; Version: 0.4.0
+;; Version: 0.4.1
 ;; Package-Requires: ((emacs "24.1"))
 ;; Keywords: matching
 
@@ -83,6 +83,9 @@
     map)
   "Keymap for swiper.")
 
+(defvar swiper--window nil
+  "Store the current window.")
+
 (defun swiper-query-replace ()
   "Start `query-replace' with string to replace from last search string."
   (interactive)
@@ -92,7 +95,7 @@
            (from (ivy--regex ivy-text))
            (to (query-replace-read-to from "Query replace" t)))
       (delete-minibuffer-contents)
-      (ivy-set-action (lambda ()
+      (ivy-set-action (lambda (_)
                         (with-selected-window swiper--window
                           (perform-replace from to
                                            t t nil))))
 (defun swiper-avy ()
   "Jump to one of the current swiper candidates."
   (interactive)
-  (with-selected-window (ivy-state-window ivy-last)
-    (let* ((candidates
-            (avy--regex-candidates
-             (ivy--regex ivy-text)))
-           (avy-background nil)
-           (candidate
-            (avy--process candidates #'avy--overlay-post)))
-      (ivy-quit-and-run
-       (avy--goto candidate)))))
-
-(defvar swiper--window nil
-  "Store the current window.")
+  (unless (string= ivy-text "")
+    (with-selected-window (ivy-state-window ivy-last)
+      (let* ((avy-all-windows nil)
+             (candidates
+              (avy--regex-candidates
+               (ivy--regex ivy-text)))
+             (avy-background nil)
+             (candidate
+              (avy--process candidates #'avy--overlay-post)))
+        (ivy-quit-and-run
+         (avy--goto candidate))))))
 
 (defun swiper-recenter-top-bottom (&optional arg)
   "Call (`recenter-top-bottom' ARG) in `swiper--window'."
                                  org-agenda-mode
                                  dired-mode
                                  jabber-chat-mode
-                                 elfeed-search-mode)))
+                                 elfeed-search-mode
+                                 fundamental-mode)))
     (unless (> (buffer-size) 100000)
       (if (fboundp 'font-lock-ensure)
           (font-lock-ensure)
@@ -206,7 +209,7 @@ there have line numbers. In the buffer, `ivy--regex' should be used."
      "")
     ((equal str "^")
      ".")
-    ((string-match "\\^" str)
+    ((string-match "^\\^" str)
      (setq ivy--old-re "")
      (let ((re (ivy--regex-plus (substring str 1))))
        (format "^[0-9][0-9 ]\\{%d\\}%s"