From 9fe44709317335aaa037f844040bba04fc00229f Mon Sep 17 00:00:00 2001 From: Juergen Hoetzel Date: Wed, 20 Jul 2022 18:18:18 +0200 Subject: [PATCH] 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. --- python-pytest.el | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/python-pytest.el b/python-pytest.el index 10185ac..29e9dca 100644 --- a/python-pytest.el +++ b/python-pytest.el @@ -329,6 +329,13 @@ With a prefix ARG, allow editing." "Major mode for pytest sessions (derived from comint-mode)." (compilation-setup)) +(defvar python-pytest-finished-mode-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map compilation-minor-mode-map) + (define-key map [remap recompile] #'python-pytest-repeat) + map) + "Keymap for `python-pytest-mode' major mode.") + (cl-defun python-pytest--run (&key args file func edit) "Run pytest for the given arguments." (setq args (python-pytest--transform-arguments args)) @@ -413,6 +420,9 @@ With a prefix ARG, allow editing." (defun python-pytest--process-sentinel (proc _state) "Process sentinel helper to run hooks after PROC finishes." (with-current-buffer (process-buffer proc) + (compilation-mode) + (read-only-mode -1) ;; required for python-pytest-repeat + (use-local-map python-pytest-finished-mode-map) (run-hooks 'python-pytest-finished-hook))) (defun python-pytest--transform-arguments (args)