-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(evil-mc): avoid inserting the first
evil-escape
char
- Loading branch information
1 parent
5718db8
commit 99559a8
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
;;; me-evil-mc-evil-escape.el --- Hackish integration of `evil-mc' with `evil-escape' -*- lexical-binding: t; -*- | ||
|
||
;; Copyright (C) 2022-2023 Abdelhak Bougouffa | ||
|
||
;; Author: Abdelhak Bougouffa (concat "abougouffa" "@" "fedora" "project" "." "org") | ||
|
||
|
||
;; HACK: Fix the integration with `evil-escape' when in insert state. By | ||
;; default, when pressing "fd" in evil-mc insert state, the first letter "f" | ||
;; gets inserted at all fake cursors. This hack fixes this behavior. | ||
;; Taken from: github.com/gabesoft/evil-mc/issues/41#issuecomment-890887060 | ||
(+after-load! '(:all evil-escape evil-mc) | ||
(defun +evil-mc--evil-escape-move-back-fake-cursors () | ||
(unless (bolp) (backward-char))) | ||
|
||
(advice-add | ||
'evil-escape-func :before | ||
(defun +evil-mc--evil-escape-fix-a () | ||
(when (evil-mc-has-cursors-p) | ||
(evil-mc-pause-cursors) | ||
(run-with-idle-timer | ||
0 nil | ||
(lambda () | ||
(evil-mc-resume-cursors) | ||
(let ((evil-mc-command '((:name . +evil-mc-evil-escape-move-back-fake-cursors)))) | ||
(evil-mc-execute-for-all))))))) | ||
|
||
(add-to-list | ||
'evil-mc-custom-known-commands | ||
'(+evil-mc--evil-escape-move-back-fake-cursors | ||
(:default . evil-mc-execute-default-call)))) | ||
|
||
|
||
(provide 'me-evil-mc-evil-escape) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters