Adding undo function to Mathematica 9
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


README to undo.m

This package adds a poor mans version control and undo functionality to Mathematica notebooks.

For a 'notebook.nb' a version information file ('') is created and every time changes are commited a backup file ('notebook.nb[version].bak') is created. Keyboard shortcuts allow an easy way to commit versions and move in between them.

Keyboard Shortcuts

Alt+z : Undo 
Alt+x : Redo 
Alt+s : Commit
Alt+d : Show CommitInfo dialog

Usage: Evaluate the following commands

ManualCommit (Default) - Only do commits manually.

AutoCommit - Turn on automatic commits. Every time a cell is evaluated a new commit is made. (This can lead to a lot of files)

CronCommit[n] - makes a new commit every n minutes.

CommitNow - Making a commit
CommitInfo - Show a list of all Versions
CommitClean - Remove all commited files

Undo - Undo to the previous commit
Redo - Undo to the next commit
GotoCommit[n] - Go to the nth version

SetVersionLimit[n] - sets max number of saved versions to the last 5

Possible issue: The present notebook might not be a commited version, so no redo is possible. Especially with ManualCommits.
When doing changes after an undo (working on not the latest version), the latest changes (when running undo or redo) are not saved, only when running 'commit' these changes are saved (to a new version). Only changes to the version with the highest version number are changed upon 'undo'. Which would be the case most of the time.

Weather a commit needs to be made when running undo is checked with a system variable that can be altered by manually saving the document. Leading to possible loss of changes. For best results do not save the notebook manually and turn auto save off - just use commit to save the work.


* do some cleaning up

Possible future improvements

* add commit clean and gotcommit button to dialog

* Change in notebook is checked using a system variable. so a manual save can lead to false conclusions. This could be fixed by a real comparison of the files. or maybe use "FileModificationTime"

* Manual commmits can still be made multiple times on the same file.

* Use Dumpsave and Get to backup and restore (at least partly) the memory state.

* Make autocommits after text was entered - not only on evaluations


Copyright 2012 Jens Boberski

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   See the License for the specific language governing permissions and
   limitations under the License.