 Serializable = require 'serializable'
 Delegator = require 'delegato'
 {includeDeprecatedAPIs, deprecate} = require 'grim'
-{Model} = require 'theorist'
 EmitterMixin = require('emissary').Emitter
 {CompositeDisposable, Emitter} = require 'event-kit'
 {Point, Range} = TextBuffer = require 'text-buffer'
 LanguageMode = require './language-mode'
 DisplayBuffer = require './display-buffer'
 Cursor = require './cursor'
+Model = require './model'
 Selection = require './selection'
 TextMateScopeSelector = require('first-mate').ScopeSelector
 {Directory} = require "pathwatcher"


  subscribeToBuffer: ->
    @buffer.retain()
    @subscribe @buffer.onDidChangePath =>
      unless atom.project.getPaths().length > 0
        atom.project.setPaths([path.dirname(@getPath())])
      @emit "title-changed" if includeDeprecatedAPIs
      @emitter.emit 'did-change-title', @getTitle()
      @emit "path-changed" if includeDeprecatedAPIs
      @emitter.emit 'did-change-path', @getPath()
    @subscribe @buffer.onDidChangeEncoding =>
      @emitter.emit 'did-change-encoding', @getEncoding()
    @subscribe @buffer.onDidDestroy => @destroy()

    # TODO: remove these when we remove the deprecations. They are old events.
    if includeDeprecatedAPIs

      @mutateSelectedText (selection) =>
        range = selection.insertText(text, options)
        didInsertEvent = {text, range}
        @emit('did-insert-text', didInsertEvent) if includeDeprecatedAPIs
        @emitter.emit 'did-insert-text', didInsertEvent
        range
    else
