       editor.setBehavioursEnabled true
       editor.setShowFoldWidgets true
       editor.getSession().setUseWrapMode true
+      #console.log "setting format to #{ti.data.format}"
+      editor.getSession().setMode "ace/mode/#{ti.data.format}"
 
   keyboard: ->
     capitalize Template.instance().keyboard.get()

    e.preventDefault()
    e.stopPropagation()
    Meteor.call 'messageUpdate', t.data._id,
      format: e.target.getAttribute 'data-format'
    $(e.target).parent().dropdown 'toggle'

  'keyup input.title': (e, t) ->
    e.stopPropagation()

  #editing: -> editing @
  config: ->
    ti = Tracker.nonreactive -> Template.instance()
    (editor) =>
      #console.log 'config', editor.getValue(), '.'
      ti.editor = editor
      #editor.meteorData = @  ## currently not needed, also dunno if works
      editor.$blockScrolling = Infinity
      #editor.on 'change', onChange
      editor.setTheme 'ace/theme/monokai'
