add function and keybinding to rerun last repl command

This commit is contained in:
Valentin Boettcher 2025-01-21 12:33:54 -05:00
parent f91baed57a
commit c93ea742db
No known key found for this signature in database
GPG key ID: E034E12B7AF56ACE
2 changed files with 15 additions and 1 deletions

View file

@ -143,6 +143,9 @@ C-c C-i Import the current buffer file like `from <module> import *' in the
C-c C-d py-vterm-interaction-send-cd-to-buffer-directory
Send %cd function call to the Python REPL to change the current working
directory of REPL to the buffer's directory.
C-c C-a py-vterm-interaction-send-rerun-last
Send C-p <return> to the repl to rerun the last line entered.
#+end_example
*** py-vterm-interaction-repl-mode

View file

@ -644,6 +644,16 @@ python vterm buffer."
(setq default-directory buffer-directory)))
(message "The buffer is not associated with a directory.")))
(defun py-vterm-interaction-send-rerun-last ()
"Rerun last repl command.
(Send C-p <return>)"
(interactive)
(py-vterm-interaction-clear-line)
(with-current-buffer (py-vterm-interaction-fellow-repl-buffer)
(vterm-send-key (kbd "C-p"))
(py-vterm-interaction-send-return-key)))
(defalias 'py-vterm-interaction-sync-wd #'py-vterm-interaction-send-cd-to-buffer-directory)
(defun py-vterm-interaction-fellow-repl-prompt-status ()
@ -664,7 +674,8 @@ python vterm buffer."
(,(kbd "C-c C-i") . ,#'py-vterm-interaction-send-import-buffer-file)
(,(kbd "C-c C-b") . ,#'py-vterm-interaction-send-buffer)
(,(kbd "C-c C-r") . ,#'py-vterm-interaction-send-run-buffer-file)
(,(kbd "C-c C-d") . ,#'py-vterm-interaction-send-cd-to-buffer-directory)))
(,(kbd "C-c C-d") . ,#'py-vterm-interaction-send-cd-to-buffer-directory)
(,(kbd "C-c C-a") . ,#'py-vterm-interaction-send-rerun-last)))
(provide 'py-vterm-interaction)