开发者

Running py.test from emacs

What I wo开发者_开发问答uld like is for C-c C-c to run py.test and display the output in the other buffer if the name of the file being edited begins with test_, and to normally run py-execute-buffer otherwise. How would I do this? I am using emacs 23.1.1 with python-mode and can access py.test from the command line.


This isn't particularly well-tested; it's just a rough idea.

(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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜