From b17b83b5dd3b52fb827342f6e9e49d4489c78add Mon Sep 17 00:00:00 2001 From: JSDurand Date: Tue, 13 Oct 2026 13:58:16 +0800 Subject: eshell: add command that binds view mode with copy mode * eshell-conf.el (copy-and-view-mode): This command toggles view mode along with the copy mode from ghostel. (ghostel-mode-map): Replace the binding of `ghostel-copy-mode`. --- eshell-conf.el | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'eshell-conf.el') diff --git a/eshell-conf.el b/eshell-conf.el index 3e95e8d..7b226e1 100644 --- a/eshell-conf.el +++ b/eshell-conf.el @@ -1195,5 +1195,22 @@ command." (add-hook 'eshell-mode-hook #'ghostel-eshell-visual-command-mode) +;;;; Copy-mode also enters view-mode + +(defun copy-and-view-mode (&optional arg) + "Also enter `view-mode' in copy-mode. +If ARG is non-nil, behave just like `ghostel-copy-mode'." + (interactive "P") + (cond + ((eq ghostel--input-mode 'copy) + (cond ((null arg) (view-mode -1))) + (ghostel-readonly-exit)) + (t + (ghostel-copy-mode) + (cond ((null arg) (view-mode 1)))))) + +;; C-c C-t +(define-key ghostel-mode-map (vector 3 20) #'copy-and-view-mode) + (provide 'eshell-conf) ;;; eshell-conf.el ends here -- cgit v1.2.3-18-g5258