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

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

[elpa] master 7ca301b 334/348: swiper.el (swiper-goto-start-of-match) Ne


From: Oleh Krehel
Subject: [elpa] master 7ca301b 334/348: swiper.el (swiper-goto-start-of-match) New defcustom
Date: Sat, 8 Apr 2017 11:04:25 -0400 (EDT)

branch: master
commit 7ca301b444d1208dbe08060529669bafced72a41
Author: Evgeni Kolev <address@hidden>
Commit: Oleh Krehel <address@hidden>

    swiper.el (swiper-goto-start-of-match) New defcustom
    
    When non-nil, swiper default action will go to the beginning of the
    match instead of on its end. This behavior is inspired by vim's and
    evil's way of searching.
    
    Fixes #944
    Fixes #942
---
 swiper.el | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/swiper.el b/swiper.el
index 7aa2875..c9b05db 100644
--- a/swiper.el
+++ b/swiper.el
@@ -77,6 +77,11 @@
   :type 'boolean
   :group 'swiper)
 
+(defcustom swiper-goto-start-of-match nil
+  "When non-nil, go to the start of the match, not its end."
+  :type 'boolean
+  :group 'swiper)
+
 (defvar swiper-map
   (let ((map (make-sparse-keymap)))
     (define-key map (kbd "M-q") 'swiper-query-replace)
@@ -697,7 +702,8 @@ WND, when specified is the window."
                      #'line-move
                    #'forward-line)
                  ln)
-        (re-search-forward re (line-end-position) t)
+        (when (and (re-search-forward re (line-end-position) t) 
swiper-goto-start-of-match)
+          (goto-char (match-beginning 0)))
         (swiper--ensure-visible)
         (cond (swiper-action-recenter
                (recenter))



reply via email to

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