   if delta.endLength < delta.startLength + offset
     lastChangeIndex = delta.endLength
   return lastChangeIndex
+
+_change = (source, dest) ->
+  if @stack[source].length > 0
+    change = @stack[source].pop()
+    _ignoreChanges.call(this, =>
+      @editor.applyDelta(change[source], { source: 'user' })
+      index = getLastChangeIndex(change[source])
+      @editor.setSelection(new Scribe.Range(@editor, index, index))
+    )
+    @stack[dest].push(change)
 
 _ignoreChanges = (fn) ->
   oldIgnoringChanges = @ignoringChanges

    )

  clear: ->
    @undoStack = []
    @redoStack = []
    @oldDelta = @editor.getDelta()

  record: (changeDelta, oldDelta) ->

    )

  undo: ->
    _change.call(this, 'undo', 'redo')


module.exports = Scribe
