Skip to content

Commit ce96ec2

Browse files
Switch to `compilation-mode' after pytest process finishes
This makes the standard `compilation-mode' commands and keybindings available. Rebind "g" to `python-pytest-repeat'. Closes #47.
1 parent d031fa9 commit ce96ec2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

python-pytest.el

+10
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,13 @@ With a prefix ARG, allow editing."
329329
"Major mode for pytest sessions (derived from comint-mode)."
330330
(compilation-setup))
331331

332+
(defvar python-pytest-finished-mode-map
333+
(let ((map (make-sparse-keymap)))
334+
(set-keymap-parent map compilation-minor-mode-map)
335+
(define-key map "g" #'python-pytest-repeat)
336+
map)
337+
"Keymap for `python-pytest-mode' major mode.")
338+
332339
(cl-defun python-pytest--run (&key args file func edit)
333340
"Run pytest for the given arguments."
334341
(setq args (python-pytest--transform-arguments args))
@@ -413,6 +420,9 @@ With a prefix ARG, allow editing."
413420
(defun python-pytest--process-sentinel (proc _state)
414421
"Process sentinel helper to run hooks after PROC finishes."
415422
(with-current-buffer (process-buffer proc)
423+
(compilation-mode)
424+
(read-only-mode -1) ;required for `python-pytest-repeat'
425+
(use-local-map python-pytest-finished-mode-map)
416426
(run-hooks 'python-pytest-finished-hook)))
417427

418428
(defun python-pytest--transform-arguments (args)

0 commit comments

Comments
 (0)