 
   preserveCursorPositionOnBufferReload: ->
     cursorPosition = null
-    @buffer.on "will-reload.edit-session-#{@id}", =>
+    @subscribe @buffer, "will-reload", =>
       cursorPosition = @getCursorBufferPosition()
-    @buffer.on "reloaded.edit-session-#{@id}", =>
+    @subscribe @buffer, "reloaded", =>
       @setCursorBufferPosition(cursorPosition) if cursorPosition
       cursorPosition = null
 
 _.extend(EditSession.prototype, EventEmitter)
+_.extend(EditSession.prototype, Subscriber)


module.exports =
class EditSession
  @idCounter: 1

  @deserialize: (state, project) ->
    if fs.exists(state.buffer)
      session = project.buildEditSessionForPath(state.buffer)

  softWrap: false

  constructor: ({@project, @buffer, tabLength, @autoIndent, softTabs, @softWrap }) ->
    @softTabs = @buffer.usesSoftTabs() ? softTabs ? true
    @languageMode = new LanguageMode(this, @buffer.getExtension())
    @displayBuffer = new DisplayBuffer(@buffer, { @languageMode, tabLength })
