运行测试的Emacs matlab模式键绑定

问题描述:

我使用Emacs + matlab-mode作为我的Matlab开发环境。我也有MTEST与Matlab一起安装来运行我的单元测试 - 我现在想要做的是有一个键绑定运行来自当前文件中的测试,我经常打开(M-x matlab-shell)。运行测试的Emacs matlab模式键绑定

我直到现在是:

; 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) 

我需要做的是在run-matlab-test功能有通话由(buffer-name)命令提供的参数runtests命令的方式而这一切应该发生在我上面提到的matlab shell中。任何提示?

编辑:我设法通过呼吁matlab-shell-run-command得到它的工作。这里需要注意的是,只有在启动顺序为:打开unit-test.m文件,从该文件运行M-x matlab-shell(这样matlab以tests目录中的当前工作目录开始),然后可以使用上面的绑定。

为了避免上述的警告,你可能会发出一个cd到MATLAB,调用的runTest之前,通过做类似如下(未经测试):

(defun run-matlab-test() 
    (interactive) 
    (matlab-shell-run-command (concat "cd " (file-name-directory (buffer-file-name)))) 
    (matlab-shell-run-command (concat "runtests " 
          (car (split-string (buffer-name) "\\.")))))