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

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

[elpa] master 52a083e 13/90: ivy.el (ivy-yank-word): New command


From: Oleh Krehel
Subject: [elpa] master 52a083e 13/90: ivy.el (ivy-yank-word): New command
Date: Tue, 30 Jun 2015 07:28:05 +0000

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

    ivy.el (ivy-yank-word): New command
    
    * swiper.el (swiper--update-input-ivy): Move point to current regex, not
      just current line.
    
    Gives a behavior similar to "C-w" of `isearch'. Possible binding:
    
        (define-key ivy-minibuffer-map (kbd "C-w") 'ivy-yank-word)
    
    Fixes #125
---
 ivy.el    |   15 +++++++++++++++
 swiper.el |    1 +
 2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/ivy.el b/ivy.el
index 2149e2d..07aa28c 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1269,6 +1269,21 @@ BUFFER may be a string or nil."
   (ivy-read "Recentf: " recentf-list
             :action #'find-file))
 
+(defun ivy-yank-word ()
+  "Pull next word from buffer into search string."
+  (interactive)
+  (let (amend)
+    (with-selected-window (ivy-state-window ivy-last)
+      (let ((pt (point))
+            (le (line-end-position)))
+        (forward-word 1)
+        (setf (window-point) (point))
+        (if (> (point) le)
+            (goto-char pt)
+          (setq amend (buffer-substring-no-properties pt (point))))))
+    (when amend
+      (insert amend))))
+
 (provide 'ivy)
 
 ;;; ivy.el ends here
diff --git a/swiper.el b/swiper.el
index 3ab246e..27e864e 100644
--- a/swiper.el
+++ b/swiper.el
@@ -287,6 +287,7 @@ Please remove it and update the \"swiper\" package."))
       (when (cl-plusp num)
         (goto-char (point-min))
         (forward-line (1- num))
+        (re-search-forward re (line-end-position) t)
         (isearch-range-invisible (line-beginning-position)
                                  (line-end-position))
         (unless (and (>= (point) (window-start))



reply via email to

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