gabesoft / evil-mc

Multiple cursors implementation for evil-mode
MIT License
388 stars 36 forks source link

evil-exchange mapping with general.el breaks change with multiple cursors #50

Closed romandecker closed 7 years ago

romandecker commented 7 years ago

I have a general.el-mapping for evil-exchange which allows me to use cx to do use exchange and still have all the other evil-change commands working with c ...:

  (general-nmap "c"
    (general-key-dispatch 'evil-change
      "x" 'evil-exchange
      "X" 'evil-exchange-cancel))

The problem is that this seems to break when I have multiple evil-mc cursors active. I'm guessing evil-mc does no longer recognize the evil-change command because now there's general-key-dispatch sitting there. When I change the mapping manually back to

(general-nmap "c" 'evil-change)

evil-mc is working nicely again. Do you have any idea how I could somehow make these three (general.el, evil-exchange and evil-mc) coexist peacefully (I would be fine with evil-exchange not working when multiple cursors are active)?

gabesoft commented 7 years ago

You could use the evil-mc-before-cursors-created and evil-mc-after-cursors-deleted hooks to turn off evil change while there are cursors active. See evil-mc-setup.el for an example on how those hooks are used.

romandecker commented 7 years ago

Thanks, I was able to get it to work using this:

  (defun my/enable-evil-exchange ()
    (general-nmap "c"
      (general-key-dispatch 'evil-change
        "x" 'evil-exchange
        "X" 'evil-exchange-cancel))
    (general-vmap "c" 'evil-change))

  (defun my/disable-evil-exchange ()
    (general-nmap "c" 'evil-change))

  (my/enable-evil-exchange)
  (add-hook 'evil-mc-before-cursors-created 'my/disable-evil-exchange)
  (add-hook 'evil-mc-after-cursors-deleted 'my/enable-evil-exchange)