title: Binding M-<up> / M-<down> in Emacs 23.1.1
body: <p>I'm trying to put in a feature that I miss from Eclipse, where <kbd>Alt</kbd>+[<kbd>Up</kbd>/<kbd>Down</kbd>] transposes the lines up or down, but can not for the life of me figure out how to assign to these keys properly. I am using it in <code>-nw</code> mode (so just in a shell window), and typically run in a screen session. </p>
  
  <p>Using a global key binding, I can get it to work with letter combinations, like <code>(kbd "M-m")</code>, but every combination I have tried for the arrow keys just gives me a message that doesn't make sense, I always get:</p>
  
  <pre><code>"ESC &lt;up&gt; is undefined"
  </code></pre>
  
  <p>What I have tried:</p>
  
  <pre><code>(global-set-key (kbd "M-&lt;up&gt;") 'transpose-line-up)    
  (global-set-key (kbd "&lt;escape&gt;-&lt;up&gt;") 'transpose-line-up)
  (global-set-key [M-up] 'transpose-line-up)
  (global-set-key [\e \M-O A] 'transpose-line-up)
  </code></pre>
  
  <p>And <kbd>C-h c</kbd> just returns:</p>
  
  <pre><code>ESC &lt;up&gt; (translated from ESC M-O A) is undefined
  </code></pre>
  
  <p>None of these work, either using <kbd>ESC</kbd> or <kbd>Alt</kbd>.</p>
  
  <p>Any idea how I can make this work? I would prefer to have these as <kbd>Alt</kbd>+[<kbd>Up</kbd>/<kbd>Down</kbd>] just because that is what I am used to.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>From the comments:</p>
  
  <ul>
  <li><p><kbd>C-q Up</kbd> prints <code>^[OA</code>.</p></li>
  <li><p><kbd>C-q M-Up</kbd> prints <code>^[</code> and moves the cursor up a line.</p></li>
  <li><p><kbd>C-h k</kbd> (<kbd>Alt</kbd>+<kbd>Up</kbd>) prints <code>ESC &lt;up&gt; (translated from ESC M-O A) is undefined</code>.</p></li>
  </ul>
  
  <p>Thanks for the suggestions, but they all turned out the same.</p>