title: electric-pair-mode: Don't pair if cursor precedes a non-whitespace character
body: <p>After upgrading to Emacs 24.4, I noticed that in some major modes, <code>electric-pair-mode</code> correctly "preserves balance" when the cursor precedes a word character, but not in others. Specifically, suppose I have the following code in a buffer, and suppose the pipe character <code>|</code> is my cursor:</p>
  
  <p><code>foo = ["1", "2", |3"]</code></p>
  
  <p>In <code>python-mode</code>, typing a double-quote character results in the following:</p>
  
  <p><code>foo = ["1", "2", "|3"]</code></p>
  
  <p>This is good — <code>electric-pair-mode</code> correctly determines that there exists an unmatched double-quote, so there's no need to insert an extra one. However, in <code>ruby-mode</code>, I get this instead:</p>
  
  <p><code>foo = ["1", "2", "|"3"]</code></p>
  
  <p>Is there a way to achieve the same <code>python-mode</code> behavior in all other major modes?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I just realized that the behavior in <code>ruby-mode</code> seems to be dependent on the other contents of the buffer. If I have a buffer with a single line <code>foo = ["a", "b", "c"]</code>, then everything seems to be fine. But if my buffer looks like:</p>
  
  <pre><code>foo = ["a", "b", "c"]
  
  "#{ bar }"
  </code></pre>
  
  <p>then the extraneous double-quote will show up. Seems like this might be a bug in how <code>electric-pair-mode</code> is determining whether it needs to preserve balance.</p>
  
  <p>Does anyone know of a way to force <code>electric-pair-mode</code> to <em>never</em> insert an extra double-quote if the cursor precedes a non-whitespace character?</p>