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.
This commit is contained in:
Michal Sojka 2020-12-23 07:42:22 +01:00 committed by GitHub
parent d4d5c50f15
commit 742ce656e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -154,10 +154,15 @@ If there's already one with the process alive, just open it."
:group 'julia-vterm-repl :group 'julia-vterm-repl
:lighter " VTermCopy" :lighter " VTermCopy"
:keymap julia-vterm-repl-copy-mode-map :keymap julia-vterm-repl-copy-mode-map
(when julia-vterm-repl-copy-mode (if julia-vterm-repl-copy-mode
(progn
(message "Start copy mode") (message "Start copy mode")
(use-local-map nil) (use-local-map nil)
(vterm-send-stop))) (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 () (defun julia-vterm-repl-copy-mode-done ()
"Save the active region to the kill ring and exit copy mode." "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) (if (region-active-p)
(kill-ring-save (region-beginning) (region-end)) (kill-ring-save (region-beginning) (region-end))
(user-error "No active region")) (user-error "No active region"))
(julia-vterm-repl-copy-mode -1) (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"))
;;---------------------------------------------------------------------- ;;----------------------------------------------------------------------