title: Emacs matlab mode key binding for running tests
body: <p>I am using Emacs + <a href="http://matlab-emacs.sourceforge.net/" rel="nofollow">matlab-mode</a> as my Matlab development environment. I also have <a href="http://blogs.mathworks.com/steve/2009/02/03/mtest-a-unit-test-harness-for-matlab-code/" rel="nofollow">MTEST</a> installed together with Matlab to run my unit tests - what I want to do now is to have a key binding that runs the tests from the current file in the matlab-shell I constantly have opened around (<code>M-x matlab-shell</code>).</p>
  
  <p>What I have until now is:</p>
  
  <pre><code>; Runs the unit tests available in the current buffer
  (defun run-matlab-test ()
  (interactive)
  (matlab-shell-run-command (concat "runtests "
                  (car (split-string (buffer-name) "\\.")))))
  
  ; Bind "C-c l" to running unit tests in matlab-mode
  (defun map-run-matlab-test-keys ()
    (local-set-key (kbd "C-c l") 'run-matlab-test))
  
  (add-hook 'matlab-mode-hook 'map-run-matlab-test-keys)
  </code></pre>
  
  <p>What I need to do is in the <code>run-matlab-test</code> function to have a way of calling the <code>runtests</code> command with the parameter provided by the <code>(buffer-name)</code> command and all this should happen in the matlab shell I mentioned above. Any hints ?</p>
  
  <p><strong>Edit</strong>: I managed to get it working by calling <code>matlab-shell-run-command</code>. The caveat here is that it only works if the starting sequence is: open your <code>unit-test.m</code> file, from that file run <code>M-x matlab-shell</code> (this way matlab starts with the current working directory in the tests directory) and then you can use the above binding.</p>