【发布时间】:2010-04-14 07:14:55
【问题描述】:
如果正在编辑的文件的名称以 test_ 开头,我希望 C-c C-c 运行 py.test 并在另一个缓冲区中显示输出,否则正常运行 py-execute-buffer。我该怎么做?我正在使用带有 python 模式的 emacs 23.1.1,并且可以从命令行访问 py.test。
【问题讨论】:
如果正在编辑的文件的名称以 test_ 开头,我希望 C-c C-c 运行 py.test 并在另一个缓冲区中显示输出,否则正常运行 py-execute-buffer。我该怎么做?我正在使用带有 python 模式的 emacs 23.1.1,并且可以从命令行访问 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)))
【讨论】: