 
   constructor: ({@bufferMarker, @displayBuffer}) ->
     @emitter = new Emitter
+    @disposables = new CompositeDisposable
     @id = @bufferMarker.id
     @oldHeadBufferPosition = @getHeadBufferPosition()
     @oldHeadScreenPosition = @getHeadScreenPosition()

    @displayBuffer.pixelRangeForScreenRange(@getScreenRange(), false)

if Grim.includeDeprecations
  {Subscriber} = require 'emissary'
  EmitterMixin = require('emissary').Emitter
  EmitterMixin.includeInto(Marker)
  Subscriber.includeInto(Marker)

  Marker::on = (eventName) ->
    switch eventName

    @oldTailScreenPosition = @getTailScreenPosition()
    @wasValid = @isValid()

    @disposables.add @bufferMarker.onDidDestroy => @destroyed()
    @disposables.add @bufferMarker.onDidChange (event) => @notifyObservers(event)

  # Essential: Destroys the marker, causing it to emit the 'destroyed' event. Once
  # destroyed, a marker cannot be restored by undo/redo operations.
  destroy: ->
    @bufferMarker.destroy()
    @disposables.dispose()

  # Essential: Creates and returns a new {Marker} with the same properties as this
  # marker.
