[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ivy 72977e2664 1/5: Override insert action for swiper-i
From: |
Basil L. Contovounesios |
Subject: |
[elpa] externals/ivy 72977e2664 1/5: Override insert action for swiper-isearch |
Date: |
Sun, 26 Mar 2023 09:22:32 -0400 (EDT) |
branch: externals/ivy
commit 72977e2664ee459d431ffb95447e5483bd40b611
Author: Dustin Paluch <dustin@alley.co>
Commit: Basil L. Contovounesios <contovob@tcd.ie>
Override insert action for swiper-isearch
* swiper.el (swiper-isearch-action-insert): New function modeled
after swiper-isearch-action-copy (#2913, #2914).
(swiper-isearch): Override the default 'insert' action with it.
Fixes #2929.
Copyright-paperwork-exempt: yes
---
swiper.el | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/swiper.el b/swiper.el
index ba9ed6b9c6..191bcdfba6 100644
--- a/swiper.el
+++ b/swiper.el
@@ -1533,7 +1533,21 @@ Return to original position."
(kill-new (match-string 0)))
(goto-char swiper--opoint)))
+(defun swiper-isearch-action-insert (cand)
+ "Insert `swiper-isearch' candidate CAND where invoked."
+ (unwind-protect
+ (progn
+ (unless (and (setq cand (swiper--isearch-candidate-pos cand))
+ ;; FIXME: Better way of getting current candidate?
+ (goto-char cand)
+ (looking-back (ivy-re-to-str ivy-regex) (point-min)))
+ (error "Could not insert `swiper-isearch' candidate: %S" cand))
+ (goto-char swiper--opoint)
+ (insert (match-string 0)))
+ (goto-char swiper--opoint)))
+
(ivy-add-actions 'swiper-isearch '(("w" swiper-isearch-action-copy "copy")))
+(ivy-add-actions 'swiper-isearch '(("i" swiper-isearch-action-insert
"insert")))
(ivy-add-actions 'swiper '(("w" swiper-action-copy "copy")))
(defun swiper-isearch-thing-at-point ()