dbuenzli / down

An OCaml toplevel (REPL) upgrade
http://erratique.ch/software/down
ISC License
84 stars 3 forks source link

Support ^W (Ctrl-W) #25

Open kit-ty-kate opened 4 years ago

kit-ty-kate commented 4 years ago

I use ^W (delete from current character to beginning of current word*) quite a lot in shell or in my text editors. I think it might be good to have it in down as well.

*: a word can more or less be defined as [a-z A-Z 0-9 (unicode alphanums)]+. I think an implementation that sets _ as a word separator would be especially useful for OCaml code.

dbuenzli commented 4 years ago

Isn't that M-backspace ?

dbuenzli commented 4 years ago

Ping @kit-ty-kate

kit-ty-kate commented 4 years ago

Mmh, it seems similar but not exactly the same. For instance with emacs I can have the following OCaml program:

let x = print_endline "blah";;

if the cursor is at the end, it will cut in order: ";;, then blah, then ", then endline, then _, then print, then =, then x, then let. Whereas M-backspace will cut in order: "blah";;, then print_endline, then =, then x, then let.

I think especially for OCaml programs, which use mostly the snake_case naming convention, it makes sense to propose a method of removing words a bit more fine grade.

dbuenzli commented 4 years ago

I think especially for OCaml programs, which use mostly the snake_case naming convention, it makes sense to propose a method of removing words a bit more fine grade.

TBH that feels a bit too fine grained to me. Especially when you have completion at your finger tips. How often to you refine an identifier according to _ segments ? My bet is that this is quite rare.

frou commented 4 years ago

Isn't ^W as "dumb" kill-word a conventional Unix CLI binding as old as time? (like its friends ^H ^D ^U ^K).

From that perspective, the issue is that what's currently on M-backspace should be on ^W according to a lot of peoples' muscle memory.

dbuenzli commented 4 years ago

According to readline's manual yes. I don't mind adding this. Just not the interpretation @kit-ty-kate wanted w.r.t. to _.

frou commented 4 years ago

Got it. Speaking of Readline, I guess the following in Bash shows an everyday comparison of C-w and M-backspace.

$ cat path/to/something

With the cursor after the path, C-w will delete the entire path, whereas M-backspace will delete one path component at a time.