Targeting a specific language for buffer changed event


Currently I am using the following code to bind a buffer changed event for all Editors with grammar type ‘HTML’:

    editorView.command('editor:grammar-changed', {}, function() {
        var grammar = editorView.editor.getGrammar();
        if( === 'HTML') {
            editorView.editor.buffer.on('changed', fcn);
        } else {
  'changed', fcn);

It work’s well enough, however I see some situations it might break down. Specifically if I were editing HTML in a PHP file, which would assumedly be assigned a grammar type PHP instead of HTML.

I could solve the issue by allowing the user to define grammar names to support, however that’s kind of annoying for users. It would be nice if I could do something like the following so that the event would fire anytime an .html line is edited rather than relying on the selected grammar

    editorView.command('buffer:changed', '.html', fcn);

I’ve tried different events: ‘buffer:changed’, ‘changed’, ‘editor:contents-modifed’, ‘content-modified’ but nothing seems to get captured.


The buffer events aren’t bubbled up to the editorView. But contents-modified is triggered on Editor instances.