From 6cbfae79602492590f1078d7530f8ac17c480375 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Mon, 10 Feb 2014 16:53:29 -0500 Subject: Make `create-python-test-file` find file if exists Instead of raising an error if the file exist, just open file in other buffer. --- lisp/init-python.el | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lisp') diff --git a/lisp/init-python.el b/lisp/init-python.el index 48bbf6d..dce210f 100644 --- a/lisp/init-python.el +++ b/lisp/init-python.el @@ -18,12 +18,12 @@ Unless a prefix argument ARG is given, py.test is also imported." (interactive "P") (let* ((py-file (file-name-nondirectory buffer-file-name)) (test-file (concat "test_" py-file))) - (when (file-exists-p test-file) - (error "Test file %s already exists." test-file)) - (with-current-buffer (find-file-other-window test-file) - (insert (format "import %s\n" (file-name-sans-extension py-file))) - (unless arg - (insert "import pytest\n"))))) + (find-file-other-window test-file) + (unless (file-exists-p test-file) + (with-current-buffer + (insert (format "import %s\n" (file-name-sans-extension py-file))) + (unless arg + (insert "import pytest\n")))))) (defun km/pytest-compile (arg) "Run pytest. -- cgit v1.2.3