Skip to content
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

add emacs yank-pop M-y functionality #40

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

cjmo89
Copy link

@cjmo89 cjmo89 commented Dec 30, 2016

Hi, I've added the ability to circle through killed text as used in the emacs yank-pop command (M-y) since I believe this makes the plug in a lot more useful.
Also, I slightly modified the vscode backspace key so that it also cancels selection in addition to deleting the selected text (as it works in emacs).
I've allowed for a maximum of 20 items in the kill ring to avoid using too much memory. Feel free to change this to whatever you prefer.

Copy link
Contributor

@sammy44nts sammy44nts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

emacs behavior is not to limit the number of lines killed.
I've just killed 4705 lines from a big document without any memory issue in both emacs and vscode previous kill ring code.

@cjmo89
Copy link
Author

cjmo89 commented Jan 3, 2017

Hi, I think you misunderstood what I meant. I haven't changed the number of lines that can be killed. In fact I have left most of the kill functionality untouched.
What I meant is that you can store a maximum of 20 individual items in the kill ring, each individual item can be one line or thousands. I have checked the official emacs documentation and emacs allows for a maximum of sixty items in the kill ring, see here
I could change this number to sixty so that it works exactly like it does in emacs

@sammy44nts
Copy link
Contributor

sammy44nts commented Jan 3, 2017

Hi @TrustMeImAProgrammer, when I read your code I understand that only 20 sole lines can be killed, am I wrong? emacs behavior in that situation is to kill-append. See https://www.gnu.org/software/emacs/manual/html_node/emacs/Appending-Kills.html#Appending-Kills
That why I was able to kill 4705 sole lines in emacs ;-) By sole lines I mean pressing C-k 4705 times in a row.
I forgot to say that after killing all those lines, I pressed C-y and it yanked everything back in emacs, not just the last 60 lines.
I like that you try to implement a more powerful kill ring in vscode-emacs but emacs kill ring is much more complex than a circular buffer of 60 elements.

Copy link
Contributor

@sammy44nts sammy44nts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request should be tagged as WIP: add emacs yank-pop M-y functionality for the moment.

@@ -48,6 +48,23 @@ export class Operation {
"C-x_r": () => {
this.editor.setRMode();
},
"M-y": () => {
let that = this;
Copy link
Contributor

@sammy44nts sammy44nts Jan 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is that for? I mean do we really need yankPop to return a Promise instead of just a boolean? Can you use this to be consistent with the previous code?

},
"backspace": () => {
commands.executeCommand("deleteLeft").then(() => {
commands.executeCommand("emacs.exitMarkMode");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code should be in editor.ts to avoid the import of vscode.commands in this file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants