From db34cf6a207ee9e654d811bb862a259f038d444d Mon Sep 17 00:00:00 2001 From: Chester Wood Date: Sat, 26 Jan 2013 14:52:37 -0700 Subject: [PATCH] Merge branch 'emacs-mode' --- lib/ace/keyboard/emacs.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/ace/keyboard/emacs.js b/lib/ace/keyboard/emacs.js index 3ab016d0..93c0b2e6 100644 --- a/lib/ace/keyboard/emacs.js +++ b/lib/ace/keyboard/emacs.js @@ -66,8 +66,6 @@ exports.handler.attach = function(editor) { if (!initialized) { initialized = true; - // in emacs, gotowordleft/right should not count a space as a word.. - editor.session.$selectLongWords = true; dom.importCssString('\ .emacs-mode .ace_cursor{\ border: 2px rgba(50,250,50,0.8) solid!important;\ @@ -94,12 +92,21 @@ exports.handler.attach = function(editor) { }', 'emacsMode' ); } + // in emacs, gotowordleft/right should not count a space as a word.. + editor.session.$selectLongWords = true; + markMode = false; editor.on("click",$resetMarkMode); editor.renderer.screenToTextCoordinates = screenToTextBlockCoordinates; + // kitchen sink seems to reload the session after loading the kb handler. + editor.on("changeSession",function(e) { + e.session.$selectLongWords = true; + }); + editor.setStyle("emacs-mode"); + }; exports.handler.detach = function(editor) { @@ -323,7 +330,7 @@ exports.handler.addCommands({ selectRectangularRegion: function(editor) { editor.multiSelect.toggleBlockSelection(); }, - setMark: function() { + setMark: function(editor) { // Sets mark-mode and clears current selection. // When in mark-mode, "goto" commands become "select" commands. // Any insertion or mouse click resets mark-mode. @@ -374,9 +381,10 @@ exports.handler.addCommands({ }, killLine: function(editor) { markMode = null; + var pos = editor.getCursorPosition(); - if (editor.getCursorPosition().column == 0 && - editor.selection.isEmpty) { + if (pos.column == 0 && + editor.session.doc.getLine(pos.row).length == 0) { // If an already empty line is killed, remove // the line entirely editor.selection.selectLine();