[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master c4acef9 56/67: swiper.el: Remove the helm bits
From: |
Oleh Krehel |
Subject: |
[elpa] master c4acef9 56/67: swiper.el: Remove the helm bits |
Date: |
Sun, 22 Mar 2015 17:34:09 +0000 |
branch: master
commit c4acef92c36d2a9874b815e59c7e1f30c6b0e669
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
swiper.el: Remove the helm bits
They are now in swiper-helm.el. Available for install separately from
MELPA.
---
swiper.el | 159 +------------------------------------------------------------
1 files changed, 2 insertions(+), 157 deletions(-)
diff --git a/swiper.el b/swiper.el
index 906d1e4..bd88a51 100644
--- a/swiper.el
+++ b/swiper.el
@@ -29,7 +29,7 @@
;; candidates. The search regex can be split into groups with a
;; space. Each group is highlighted with a different face.
;;
-;; The overview back end can be either `helm' or `ivy'.
+;; The overview back end is `ivy'.
;;
;; It can double as a quick `regex-builder', although only single
;; lines will be matched.
@@ -42,12 +42,6 @@
:group 'matching
:prefix "swiper-")
-(defcustom swiper-completion-method 'ivy
- "Method to select a candidate from a list of strings."
- :type '(choice
- (const :tag "Helm" helm)
- (const :tag "Ivy" ivy)))
-
(defface swiper-match-face-1
'((t (:inherit isearch-lazy-highlight-face)))
"Face for `swiper' matches.")
@@ -109,13 +103,6 @@
(zerop (forward-line 1)))
(nreverse candidates))))))
-(defvar swiper-helm-keymap
- (let ((map (make-sparse-keymap)))
- (define-key map (kbd "C-s") 'helm-next-line)
- (define-key map (kbd "C-r") 'helm-previous-line)
- map)
- "Allows you to go to next and previous hit isearch-style.")
-
(defvar swiper--opoint 1
"The point when `swiper' starts.")
@@ -125,10 +112,7 @@
When non-nil, INITIAL-INPUT is the initial search pattern."
(interactive)
(setq swiper--opoint (point))
- (if (and (eq swiper-completion-method 'helm)
- (featurep 'helm))
- (swiper--helm initial-input)
- (swiper--ivy initial-input)))
+ (swiper--ivy initial-input))
(defun swiper--init ()
"Perform initialization common to both completion methods."
@@ -166,59 +150,6 @@ When non-nil, INITIAL-INPUT is the initial search pattern."
(goto-char swiper--opoint)
(swiper--action res ivy-text)))))
-(defvar helm-candidate-number-limit)
-(defvar helm-display-function)
-(defvar helm-map)
-(defvar helm-input)
-(declare-function helm "ext:helm")
-(declare-function helm-persistent-action-display-window "ext:helm")
-(declare-function helm-window "ext:helm")
-(declare-function helm-next-line "ext:helm")
-
-(defun swiper--helm (&optional initial-input)
- "`isearch' with an overview using `helm'.
-When non-nil, INITIAL-INPUT is the initial search pattern."
- (interactive)
- (require 'helm)
- (require 'helm-match-plugin)
- (swiper--init)
- (unwind-protect
- (let ((helm-display-function
- (lambda (buf)
- (when (one-window-p)
- (split-window-vertically))
- (other-window 1)
- (switch-to-buffer buf)))
- helm-candidate-number-limit)
- (helm :sources
- `((name . ,(buffer-name))
- (init . (lambda ()
- (add-hook 'helm-move-selection-after-hook
- #'swiper--update-sel)
- (add-hook 'helm-update-hook
- #'swiper--update-input-helm)
- (add-hook 'helm-after-update-hook
- #'swiper--reanchor)))
- (match-strict . (lambda (x)
- (ignore-errors
- (string-match (ivy--regex helm-input)
x))))
- (candidates . ,(swiper--candidates))
- (filtered-candidate-transformer
- helm-fuzzy-highlight-matches)
- (action . swiper--action-helm))
- :keymap (make-composed-keymap
- swiper-helm-keymap
- helm-map)
- :input initial-input
- :preselect
- (format "^%d " swiper--anchor)
- :buffer "*swiper*"))
- ;; cleanup
- (remove-hook 'helm-move-selection-after-hook #'swiper--update-sel)
- (remove-hook 'helm-update-hook #'swiper--update-input-helm)
- (remove-hook 'helm-after-update-hook #'swiper--reanchor)
- (swiper--cleanup)))
-
(defun swiper--ensure-visible ()
"Remove overlays hiding point."
(let ((overlays (overlays-at (point)))
@@ -245,18 +176,6 @@ When non-nil, INITIAL-INPUT is the initial search pattern."
(defvar swiper--len 0
"The last length of input for which an anchoring was made.")
-(defun swiper--update-input-helm ()
- "Update selection."
- (swiper--cleanup)
- (with-selected-window swiper--window
- (swiper--add-overlays
- (ivy--regex helm-input)
- (window-start swiper--window)
- (window-end swiper--window t)))
- (when (/= (length helm-input) swiper--len)
- (setq swiper--len (length helm-input))
- (swiper--reanchor)))
-
(defun swiper--update-input-ivy ()
"Called when `ivy' input is updated."
(swiper--cleanup)
@@ -313,80 +232,6 @@ When non-nil, INITIAL-INPUT is the initial search pattern."
(overlay-put overlay 'priority i)))
(cl-incf i)))))))
-(defun swiper--binary (beg end)
- "Find anchor between BEG and END."
- (if (<= (- end beg) 10)
- (let ((min 1000)
- n
- ln
- d)
- (goto-char (point-min))
- (forward-line (1- beg))
- (while (< beg end)
- (beginning-of-line)
- (setq n (read (current-buffer)))
- (when (< (setq d (abs (- n swiper--anchor))) min)
- (setq min d)
- (setq ln beg))
- (cl-incf beg)
- (forward-line 1))
- (goto-char (point-min))
- (when ln
- (forward-line (1- ln))))
- (let ((mid (+ beg (/ (- end beg) 2))))
- (goto-char (point-min))
- (forward-line mid)
- (beginning-of-line)
- (let ((n (read (current-buffer))))
- (if (> n swiper--anchor)
- (swiper--binary beg mid)
- (swiper--binary mid end))))))
-
-(defun swiper--update-sel ()
- "Update selection."
- (let* ((re (ivy--regex helm-input))
- (str (buffer-substring-no-properties
- (line-beginning-position)
- (line-end-position)))
- (num (if (string-match "^[0-9]+" str)
- (string-to-number (match-string 0 str))
- 0))
- pt)
- (when (> (length re) 0)
- (with-selected-window swiper--window
- (goto-char (point-min))
- (forward-line (1- num))
- (when (re-search-forward re (point-max) t)
- (setq pt (match-beginning 0))))
- (when pt
- (with-selected-window
- (helm-persistent-action-display-window)
- (goto-char pt)
- (recenter)
- (swiper--update-input-helm))))
- (with-selected-window swiper--window
- (let ((ov (make-overlay
- (line-beginning-position)
- (1+ (line-end-position)))))
- (overlay-put ov 'face 'swiper-line-face)
- (push ov swiper--overlays)))))
-
-(defun swiper--reanchor ()
- "Move to a valid match closest to `swiper--anchor'."
- (with-selected-window (helm-window)
- (goto-char (point-min))
- (if (re-search-forward (format "^%d " swiper--anchor) nil t)
- nil
- (forward-line 1)
- (swiper--binary 2 (1+ (count-lines (point) (point-max)))))
- (when (> (count-lines (point-min) (point-max)) 1)
- (forward-line -1)
- (helm-next-line 1))))
-
-(defun swiper--action-helm (x)
- "Goto line X."
- (swiper--action x helm-input))
-
(defun swiper--action (x input)
"Goto line X and search for INPUT."
(if (null x)
- [elpa] master 41732be 48/67: ivy.el: Return nil when there is no match, (continued)
- [elpa] master 41732be 48/67: ivy.el: Return nil when there is no match, Oleh Krehel, 2015/03/22
- [elpa] master 588dab6 49/67: ivy-test.el: Add testing, Oleh Krehel, 2015/03/22
- [elpa] master f754835 47/67: swiper.el: Silence a few compilation warnings, Oleh Krehel, 2015/03/22
- [elpa] master cc4bf75 52/67: README.md: Add build status, Oleh Krehel, 2015/03/22
- [elpa] master 2b8e4e1 53/67: ivy.el: Remove while-no-input, Oleh Krehel, 2015/03/22
- [elpa] master 2191bdb 54/67: ivy.el (ivy-completions): Simplify, Oleh Krehel, 2015/03/22
- [elpa] master d587fa2 51/67: ivy.el (ivy-read): Allow for format-style PROMPT, Oleh Krehel, 2015/03/22
- [elpa] master 9f9c4dc 57/67: swiper-helm.el: Fix typo, Oleh Krehel, 2015/03/22
- [elpa] master 3a08a88 50/67: ivy.el (ivy-read): Change index to preselect, Oleh Krehel, 2015/03/22
- [elpa] master d2b2813 55/67: swiper-helm.el: Copy all helm stuff here, Oleh Krehel, 2015/03/22
- [elpa] master c4acef9 56/67: swiper.el: Remove the helm bits,
Oleh Krehel <=
- [elpa] master 0c85d9a 58/67: Add a custom `ivy-count-format', Oleh Krehel, 2015/03/22
- [elpa] master c2e58e9 59/67: Fix invalid package header line, Oleh Krehel, 2015/03/22
- [elpa] master a275a2a 60/67: Use `font-lock-append-text-property' to non-destructively modify a, Oleh Krehel, 2015/03/22
- [elpa] master 7876619 61/67: Update "C-n" and "C-p" bindings, Oleh Krehel, 2015/03/22
- [elpa] master f20b287 62/67: swiper.el (swiper--init): Set `swiper--opoint', Oleh Krehel, 2015/03/22
- [elpa] master bb6c40c 63/67: swiper.el (swiper-min-highlight): New defcustom, Oleh Krehel, 2015/03/22
- [elpa] master cf71b09 64/67: ivy.el (ivy-wrap): New defcustom, Oleh Krehel, 2015/03/22
- [elpa] master 55414c3 66/67: Update Copyright, Oleh Krehel, 2015/03/22
- [elpa] master 4358c03 65/67: Move swiper-helm to another repo, Oleh Krehel, 2015/03/22
- [elpa] master 302a16a 67/67: Add 'packages/swiper/' from commit '55414c321ca07bd86f0f1efaf8f6130617e6fad6', Oleh Krehel, 2015/03/22