From da306a6dbda6f1e285281765a311938a1d9db022 Mon Sep 17 00:00:00 2001 From: Nathaniel Nicandro Date: Sun, 3 Dec 2023 23:29:18 -0600 Subject: [PATCH] Add `jupyter-repl-clear-input` command * jupyter-repl.el (jupyter-repl-clear-input): The new command. (jupyter-repl-mode-map): Add a binding for it. closes #512 --- jupyter-repl.el | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/jupyter-repl.el b/jupyter-repl.el index fa9b5f55..ef2f3459 100644 --- a/jupyter-repl.el +++ b/jupyter-repl.el @@ -800,6 +800,14 @@ lines, truncate it to something less than (jupyter-repl-insert-prompt 'in)))) (goto-char (point-max))) +(defun jupyter-repl-clear-input () + "Clear the contents of the input cell." + (interactive) + (goto-char (point-max)) + (delete-region + (jupyter-repl-cell-code-beginning-position) + (point-max))) + ;;; Handlers (defun jupyter-repl-history-add (code) @@ -1649,6 +1657,7 @@ Return the buffer switched to." (define-key map (kbd "M-n") #'jupyter-repl-history-next) (define-key map (kbd "M-p") #'jupyter-repl-history-previous) (define-key map (kbd "C-c C-o") #'jupyter-repl-clear-cells) + (define-key map (kbd "C-c C-u") #'jupyter-repl-clear-input) (define-key map (kbd "C-c M-r") #'jupyter-repl-history-previous-matching) (define-key map (kbd "C-c M-s") #'jupyter-repl-history-next-matching) map))