[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 97cf30d 063/348: Add multiple-cursors support to ivy-compl
From: |
Oleh Krehel |
Subject: |
[elpa] master 97cf30d 063/348: Add multiple-cursors support to ivy-completion-in-region-action |
Date: |
Sat, 8 Apr 2017 11:03:25 -0400 (EDT) |
branch: master
commit 97cf30dc9cb5473a1d6b0ff67950be556eb3de31
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Add multiple-cursors support to ivy-completion-in-region-action
* ivy.el (ivy-completion-in-region-action): Do the same thing for each
cursor as for point, with respective offset.
Fixes #547
---
ivy.el | 35 ++++++++++++++++++++++++++---------
1 file changed, 26 insertions(+), 9 deletions(-)
diff --git a/ivy.el b/ivy.el
index b661a6d..f4f590d 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1635,20 +1635,37 @@ INHERIT-INPUT-METHOD is currently ignored."
(defvar ivy-completion-end nil
"Completion bounds end.")
+(declare-function mc/all-fake-cursors "ext:multiple-cursors-core")
+
(defun ivy-completion-in-region-action (str)
"Insert STR, erasing the previous one.
The previous string is between `ivy-completion-beg' and `ivy-completion-end'."
(when (stringp str)
(with-ivy-window
- (when ivy-completion-beg
- (delete-region
- ivy-completion-beg
- ivy-completion-end))
- (setq ivy-completion-beg
- (move-marker (make-marker) (point)))
- (insert (substring-no-properties str))
- (setq ivy-completion-end
- (move-marker (make-marker) (point))))))
+ (let ((fake-cursors (and (featurep 'multiple-cursors)
+ (mc/all-fake-cursors)))
+ (pt (point))
+ (beg ivy-completion-beg)
+ (end ivy-completion-end))
+ (when ivy-completion-beg
+ (delete-region
+ ivy-completion-beg
+ ivy-completion-end))
+ (setq ivy-completion-beg
+ (move-marker (make-marker) (point)))
+ (insert (substring-no-properties str))
+ (setq ivy-completion-end
+ (move-marker (make-marker) (point)))
+ (save-excursion
+ (dolist (cursor fake-cursors)
+ (goto-char (overlay-start cursor))
+ (delete-region (+ (point) (- beg pt))
+ (+ (point) (- end pt)))
+ (insert (substring-no-properties str))
+ ;; manually move the fake cursor
+ (move-overlay cursor (point) (1+ (point)))
+ (move-marker (overlay-get cursor 'point) (point))
+ (move-marker (overlay-get cursor 'mark) (point))))))))
(defun ivy-completion-common-length (str)
"Return the length of the first 'completions-common-part face in STR."
- [elpa] master ac1dc5b 034/348: counsel.el (counsel-company): New command, (continued)
- [elpa] master ac1dc5b 034/348: counsel.el (counsel-company): New command, Oleh Krehel, 2017/04/08
- [elpa] master cba67e4 038/348: counsel.el (counsel-bookmark): Add require, Oleh Krehel, 2017/04/08
- [elpa] master 3d48093 027/348: counsel.el (counsel--gg-sentinel): Add a work around, Oleh Krehel, 2017/04/08
- [elpa] master ddb4681 025/348: counsel.el (counsel-git-grep-cmd-default): New defvar, Oleh Krehel, 2017/04/08
- [elpa] master cf38ceb 040/348: swiper.el (swiper-font-lock-exclude): Add forth-mode, Oleh Krehel, 2017/04/08
- [elpa] master ab55e03 055/348: counsel.el (counsel-set-variable): Add :preselect, Oleh Krehel, 2017/04/08
- [elpa] master f4ec789 056/348: counsel.el (counsel-set-variable): Fix 2nd preselect, Oleh Krehel, 2017/04/08
- [elpa] master 792b7b7 051/348: counsel.el (counsel-set-variable): New command, Oleh Krehel, 2017/04/08
- [elpa] master dc4a858 060/348: counsel.el (counsel-hydra-heads): New command, Oleh Krehel, 2017/04/08
- [elpa] master cd8a570 062/348: Escape `%` chars if present in the symbol value, Oleh Krehel, 2017/04/08
- [elpa] master 97cf30d 063/348: Add multiple-cursors support to ivy-completion-in-region-action,
Oleh Krehel <=
- [elpa] master 8c7a7fc 028/348: When reading file names, check preselect and initial-input compat, Oleh Krehel, 2017/04/08
- [elpa] master 5d0fec1 032/348: ivy.el: Fix some checkdoc warnings, Oleh Krehel, 2017/04/08
- [elpa] master 2e1cebc 036/348: counsel.el (counsel-bookmark): Add, Oleh Krehel, 2017/04/08
- [elpa] master a566403 044/348: ivy.el (ivy-read): Document all args, Oleh Krehel, 2017/04/08
- [elpa] master baf89c0 054/348: ivy-test.el (colir-color-parse): Add test, Oleh Krehel, 2017/04/08
- [elpa] master be24b57 049/348: Revert "ivy.el (ivy-completion-in-region): Fix double insert bug", Oleh Krehel, 2017/04/08
- [elpa] master 77fb030 052/348: ivy.el (ivy-completion-in-region): Fix common length longer than str, Oleh Krehel, 2017/04/08
- [elpa] master 7280e19 050/348: ivy.el (ivy-completion-common-length): Fix double insert bug, Oleh Krehel, 2017/04/08
- [elpa] master 288723e 065/348: counsel.el (counsel-set-variable): Allow new symbols, Oleh Krehel, 2017/04/08
- [elpa] master fe32959 066/348: ivy.el (ivy--actionp): Fix lambda being considered a list of actions, Oleh Krehel, 2017/04/08