How to customize autocomplete function of the CodeMirror
<p>I want to customize an autocomplete function to Codemirror.</p>

<p>So I have build this code:</p>

<pre><code>    CodeMirror.commands.autocomplete = function (cm) {
    var arrayTabNONDefault = new Array();
    var stringaCampi = null;
    var arrayTabellaCampo = null;
    var textVal = cm.getValue();
    textVal = textVal.toUpperCase();

    var res = textVal.match("SELECT(.*)FROM");
    if (res != null) {
    stringaCampi = res[1];
    arrayTabellaCampo = stringaCampi.split(",");
    var nomeTab = null;
    for (var i = 0; i &lt; arrayTabellaCampo.length; i++) {
        nomeTab = (arrayTabellaCampo[i].split(".")[0]).trim();
        if (hintTables[nomeTab] == null)
        hintTables[nomeTab] = new Array();
    } //FINE FOR
    } //FINE IF

    CodeMirror.showHint(cm, CodeMirror.hint.sql, {
    tables: hintTables
    });

    cm.on("beforeChange", function (cm, change) {
    var before = cm.getRange({ line: 0, ch: 0 }, change.from);
    var text = cm.getRange(change.from, change.to);
    var after = cm.getRange(change.to, { line: cm.lineCount() + 1, ch: 0 });
    if (before.indexOf("FROM") !== -1)
    //                            alert("Ho scritto FROM");
        console.log("before change", before, text, after);
    });

    cm.on("change", function (cm, change) {
    var from = change.from;
    var text = change.text.join("\n");
    var removed = change.removed.join("\n");
    var to = cm.posFromIndex(cm.indexFromPos(from) + text.length);

    var before = cm.getRange({ line: 0, ch: 0 }, from);
    var after = cm.getRange(to, { line: cm.lineCount() + 1, ch: 0 });

    if (before.indexOf("FROM") !== -1)
        console.log("after change", before, removed, text, after);
    });


} //FINE ESTENSIONE
</code></pre>

<p>This is the content of hintTables</p>

<pre><code>var hintTables = { "#T_TF_FilesList": ["FilesListHeaderID", "NumRecord", "FileTypeID", "FileID", "FilesListHeaderID", "NumRecord"],
            "#T_TF_SelectedItems": ["EventHeaderID", "ItemType", "ItemID1", "ItemID2", "EventHeaderID", "ItemType", "ItemID1", "ItemID2"],
            "#T_TFT_CacheSearchCriteriaHeaders": ["ID", "SyncDate", "FileTypeID", "CriteriaExpressionString", "CriteriaExpressionHash", "PageRecordsNumber", "PageNumber", "NumFiles"]
        };
</code></pre>

<p>So I want that the system should propose a list of this table after I write FROM, or the system should to propose a list of stored procedures after I write EXECUTE.</p>

<p>It is possible to do this?</p>