evil-mc icon indicating copy to clipboard operation
evil-mc copied to clipboard

Support for hybrid mode commands?

Open aaronjensen opened this issue 8 years ago • 23 comments

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!

aaronjensen avatar Mar 04 '16 16:03 aaronjensen

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.

gabesoft avatar Mar 04 '16 18:03 gabesoft

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"

aaronjensen avatar Mar 07 '16 06:03 aaronjensen

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

gabesoft avatar Mar 07 '16 06:03 gabesoft

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.

aaronjensen avatar Mar 07 '16 06:03 aaronjensen

I wonder if this is related to #23

gabesoft avatar Mar 07 '16 06:03 gabesoft

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

aaronjensen avatar Mar 07 '16 20:03 aaronjensen

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.

gabesoft avatar Mar 07 '16 21:03 gabesoft

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 [email protected] 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

aaronjensen avatar Mar 07 '16 21:03 aaronjensen

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 avatar Mar 07 '16 21:03 gabesoft

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

gabesoft avatar Mar 07 '16 22:03 gabesoft

You may need to brew link emacs after

On Mar 7, 2016, 2:31 PM -0800, Gabriel [email protected], 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).

aaronjensen avatar Mar 07 '16 22:03 aaronjensen

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

gabesoft avatar Mar 07 '16 22:03 gabesoft

Ah yeah. Or brew reinstall with the same args

On Mar 7, 2016, 2:53 PM -0800, Gabriel [email protected], 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).

aaronjensen avatar Mar 07 '16 23:03 aaronjensen

Yea I can reproduce the problem now.

gabesoft avatar Mar 07 '16 23:03 gabesoft

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

gabesoft avatar Mar 08 '16 00:03 gabesoft

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.

aaronjensen avatar Mar 08 '16 01:03 aaronjensen

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 avatar Mar 08 '16 01:03 gabesoft

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

gabesoft avatar Mar 21 '16 07:03 gabesoft

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?

aaronjensen avatar Mar 21 '16 14:03 aaronjensen

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

gabesoft avatar Mar 21 '16 15:03 gabesoft

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 avatar Jun 15 '18 07:06 Compro-Prasad

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

Compro-Prasad avatar Jun 15 '18 11:06 Compro-Prasad

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

jackkamm avatar Oct 10 '20 22:10 jackkamm