7
如果要让Cc Cc运行py.test并在另一个缓冲区显示输出(如果正在编辑的文件的名称以test_开头并正常运行py-execute-buffer除此以外。我将如何做到这一点?我使用Python模式使用emacs 23.1.1,并且可以从命令行访问py.test。从emacs运行py.test
如果要让Cc Cc运行py.test并在另一个缓冲区显示输出(如果正在编辑的文件的名称以test_开头并正常运行py-execute-buffer除此以外。我将如何做到这一点?我使用Python模式使用emacs 23.1.1,并且可以从命令行访问py.test。从emacs运行py.test
这并没有特别好的测试;这只是一个粗略的想法。
(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)))
谢谢,我试过了,它工作正常。 – Nikwin 2010-04-16 07:42:42
经过一段时间后,我决定我希望py.test只在当前缓冲区运行,所以我用(shell-command(concat“py.test”(buffer -文件名))) – Nikwin 2010-04-17 05:50:53