syl20bnr / evil-escape

Customizable key sequence to escape from insert state and everything else in Emacs.
GNU General Public License v3.0
225 stars 42 forks source link

Weird indentation effect when using evil-escape-key-sequence? #69

Open zzantares opened 8 years ago

zzantares commented 8 years ago

Hi, I'm having a little annoyance when using the evil-escape-key-sequence, basically when I do kj the indentation on the current line is modified. In the following animation I just want to add the close parenthesis ) in it's own line but keep it currently indented, so I just do RET and the ) gets correctly indented but as soon as I escape kj the ) moves out.

evil-escape

In the animation I do a second test but now pressing ESC and you can see it works fine without moving out the ), so it's only happening when using the key sequence.

Is there any magic setting I could use to avoid this effect?

Thanks

zzantares commented 8 years ago

Do you have any suspicion of why is this happening @syl20bnr? I could try to look in to this but I don't where or what to search in the code.

Thanks.

NateEag commented 8 years ago

This happens because of the temporary insertion of the first letter of the escape sequence.

Some modes automatically indent code whenever you insert a character, and aggressive-indent-mode will let you get that behavior even in modes that don't.

I think you're probably dealing with one of those.

zzantares commented 8 years ago

Thanks @NateEag so the problem is in the mode itself? I'll look in to that.

Thanks.

NateEag commented 8 years ago

@ZzAntares That's my belief, anyway. I have not actually tested your scenario myself.

However, the insert-first-keystroke-then-delete-it-on-second-one behavior has been causing me similar frustrations with my hacked version of aggressive-fill-mode.

My unpolished changes to aggressive-fill-mode make it fill after every character insertion.

Thus, when the first letter of my escape sequence gets inserted, it triggers a fill, which happens with the character in place.

On the next keystroke, the j is erased, which does not trigger a fill, and thus leaves my paragraph filled slightly wrong.

It also bites me if I escape after entering a blank line below a paragraph. The temporary character makes fill-paragraph see the line as not blank, then filling is triggered, so the j is moved up a line, then deleted, effectively erasing the blank line I just entered.

That's not really related to this issue - just wanted to explain the reasons behind my diagnosis. Your issue sounds very similar to the ones I've been having, so I assume it's the same cause.

I don't have a good solution for either case at the moment, just this analysis.

NateEag commented 8 years ago

addendum - I realized today that the paragraph removal I was seeing was due to a mistake I made while trying to eliminate the first problem I described. I thought I'd reverted the bad change, but apparently it stuck around somehow.

The above is probably still useful in understanding the behavior described in this issue, but the second behavior was not something that would have been reproducible outside my personal config.

syl20bnr commented 8 years ago

We may be able to fix this by temporarily inhibiting minor modes that auto-intend things on insertion.

If you can provide a quick repro step I should be able to identify the minor mode and provide a fix.

Le vendredi 4 novembre 2016, Nate Eagleson notifications@github.com a écrit :

addendum - I realized today that the paragraph removal I was seeing was due to a mistake I made while trying to eliminate the first problem I described. I thought I'd reverted the bad change, but apparently it stuck around somehow.

The above is probably still useful in understanding the behavior described in this issue, but the second behavior was not something that would have been reproducible outside my personal config.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/syl20bnr/evil-escape/issues/69#issuecomment-258450976, or mute the thread https://github.com/notifications/unsubscribe-auth/ABL5kdJ9xvU3f6whDTsu03Aop0uh7AHPks5q60WAgaJpZM4JBqIj .

-syl20bnr-

zzantares commented 8 years ago

Thanks @syl20bnr, here is what I did to reproduce the issue outside of my own emacs:

(evil-mode 1)
(evil-escape-mode 1)
(setq-default evil-escape-key-sequence "kj")
(setq-default evil-escape-delay 0.3)
(global-set-key (kbd "<escape>") 'evil-escape)

If you repeat the steps but escaping with ESC the closing parenthesis does not move, this is the preferred behavior.

Thanks!

Linuus commented 5 years ago

Do we have some kind of workaround for this issue?

zzantares commented 5 years ago

For the record, I no longer use evil-escape, I've accustomed my self to use C-[, my Ctrl key is my caps lock and the right pinky is very near the [ so it feels very natural. Needless to say that the behavior described is no longer an issue for me.