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

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

[elpa] master cd083cc 18/57: Add swiper -> avy finalizer


From: Oleh Krehel
Subject: [elpa] master cd083cc 18/57: Add swiper -> avy finalizer
Date: Tue, 19 May 2015 14:21:26 +0000

branch: master
commit cd083cc722658fa39ff10c6601d0d4d99b44ef5f
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    Add swiper -> avy finalizer
    
    * ivy.el (ivy-quit-and-run): New defmacro.
    (tramp-get-completion-function): Add declare.
    
    * swiper.el (swiper-map): Bind `avy-swiper' to "C-'".
    (avy-swiper): New defun - jump to one of the currently visible swiper
    candidates using avy.
---
 ivy.el    |   12 ++++++++++++
 swiper.el |   20 ++++++++++++++++++++
 2 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/ivy.el b/ivy.el
index a7e76e0..e42f8c3 100644
--- a/ivy.el
+++ b/ivy.el
@@ -182,6 +182,16 @@ When non-nil, it should contain one %d.")
 
 (defvar Info-current-file)
 
+(defmacro ivy-quit-and-run (&rest body)
+  "Quit the minibuffer and run BODY afterwards."
+  `(progn
+     (put 'quit 'error-message "")
+     (run-at-time nil nil
+                  (lambda ()
+                    (put 'quit 'error-message "Quit")
+                    ,@body))
+     (minibuffer-keyboard-quit)))
+
 (defun ivy--done (text)
   "Insert TEXT and exit minibuffer."
   (if (and ivy--directory
@@ -224,6 +234,8 @@ Is is a cons cell, related to 
`tramp-get-completion-function'."
         (concat user "@" domain)
       domain)))
 
+(declare-function tramp-get-completion-function "tramp")
+
 (defun ivy-alt-done (&optional arg)
   "Exit the minibuffer with the selected candidate.
 When ARG is t, exit with current text, ignoring the candidates."
diff --git a/swiper.el b/swiper.el
index 0879103..3c58d59 100644
--- a/swiper.el
+++ b/swiper.el
@@ -79,6 +79,7 @@
   (let ((map (make-sparse-keymap)))
     (define-key map (kbd "M-q") 'swiper-query-replace)
     (define-key map (kbd "C-l") 'swiper-recenter-top-bottom)
+    (define-key map (kbd "C-'") 'avy-swiper)
     map)
   "Keymap for swiper.")
 
@@ -98,6 +99,25 @@
       (swiper--cleanup)
       (exit-minibuffer))))
 
+(defvar avy-background)
+(declare-function avy--regex-candidates "ext:avy")
+(declare-function avy--process "ext:avy")
+(declare-function avy--overlay-post "ext:avy")
+(declare-function avy--goto "ext:avy")
+
+;;;###autoload
+(defun avy-swiper ()
+  "Jump to one of the current swiper candidates."
+  (interactive)
+  (with-selected-window (ivy-state-window ivy-last)
+    (let* ((candidates
+            (avy--regex-candidates 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.")
 



reply via email to

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