Closed
Description
Hi, and thanks for this package.
Would you accept a PR which adds an option to swiper which will make swiper to go the beginning of the match, not its end?
Something like this:
diff --git a/swiper.el b/swiper.el
index 7aa2875..754b9bf 100644
--- a/swiper.el
+++ b/swiper.el
@@ -683,36 +683,38 @@ WND, when specified is the window."
(defun swiper--action (x)
"Goto line X."
(let ((ln (1- (read (or (get-text-property 0 'swiper-line-number x)
(and (string-match ":\\([0-9]+\\):.*\\'" x)
(match-string-no-properties 1 x))))))
(re (ivy--regex ivy-text)))
(if (null x)
(user-error "No candidates")
(with-ivy-window
(unless (equal (current-buffer)
(ivy-state-buffer ivy-last))
(switch-to-buffer (ivy-state-buffer ivy-last)))
(goto-char swiper--point-min)
(funcall (if swiper-use-visual-line
#'line-move
#'forward-line)
ln)
(re-search-forward re (line-end-position) t)
+ (when (goto-char swiper--point-min) ;; and some other var is true, maybe `swiper-action-land-on-match-start`
+ (goto-char (match-beginning 0)))
(swiper--ensure-visible)
(cond (swiper-action-recenter
(recenter))
(swiper--current-window-start
(set-window-start (selected-window) swiper--current-window-start)))
(when (/= (point) swiper--opoint)
(unless (and transient-mark-mode mark-active)
(when (eq ivy-exit 'done)
(push-mark swiper--opoint t)
(message "Mark saved where search started"))))
(add-to-history
'regexp-search-ring
re
regexp-search-ring-max)
(when (and (bound-and-true-p evil-mode)
(eq evil-search-module 'evil-search))
(add-to-history 'evil-ex-search-history re)
(setq evil-ex-search-pattern (list re t t))
Metadata
Metadata
Assignees
Labels
No labels