<commit_before>var createPane = require('atom-pane');
var $ = require('jquery');

function postIframeMessage(iframe, message) {
    iframe.contentWindow.messageData = message;
    iframe.contentWindow.messageHandler();
}
function newEditor(dispose, edset, editor, iframe) {
    var oldPath = editor.getPath();
    postIframeMessage(
        iframe,
        {type: "new-buffer",
         file: editor.getPath(),
         text: editor.getText()});
    edset[oldPath] = editor;
    dispose.push(editor.onDidChangePath(function() {
        postIframeMessage(
            iframe,
            {type: "rename-buffer",
             file: editor.getPath(),
             last: oldPath});
        delete edset[oldPath];
        edset[editor.getPath()] = editor;
    }));
    dispose.push(editor.onDidStopChanging(function() {
        postIframeMessage(
            iframe,
            {type: "change-buffer",
             file: editor.getPath(),
             text: editor.getText()});
    }));
    oldPath = editor.getPath();
};

function sendDownEditorList(dispose, edset, iframe) {
    var editors = atom.workspace.getTextEditors();
    for (var i = 0; i < editors.length; i++) {
        var editor = editors[i];
        newEditor(dispose, edset, editor, iframe);
    }
}

module.exports.activate = function() {
    atom.workspaceView.command("ymacs-editor:create", function() {
        var ydiv = $(document.createElement('div'));
        var dispose = [];
        var editors = {};

        createPane(function(err, pane) {
            if (err)
                throw err;<commit_msg>Use atom.commands. A little armor around our message passer.<commit_after>var createPane = require('atom-pane');
var $ = require('jquery');

function postIframeMessage(iframe, message) {
    if (iframe.contentWindow) {
        iframe.contentWindow.messageData = message;
        iframe.contentWindow.messageHandler();
    }
}
function newEditor(dispose, edset, editor, iframe) {
    var oldPath = editor.getPath();
    postIframeMessage(
        iframe,
        {type: "new-buffer",
         file: editor.getPath(),
         text: editor.getText()});
    edset[oldPath] = editor;
    dispose.push(editor.onDidChangePath(function() {
        postIframeMessage(
            iframe,
            {type: "rename-buffer",
             file: editor.getPath(),
             last: oldPath});
        delete edset[oldPath];
        edset[editor.getPath()] = editor;
    }));
    dispose.push(editor.onDidStopChanging(function() {
        postIframeMessage(
            iframe,
            {type: "change-buffer",
             file: editor.getPath(),
             text: editor.getText()});
    }));
    oldPath = editor.getPath();
};

function sendDownEditorList(dispose, edset, iframe) {
    var editors = atom.workspace.getTextEditors();
    for (var i = 0; i < editors.length; i++) {
        var editor = editors[i];
        newEditor(dispose, edset, editor, iframe);
    }
}

module.exports.activate = function() {
    atom.commands.add("atom-workspace", "ymacs-editor:create", function() {
        var ydiv = $(document.createElement('div'));
        var dispose = [];
        var editors = {};

        createPane(function(err, pane) {
            if (err)
                throw err;
{'fraction_non_alphanumeric': 0.13767670559311618, 'fraction_numerical': 0.0006146281499692685, 'mean_word_length': 2.4517497348886534, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5858331', 'n_tokens_mistral': 981, 'n_tokens_neox': 939, 'n_words': 192}