dbcli / mycli

A Terminal Client for MySQL with AutoCompletion and Syntax Highlighting.
http://mycli.net
Other
11.5k stars 664 forks source link

Word-moving commands are inconsistent at least in Emacs mode #1083

Closed doublep closed 2 years ago

doublep commented 2 years ago

Version 1.25.0

I'm using Emacs mode. Different word movement commands in mycli appear to work inconsistently not only with Emacs, but also within the program itself.

Example ([^] denotes the cursor):

[^]foo.bar.baz [M-right] -> foo[^].bar.baz [M-right] -> foo.[^]bar.baz [M-right] -> foo.bar[^].baz [M-right] -> foo.bar.[^]baz,

but:

[^]foo.bar.baz [M-f] -> foo[^].bar.baz [M-f] -> foo.bar[^].baz [M-f] -> foo.bar.baz[^],

so M-right stops both after word end and before word start, while M-f behaves like in Emacs (only stops after word end).

In general, it appears that M-\ commands behave like in Emacs, but others don't. However, instead of giving you more options, this rather breaks editing habits. E.g. in Emacs itself M-right is just like M-f (except for bidirectional stuff, which most people who don't use Arabic etc. don't even know anyway). Someone using Emacs expects them to be interchangeably.

Even worse is M-d vs. M-backspace, because for the latter there is apparently no analogue in mycli that behaves like in Emacs. So, if you delete words forward (M-d) it behaves like in Emacs, but if backward (M-backspace) it doesn't. Gah!

It would be nice if in Emacs mode all word commands behaved like in Emacs. I wouldn't mind if this was controlled by an option (to me the current behavior unquestionably appears broken, but it's OK if I have to edit the config file once to fix it).

Speaking of which, I hate that word-moving commands consider _ part of a word. I have some table names of ~25 characters and it's very annoying when M-d deletes the whole name when I just wanted to replace one word within it. Another inconsistency with Emacs for me.

rolandwalker commented 2 years ago

Hi! Do you have ptpython installed? Or some other program that uses https://github.com/prompt-toolkit ?

Mycli overrides very few keys in https://github.com/dbcli/mycli/blob/main/mycli/key_bindings.py , and the rest are inherited from prompt-toolkit. When I start ptpython which uses prompt-toolkit, I get the same inconsistent behavior you describe. Maybe there's some reason for it, but as an Emacser I tend to agree with you.

doublep commented 2 years ago

No. I installed it to check if it makes any difference, and apparently it doesn't: same behavior with and without it as far as I can tell.

doublep commented 2 years ago

Guess I misunderstood. Maybe you could redirect the bug report to the library then? I have little knowledge of how Python works.

rolandwalker commented 2 years ago

Sorry if I was uncleear. Yes, the issue you describe lies in the library https://github.com/prompt-toolkit not with this project. But we are friendly projects! I think you should open an issue there, and @ me and/or link this issue as it already has your perfect description.