From 742ce656e2748864183ed56efc46d4e9d515c2bb Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Wed, 23 Dec 2020 07:42:22 +0100 Subject: [PATCH] Allow ending copy mode with C-c C-t (#3) When ending julia-vterm-repl-copy-mode by pressing C-c C-t, the Julia process remains stopped and the buffer is almost unusable, because it does not have its local keymap set. The only working way to terminate the copy mode is by pressing RET, but this requires an active region. This commit fixes the above problem by moving the code for ending the copy mode to julia-vterm-repl-copy-mode. Now the copy mode can be terminated by both RET and C-c C-t. --- julia-vterm.el | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/julia-vterm.el b/julia-vterm.el index 959e5b0..386ba85 100644 --- a/julia-vterm.el +++ b/julia-vterm.el @@ -154,10 +154,15 @@ If there's already one with the process alive, just open it." :group 'julia-vterm-repl :lighter " VTermCopy" :keymap julia-vterm-repl-copy-mode-map - (when julia-vterm-repl-copy-mode - (message "Start copy mode") - (use-local-map nil) - (vterm-send-stop))) + (if julia-vterm-repl-copy-mode + (progn + (message "Start copy mode") + (use-local-map nil) + (vterm-send-stop)) + (vterm-reset-cursor-point) + (use-local-map julia-vterm-repl-mode-map) + (vterm-send-start) + (message "End copy mode"))) (defun julia-vterm-repl-copy-mode-done () "Save the active region to the kill ring and exit copy mode." @@ -165,11 +170,7 @@ If there's already one with the process alive, just open it." (if (region-active-p) (kill-ring-save (region-beginning) (region-end)) (user-error "No active region")) - (julia-vterm-repl-copy-mode -1) - (vterm-reset-cursor-point) - (use-local-map julia-vterm-repl-mode-map) - (vterm-send-start) - (message "End copy mode")) + (julia-vterm-repl-copy-mode -1)) ;;----------------------------------------------------------------------