[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master f9b64c3 126/399: swiper.el (swiper-isearch): Add
From: |
Oleh Krehel |
Subject: |
[elpa] master f9b64c3 126/399: swiper.el (swiper-isearch): Add |
Date: |
Sat, 20 Jul 2019 14:57:05 -0400 (EDT) |
branch: master
commit f9b64c3fa164cf5e68e49db8862ca56bf5a7a24d
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
swiper.el (swiper-isearch): Add
Fixes #1931
---
swiper.el | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)
diff --git a/swiper.el b/swiper.el
index be27efa..32ecaf4 100644
--- a/swiper.el
+++ b/swiper.el
@@ -1101,6 +1101,73 @@ See `ivy-format-function' for further information."
nil))
res))
+;;* `swiper-isearch'
+(defvar swiper--isearch-last-point nil)
+
+(defun swiper-isearch-function (str)
+ "Collect STR matches in the current buffer for `swiper-isearch'."
+ (unless (string= str "")
+ (let ((re-full (funcall ivy--regex-function str))
+ re
+ cands
+ idx-found
+ (idx 0))
+ (setq re (ivy-re-to-str re-full))
+ (with-ivy-window
+ (save-excursion
+ (goto-char (point-min))
+ (while (re-search-forward re nil t)
+ (unless idx-found
+ (when (>= (match-beginning 0) swiper--isearch-last-point)
+ (setq swiper--isearch-last-point (match-beginning 0))
+ (setq idx-found idx)))
+ (cl-incf idx)
+ (let ((line (buffer-substring-no-properties
+ (line-beginning-position)
+ (line-end-position))))
+ (put-text-property 0 1 'point (point) line)
+ (push line cands)))))
+ (setq ivy--old-re re)
+ (when idx-found
+ (ivy-set-index idx-found))
+ (setq ivy--old-cands (nreverse cands)))))
+
+(defun swiper-isearch-action (x)
+ "Move to X for `swiper-isearch'."
+ (if (> (length x) 0)
+ (with-ivy-window
+ (goto-char (get-text-property 0 'point x))
+ (isearch-range-invisible (line-beginning-position)
+ (line-end-position))
+ (unless (eq ivy-exit 'done)
+ (swiper--cleanup)
+ (swiper--add-overlays (ivy--regex ivy-text))))
+ (swiper--cleanup)))
+
+(defun swiper-isearch ()
+ "A `swiper' that's not line-based."
+ (interactive)
+ (swiper--init)
+ (setq swiper--isearch-last-point (point))
+ (let (res)
+ (unwind-protect
+ (and
+ (setq res
+ (ivy-read
+ "iswiper: " #'swiper-isearch-function
+ :dynamic-collection t
+ :action #'swiper-isearch-action
+ :update-fn (lambda ()
+ (swiper-isearch-action (ivy-state-current
ivy-last)))
+ :unwind #'swiper--cleanup
+ :history 'swiper-history
+ :caller 'swiper-isearch))
+ (point))
+ (unless (or res swiper-stay-on-quit)
+ (goto-char swiper--opoint))
+ (unless (or res (string= ivy-text ""))
+ (cl-pushnew ivy-text swiper-history)))))
+
(provide 'swiper)
;;; swiper.el ends here
- [elpa] master 344aebc 116/399: counsel.el (counsel-dired-jump): Improve, (continued)
- [elpa] master 344aebc 116/399: counsel.el (counsel-dired-jump): Improve, Oleh Krehel, 2019/07/20
- [elpa] master b27ef9e 111/399: counsel.el (counsel-git-cands): Extract, Oleh Krehel, 2019/07/20
- [elpa] master 1b5af1e 115/399: counsel.el (counsel-file-jump-args): Adjust, Oleh Krehel, 2019/07/20
- [elpa] master 05763ae 121/399: counsel.el (counsel-git): Fix default-directory, Oleh Krehel, 2019/07/20
- [elpa] master aef1242 118/399: ivy-overlay.el (ivy-overlay-impossible-p): Simplify, Oleh Krehel, 2019/07/20
- [elpa] master 3cb9d72 120/399: ivy-overlay.el (ivy-display-function-overlay): Fix weird offset, Oleh Krehel, 2019/07/20
- [elpa] master ea6ef81 122/399: Allow recursive minibuffers to use ivy-display-function-alist, Oleh Krehel, 2019/07/20
- [elpa] master 5e54abd 123/399: Fix counsel-org-tag-agenda, Oleh Krehel, 2019/07/20
- [elpa] master 1998783 125/399: counsel.el (counsel-find-file-ignore-regexp): Add nested hidden dotfiles, Oleh Krehel, 2019/07/20
- [elpa] master bb5d0d4 119/399: ivy-overlay.el (ivy-display-function-overlay): Refactor, Oleh Krehel, 2019/07/20
- [elpa] master f9b64c3 126/399: swiper.el (swiper-isearch): Add,
Oleh Krehel <=
- [elpa] master 1606918 129/399: ivy.el (ivy-read): Allow :update-fn to be 'auto, Oleh Krehel, 2019/07/20
- [elpa] master f4431d4 133/399: doc/ivy.org (automatically integrated packages): Add, Oleh Krehel, 2019/07/20
- [elpa] master 0465711 124/399: counsel.el (counsel-org-tag-agenda): Check org-version, Oleh Krehel, 2019/07/20
- [elpa] master 3416142 128/399: counsel.el (counsel--async-sentinel): Fix index jumping randomly, Oleh Krehel, 2019/07/20
- [elpa] master 31a554d 130/399: swiper.el (swiper-isearch): Anchor to line-beginning-position, Oleh Krehel, 2019/07/20
- [elpa] master adad2e4 127/399: counsel.el: Strip space from initial input of counsel-package, Oleh Krehel, 2019/07/20
- [elpa] master df8901f 132/399: swiper.el (swiper-query-replace): Add preview overlays, Oleh Krehel, 2019/07/20
- [elpa] master dc3f469 131/399: swiper.el (swiper-isearch): Extend, Oleh Krehel, 2019/07/20
- [elpa] master bc479ed 134/399: swiper.el (swiper-isearch): Fix minibuffer height, Oleh Krehel, 2019/07/20
- [elpa] master fa2e02d 137/399: ivy-overlay.el (ivy-cursor): Customize for dark background, Oleh Krehel, 2019/07/20