如果正在编辑的文件的名称以 test_ 开头,我想要 Cc Cc 运行 py.test 并在另一个缓冲区中显示输出,否则正常运行 py-execute-buffer。我该怎么做?我正在使用带有 python 模式的 emacs 23.1.1,并且可以从命令行访问 py.test。
问问题
1315 次
1 回答
8
这没有经过特别充分的测试。这只是一个粗略的想法。
(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)))
于 2010-04-14T13:56:41.953 回答