emacs: add contents of copy/cut editor events to killring

This commit is contained in:
Robert Krahn 2013-05-26 18:52:57 -07:00
commit ee76ccad19

View file

@ -112,6 +112,8 @@ exports.handler.attach = function(editor) {
editor.commands.addCommands(commands);
exports.handler.platform = editor.commands.platform;
editor.$emacsModeHandler = this;
editor.addEventListener('copy', this.onCopy);
editor.addEventListener('paste', this.onPaste);
};
exports.handler.detach = function(editor) {
@ -122,6 +124,8 @@ exports.handler.detach = function(editor) {
editor.removeEventListener("changeSession", $kbSessionChange);
editor.unsetStyle("emacs-mode");
editor.commands.removeCommands(commands);
editor.removeEventListener('copy', this.onCopy);
editor.removeEventListener('paste', this.onPaste);
};
var $kbSessionChange = function(e) {
@ -157,6 +161,13 @@ combinations.forEach(function(c) {
eMods[hashId] = c.toLowerCase() + "-";
});
exports.handler.onCopy = function(e, editor) {
if (editor.$handlesEmacsOnCopy) return;
editor.$handlesEmacsOnCopy = true;
exports.handler.commands.killRingSave.exec(editor);
delete editor.$handlesEmacsOnCopy;
}
exports.handler.bindKey = function(key, command) {
if (!key)
return;