Skip to content

Commit

Permalink
Override insert action for swiper-isearch
Browse files Browse the repository at this point in the history
* swiper.el (swiper-isearch-action-insert): New function modeled
after swiper-isearch-action-copy (abo-abo#2913, abo-abo#2914).
(swiper-isearch): Override the default 'insert' action with it.

Fixes abo-abo#2929.

Copyright-paperwork-exempt: yes
  • Loading branch information
dustinpaluch authored and basil-conto committed Mar 26, 2023
1 parent b8be491 commit 72977e2
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions swiper.el
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand Down

0 comments on commit 72977e2

Please sign in to comment.