title: How Emacs determines a unit of work to undo
body: <p>When you enter the command <kbd>C-/</kbd>, Emacs undoes some part of your recent changes to a buffer. When you enter <kbd>C-/</kbd> again, it undoes another chunk of work.</p>
  
  <p>I have read the <a href="http://www.gnu.org/software/emacs/manual/html_node/emacs/Undo.html#Undo" rel="noreferrer">Emacs manual entry on Undo</a> but it is vague about exactly how it works. The manual says "Consecutive character insertion commands are usually grouped together into a single undo record" but it does not explain how it decides the number of character insertion commands that constitute a group. The number of characters it puts in a group seems random.</p>
  
  <p>Can anyone explain the algorithm Emacs uses to group characters into undo records?</p>