2010-04-14 77 views
7

如果要讓Cc Cc運行py.test並在另一個緩衝區顯示輸出(如果正在編輯的文件的名稱以test_開頭並正常運行py-execute-buffer除此以外。我將如何做到這一點?我使用Python模式使用emacs 23.1.1,並且可以從命令行訪問py.test。從emacs運行py.test

回答

7

這並沒有特別好的測試;這只是一個粗略的想法。

(defun py-do-it() 
    (interactive) 
    (if (string-match 
     (rx bos "test_") 
     (file-name-nondirectory (buffer-file-name))) 
     (compile "py.test") 
    (py-execute-buffer))) 

(add-hook 'python-mode-hook 
      (lambda() 
      (local-set-key 
      (kbd "F5")     ;or whatever 
      'py-do-it))) 
+0

謝謝,我試過了,它工作正常。 – Nikwin 2010-04-16 07:42:42

+0

經過一段時間後,我決定我希望py.test只在當前緩衝區運行,所以我用(shell-command(concat「py.test」(buffer -文件名))) – Nikwin 2010-04-17 05:50:53