gabesoft / evil-mc

Multiple cursors implementation for evil-mode
MIT License
383 stars 35 forks source link

Support for hybrid mode commands? #24

Open aaronjensen opened 8 years ago

aaronjensen commented 8 years ago

I use spacemacs w/ hybrid mode, as such, I often use kill-word, delete-char and probably other non-evil commands. Would you be opposed to adding support for them? I can probably submit some pulls if you're interested. Thanks!

gabesoft commented 8 years ago

I think that would be ok, as long as supporting those commands doesn't introduce too much complexity. If you do want to submit pulls don't forget to add tests for every command introduced.

aaronjensen commented 8 years ago

Maybe I'm dong something wrong, but the tests don't pass locally on emacs 25.1

The first to fail is "Scenario: Copy paste a word with count"

gabesoft commented 8 years ago

Did you do a make test-install and then a make test?

aaronjensen commented 8 years ago

Yep. I can repro the issue in my environment as well. If you have two cursors and you do a 3yw only the last cursor yanks 3 words, the first only yanked 1.

gabesoft commented 8 years ago

I wonder if this is related to #23

aaronjensen commented 8 years ago

I don't think I'm seeing any of those errors. Here is my debug output https://gist.github.com/aaronjensen/08453fcc498a1244d44b

gabesoft commented 8 years ago

Then the only thing that seems to be different for you is your version of emacs, I use 24.5.1 and I'm on a mac. I'm not sure whether that should make a difference though.

aaronjensen commented 8 years ago

I'm on a mac as well, I installed with: brew install emacs --with-cocoa --with-librsvg --with-gnutls --with-imagemagick --HEAD

On Mon, Mar 7, 2016 at 1:25 PM Gabriel Adomnicai notifications@github.com wrote:

Then the only thing that seems to be different for you is your version of emacs, I use 24.5.1 and I'm on a mac. I'm not sure whether that should make a difference though.

— Reply to this email directly or view it on GitHub https://github.com/gabesoft/evil-mc/issues/24#issuecomment-193458033.

Aaron

gabesoft commented 8 years ago

Ok, I'll try to install emacs with the same options as you when I get home and hopefully I'll be able to reproduce the problem.

gabesoft commented 8 years ago

Is your version of emacs 25.1? I tried installing exactly as you but I always get 24.5.1

aaronjensen commented 8 years ago

You may need to brew link emacs after

On Mar 7, 2016, 2:31 PM -0800, Gabriel Adomnicainotifications@github.com, wrote:

Is your version of emacs 25.1? I tried installing exactly as you but I always get 24.5.1

— Reply to this email directly orview it on GitHub(https://github.com/gabesoft/evil-mc/issues/24#issuecomment-193485753).

gabesoft commented 8 years ago

Oh, I wonder if I have to uninstall my current version first. I always get this output from brew

Warning: emacs-24.5 already installed

aaronjensen commented 8 years ago

Ah yeah. Or brew reinstall with the same args

On Mar 7, 2016, 2:53 PM -0800, Gabriel Adomnicainotifications@github.com, wrote:

Oh, I wonder if I have to uninstall my current version first. I always get this output from brew

Warning: emacs-24.5 already installed

— Reply to this email directly orview it on GitHub(https://github.com/gabesoft/evil-mc/issues/24#issuecomment-193492344).

gabesoft commented 8 years ago

Yea I can reproduce the problem now.

gabesoft commented 8 years ago

I can reproduce the problem but I'm not sure I'll have too much time to spend on this since 25.1 is not really a stable version

aaronjensen commented 8 years ago

Ok, no worries. I will say it's quite stable other than this issue and quite a bit faster. It's what I recommend people install now a days on a mac.

gabesoft commented 8 years ago

Cool, I'll take a look when I have some time. But, from what I can tell commands that contain a number don't work due to the number not being read during a command input. Not sure what the reason is but the relevant code is in evil-mc-command-record.el

gabesoft commented 8 years ago

I finally got around to fixing the tests for emacs 25.1 via this commit efc5e134524b9a88e62c3c2248112c0e8331500c

aaronjensen commented 8 years ago

Wow, that looks involved. I'm not familiar enough with it to tell what the change is that emacs 25 actually forced. Was it a breaking change in emacs 25 that caused it, not a bug?

gabesoft commented 8 years ago

Well, I took advantage of this opportunity to add some more tests and do some minor refactoring. The changes relevant to emacs 25 are only in evil-mc-command-record.el

Compro-Prasad commented 6 years ago

Any progress on this? I am using normal Emacs. The thing I don't like about multiple-cursors package is that it doesn't give me functionality of evil-mc-make-and-goto-next-match. But since I am a normal Emacs user jumping into normal mode isn't beneficial to me. I am okay with evil being installed. But I don't want it to be enabled. I know that is not possible. Still, do you have any solution to using evil-mc-make-and-goto-next-match without jumping to normal mode? I don't want evil to be enabled.

Compro-Prasad commented 6 years ago

https://github.com/magnars/multiple-cursors.el/issues/335

jackkamm commented 3 years ago

The following configuration gets evil-mc mostly working with hybrid-style editing:

(require 'cl-lib)
(require 'multiple-cursors)
(customize-set-variable
 'evil-mc-custom-known-commands
 (cl-loop for cmd in mc--default-cmds-to-run-for-all
          if (not (assoc cmd evil-mc-known-commands))
          collect `(,cmd . ((:default
                             . evil-mc-execute-default-call-with-count)))))

That is, I'm just taking all the commands that multiple-cursors.el deems safe and are not known by evil-mc-known-commands, and adding them to evil-mc-custom-known-commands with the standard executor.

For reference, below is the list of the commands added. I think it would be good to add most of these to evil-mc-known-commands so hybrid editing could be better supported out of the box. Though it might be quite a bit of work to create tests for all of them...

mc/keyboard-quit
quoted-insert
previous-line
next-line
open-line
delete-blank-lines
transpose-lines
transpose-paragraphs
transpose-regions
join-line
right-char
right-word
forward-char
forward-word
left-char
left-word
backward-char
backward-word
forward-paragraph
backward-paragraph
upcase-word
downcase-word
forward-list
backward-list
hippie-expand-lines
yank-pop
append-next-kill
kill-word
kill-line
kill-whole-line
backward-kill-word
delete-char
py-electric-backspace
cperl-electric-backspace
autopair-backspace
just-one-space
zap-to-char
end-of-line
set-mark-command
cua-set-mark
cua-replace-region
cua-delete-region
move-end-of-line
beginning-of-line
move-beginning-of-line
kill-ring-save
back-to-indentation
subword-forward
subword-backward
subword-mark
subword-kill
subword-backward-kill
subword-transpose
subword-capitalize
subword-upcase
subword-downcase
er/expand-region
er/contract-region
smart-forward
smart-backward
smart-up
smart-down