fix(multiple-cursors): check evil-local-mode instead of the global one
For evil compatibility (switching to emacs state during multiple cursors), when evil is enabled locally by evil-local-mode but not globally by evil-mode, using the former to check is more accurate. Also make the state variables local since MC maybe used for multiple buffers: activate current buffer and while not deactivating here, go to another buffer and activate there.
This commit is contained in:
parent
6aa9ebae64
commit
23c0eeba45
1 changed files with 4 additions and 4 deletions
|
@ -175,12 +175,12 @@
|
|||
(when (modulep! :editor evil)
|
||||
(evil-define-key* '(normal emacs) mc/keymap [escape] #'mc/keyboard-quit)
|
||||
|
||||
(defvar +mc--compat-evil-prev-state nil)
|
||||
(defvar +mc--compat-mark-was-active nil)
|
||||
(defvar-local +mc--compat-evil-prev-state nil)
|
||||
(defvar-local +mc--compat-mark-was-active nil)
|
||||
|
||||
(add-hook! 'multiple-cursors-mode-enabled-hook
|
||||
(defun +multiple-cursors-compat-switch-to-emacs-state-h ()
|
||||
(when (and (bound-and-true-p evil-mode)
|
||||
(when (and (bound-and-true-p evil-local-mode)
|
||||
(not (memq evil-state '(insert emacs))))
|
||||
(setq +mc--compat-evil-prev-state evil-state)
|
||||
(when (region-active-p)
|
||||
|
@ -210,7 +210,7 @@
|
|||
;; how evil deals with regions
|
||||
(defadvice! +multiple--cursors-adjust-mark-for-evil-a (&rest _)
|
||||
:before #'mc/edit-lines
|
||||
(when (and (bound-and-true-p evil-mode)
|
||||
(when (and (bound-and-true-p evil-local-mode)
|
||||
(not (memq evil-state '(insert emacs))))
|
||||
(if (> (point) (mark))
|
||||
(goto-char (1- (point)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue