-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
REPL: implement a kill ring #23377
REPL: implement a kill ring #23377
Conversation
@Keno do you have an idea why some sentinel values other than '\0' don't work, and whether the new value here, which seems to work, is ok? |
Should be ok. Terminals shouldn't really give you private plane Chars. In fact some of them (e.g. iTerm2) use private plane chars to store metadata, so they don't support them either. |
a0a04f2
to
5dd8843
Compare
Thanks for your answer Keno! |
'\0' was used as a sentinel for self-insert (spelled "*" in keymaps), which made it un-available for Ctrl-Space combo. We replace here '\0' with an un-assigned sentinel Char value.
* add possibility to set the "mark" in the edit area, with C-Space * the mark and current position (the "point") delimit a region * C-x C-x exchanges the mark with the point * M-w is set to copy the region into the kill buffer * M-W is set to kill the region into the kill buffer (in Emacs, the binding for this is C-w, but it's already taken by edit_werase)
After a yank ("^Y"), it's possible to "yank-pop" with the "M-y" binding, which replaces the just-yanked text with an older entry from the "kill-ring".
All call sites of `splice_buffer!` were manually substracting 1 to the last position of the range, indicating that it's more natural to specify a region with an open-close range. Therefore, `splice_buffer!` and `edit_replace` (thin wrapper of `splice_buffer!`) are merged into `edit_splice!`, which takes a `Region` (a pair of integers) object instead of a range.
5dd8843
to
8422d50
Compare
This fixes part of #8447. In order to implement a kill ring, which is a stack of previously killed region of text, the concept of "region" is indeed needed: after a "yank" ("C-y"), one can replace the yanked text with an older entry in the kill-ring via "M-y" (so the REPL must remember the region consisting of the first yanked text). While I was at it, it's now possible to "set the mark" with "C-Space", to copy/kill the current region with "M-w/M-W", and to exchange the mark with the current position with "C-xC-x". As "M-y" is normally possible only after a yank, commands can now return a symbol which will be remembered till the next command (kind of similar to "key repeats", but with more information).
There are still probably few bugs, but if someone is willing to review, I would require attention particularly on the following: previously, the char
'\0'
was used as a sentinel to indicate "wildcard" ("*"), but this conflicts with the code sent by "C-Space". So I chose another sentinel value, but I know very littly about UTF8; For some characters I got errors, for others I didn't get a functional REPL (sentinel not recognized, so no printed letters when matching "*"). The chosen working sentinel value is in a "Private Use range" (I got it from the code fromrand(::Char)
).