[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master e722d6a 046/167: swiper.el (swiper-mc): Add and bind to "C
From: |
Oleh Krehel |
Subject: |
[elpa] master e722d6a 046/167: swiper.el (swiper-mc): Add and bind to "C-7" |
Date: |
Tue, 08 Dec 2015 10:49:48 +0000 |
branch: master
commit e722d6a7166eb75015a02445a6cb616b9ea289f2
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
swiper.el (swiper-mc): Add and bind to "C-7"
* swiper.el (swiper-map): Update.
(swiper-mc): New command.
(swiper--ivy): Use :action.
(swiper--action): Update arglist.
---
swiper.el | 61 +++++++++++++++++++++++++++++++++++++++++--------------------
1 files changed, 41 insertions(+), 20 deletions(-)
diff --git a/swiper.el b/swiper.el
index 361769e..8ad9c54 100644
--- a/swiper.el
+++ b/swiper.el
@@ -109,6 +109,7 @@
(define-key map (kbd "M-q") 'swiper-query-replace)
(define-key map (kbd "C-l") 'swiper-recenter-top-bottom)
(define-key map (kbd "C-'") 'swiper-avy)
+ (define-key map (kbd "C-7") 'swiper-mc)
map)
"Keymap for swiper.")
@@ -190,6 +191,27 @@
(ivy-quit-and-run
(avy-action-goto (caar candidate)))))))
+(declare-function mc/create-fake-cursor-at-point "ext:multiple-cursors-core")
+(declare-function mc/maybe-multiple-cursors-mode "ext:multiple-cursors-core")
+
+;;;###autoload
+(defun swiper-mc ()
+ (interactive)
+ (unless (require 'multiple-cursors nil t)
+ (error "multiple-cursors isn't installed"))
+ (let ((cands (nreverse ivy--old-cands)))
+ (unless (string= ivy-text "")
+ (ivy-set-action
+ (lambda (_)
+ (let (cand)
+ (while (setq cand (pop cands))
+ (swiper--action cand)
+ (when cands
+ (mc/create-fake-cursor-at-point))))
+ (mc/maybe-multiple-cursors-mode)))
+ (setq ivy-exit 'done)
+ (exit-minibuffer))))
+
(defun swiper-recenter-top-bottom (&optional arg)
"Call (`recenter-top-bottom' ARG)."
(interactive "P")
@@ -319,24 +341,23 @@ When non-nil, INITIAL-INPUT is the initial search
pattern."
(preselect (buffer-substring-no-properties
(line-beginning-position)
(line-end-position)))
- (minibuffer-allow-text-properties t)
- res)
+ (minibuffer-allow-text-properties t))
(unwind-protect
- (setq res (ivy-read
- "Swiper: "
- candidates
- :initial-input initial-input
- :keymap swiper-map
- :preselect preselect
- :require-match t
- :update-fn #'swiper--update-input-ivy
- :unwind #'swiper--cleanup
- :re-builder #'swiper--re-builder
- :history 'swiper-history
- :caller 'swiper))
- (if (null ivy-exit)
- (goto-char swiper--opoint)
- (swiper--action res ivy-text)))))
+ (ivy-read
+ "Swiper: "
+ candidates
+ :initial-input initial-input
+ :keymap swiper-map
+ :preselect preselect
+ :require-match t
+ :update-fn #'swiper--update-input-ivy
+ :unwind #'swiper--cleanup
+ :action #'swiper--action
+ :re-builder #'swiper--re-builder
+ :history 'swiper-history
+ :caller 'swiper)
+ (when (null ivy-exit)
+ (goto-char swiper--opoint)))))
(defun swiper--ensure-visible ()
"Remove overlays hiding point."
@@ -436,8 +457,8 @@ BEG and END, when specified, are the point bounds."
(overlay-put overlay 'priority i)))
(cl-incf i)))))))))
-(defun swiper--action (x input)
- "Goto line X and search for INPUT."
+(defun swiper--action (x)
+ "Goto line X."
(if (null x)
(user-error "No candidates")
(goto-char (point-min))
@@ -446,7 +467,7 @@ BEG and END, when specified, are the point bounds."
#'forward-line)
(1- (read (get-text-property 0 'display x))))
(re-search-forward
- (ivy--regex input) (line-end-position) t)
+ (ivy--regex ivy-text) (line-end-position) t)
(swiper--ensure-visible)
(when (/= (point) swiper--opoint)
(unless (and transient-mark-mode mark-active)
- [elpa] master 4e0c3f1 019/167: swiper-avy: show avy hints in minibuffer as well, (continued)
- [elpa] master 4e0c3f1 019/167: swiper-avy: show avy hints in minibuffer as well, Oleh Krehel, 2015/12/08
- [elpa] master 52c9565 020/167: swiper.el (swiper--candidates): Avoid line-move for large buffers, Oleh Krehel, 2015/12/08
- [elpa] master 47a220d 023/167: Support hash tables in ivy-read, Oleh Krehel, 2015/12/08
- [elpa] master 21b9edf 021/167: Fix up visual-line-mode limitation logic, Oleh Krehel, 2015/12/08
- [elpa] master 126158d 025/167: ivy.el (ivy--filter): Anchor only for swiper, Oleh Krehel, 2015/12/08
- [elpa] master 800e640 028/167: Fix "M-o k" when switching buffers, Oleh Krehel, 2015/12/08
- [elpa] master b9d0502 026/167: ivy.el (ivy--filter): Fix typo, Oleh Krehel, 2015/12/08
- [elpa] master 6956311 027/167: Adjust ivy-state-preselect for file name completion, Oleh Krehel, 2015/12/08
- [elpa] master 6f4d46b 034/167: Fix preselect for input "^", Oleh Krehel, 2015/12/08
- [elpa] master ef189f1 030/167: ivy.el (ivy-count-format): Extend customize choices, Oleh Krehel, 2015/12/08
- [elpa] master e722d6a 046/167: swiper.el (swiper-mc): Add and bind to "C-7",
Oleh Krehel <=
- [elpa] master 3a3b052 036/167: swiper.el: Add a lot of avy declares, Oleh Krehel, 2015/12/08
- [elpa] master 3699fa9 041/167: Don't reset the match to first if the current one still works, Oleh Krehel, 2015/12/08
- [elpa] master 877648a 045/167: ivy.el (ivy-case-fold-search): New defvar, Oleh Krehel, 2015/12/08
- [elpa] master 340318d 044/167: ivy-count-format must be an empty string instead of nil, Oleh Krehel, 2015/12/08
- [elpa] master 9cc75eb 050/167: Adjust the swiper regexp builder for the display change, Oleh Krehel, 2015/12/08
- [elpa] master 85682ee 048/167: Fix "C-x h" selection and "C-b" bug, Oleh Krehel, 2015/12/08
- [elpa] master 99698e6 035/167: ivy.el (ivy-dispatching-call): Add and bind to "C-M-o", Oleh Krehel, 2015/12/08
- [elpa] master 0630395 043/167: Fix the count when git-grep for "->foo", Oleh Krehel, 2015/12/08
- [elpa] master 4045349 032/167: ivy.el (ivy-use-virtual-buffers): Update docstring, Oleh Krehel, 2015/12/08
- [elpa] master f9df75e 037/167: ivy.el (ivy-index-functions-alist): New variable, Oleh Krehel, 2015/12/08