]> code.delx.au - gnu-emacs-elpa/blobdiff - swiper.el
counsel.el: Add a bunch of autoload cookies
[gnu-emacs-elpa] / swiper.el
index ab1d02254048251deff1479953752009f3c51d62..8312852c0412891a34cbf06cd7ff9421796cf991 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
 
       (exit-minibuffer))))
 
 (defvar avy-background)
+(defvar avy-all-windows)
 (declare-function avy--regex-candidates "ext:avy")
 (declare-function avy--process "ext:avy")
 (declare-function avy--overlay-post "ext:avy")
 (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)))))
+  (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'."
 (defun swiper-font-lock-ensure ()
   "Ensure the entired buffer is highlighted."
   (unless (or (derived-mode-p 'magit-mode)
+              (bound-and-true-p magit-blame-mode)
               (memq major-mode '(package-menu-mode
                                  gnus-summary-mode
                                  gnus-article-mode
@@ -231,10 +235,9 @@ Please remove it and update the \"swiper\" package."))
         (preselect (format
                     swiper--format-spec
                     (line-number-at-pos)
-                    (regexp-quote
-                     (buffer-substring-no-properties
-                      (line-beginning-position)
-                      (line-end-position)))))
+                    (buffer-substring-no-properties
+                     (line-beginning-position)
+                     (line-end-position))))
         res)
     (unwind-protect
          (setq res (ivy-read
@@ -285,6 +288,11 @@ Please remove it and update the \"swiper\" package."))
       (when (cl-plusp num)
         (goto-char (point-min))
         (forward-line (1- num))
+        (if (and (equal ivy-text "")
+                 (>= swiper--opoint (line-beginning-position))
+                 (<= swiper--opoint (line-end-position)))
+            (goto-char swiper--opoint)
+          (re-search-forward re (line-end-position) t))
         (isearch-range-invisible (line-beginning-position)
                                  (line-end-position))
         (unless (and (>= (point) (window-start))