diff options
| author | Jack Jamison <jackqjamison@gmail.com> | 2026-07-05 01:19:30 -0400 |
|---|---|---|
| committer | Jack Jamison <jackqjamison@gmail.com> | 2026-07-05 01:19:30 -0400 |
| commit | bdf9a71ab7baa2b1de9abcfd5df1a9107a55d141 (patch) | |
| tree | c4524e6c41aa5107211103401dabfaefc81aa882 /.config/emacs/lisp/evil-collection/modes/eat | |
| parent | fe3984f541bd32bdfa418afb305b614176b55ca0 (diff) | |
add a bunch of emacs packages HELP
Diffstat (limited to '.config/emacs/lisp/evil-collection/modes/eat')
| -rw-r--r-- | .config/emacs/lisp/evil-collection/modes/eat/README.org | 37 | ||||
| -rw-r--r-- | .config/emacs/lisp/evil-collection/modes/eat/evil-collection-eat.el | 124 |
2 files changed, 161 insertions, 0 deletions
diff --git a/.config/emacs/lisp/evil-collection/modes/eat/README.org b/.config/emacs/lisp/evil-collection/modes/eat/README.org new file mode 100644 index 0000000..b8fdfae --- /dev/null +++ b/.config/emacs/lisp/evil-collection/modes/eat/README.org @@ -0,0 +1,37 @@ +* eat + + Evil bindings for [[https://codeberg.org/akib/emacs-eat][eat]], the Emulate A Terminal package. + + Initial state for =eat-mode= is =insert=. The same =C-*= keys that vterm + forwards raw to the terminal are bound to =eat-self-input= here so that + shells and TUIs receive them instead of evil-insert-state. + +** Key bindings + +*** eat-mode-map + + | Command | Original | Evil | + |------------------------------------------+----------+-----------| + | =evil-collection-eat-toggle-send-escape= | n/a | =C-c C-z= | + + The following keys are forwarded raw to the terminal via =eat-self-input= + in insert state: =C-a=, =C-b=, =C-d=, =C-e=, =C-f=, =C-k=, =C-l=, =C-n=, + =C-o=, =C-p=, =C-q=, =C-r=, =C-s=, =C-t=, =C-u=, =C-v=, =C-w=, =C-y=, + =C-z=, =<delete>=. =C-c= (prefix) and =C-h= (help) are not forwarded. + +*** eat-line-mode-map + + =RET=, =C-m= and =[return]= send input to the terminal in the state + named by =evil-collection-repl-submit-state=, and insert a newline in + the opposite state. + + | Command | Original | State | + |-----------------------+----------+-------------------------------------| + | =eat-line-send-input= | =RET= | =evil-collection-repl-submit-state= | + | =newline= | n/a | opposite of submit state | + +** New commands + + | Command | Purpose | + |------------------------------------------+---------------------------------------------------| + | =evil-collection-eat-toggle-send-escape= | Toggle whether =ESC= goes to eat or back to evil. | diff --git a/.config/emacs/lisp/evil-collection/modes/eat/evil-collection-eat.el b/.config/emacs/lisp/evil-collection/modes/eat/evil-collection-eat.el new file mode 100644 index 0000000..b5a6262 --- /dev/null +++ b/.config/emacs/lisp/evil-collection/modes/eat/evil-collection-eat.el @@ -0,0 +1,124 @@ +;;; evil-collection-eat.el --- Bindings for `eat' -*- lexical-binding: t -*- + +;; Copyright (C) 2024 James Cherti + +;; Maintainer: James Cherti <https://www.jamescherti.com/contact/> +;; Author: James Cherti <https://www.jamescherti.com/contact/> +;; Based on evil-collection-vterm.el by James Nguyen and Pierre Neidhardt +;; URL: https://github.com/emacs-evil/evil-collection +;; Version: 0.0.1 +;; Package-Requires: ((emacs "26.3")) +;; Keywords: evil, eat, tools + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see <http://www.gnu.org/licenses/>. + +;;; Commentary: +;; This package provides `evil-mode' keybindings for `eat'. + +;;; Code: +(require 'evil-collection) +(require 'eat nil t) + +(defconst evil-collection-eat-maps '(eat-mode-map + eat-line-mode-map + eat-semi-char-mode-map + eat-char-mode-map + eat-eshell-semi-char-mode-map + eat-eshell-char-mode-map)) + +;; The map symbols below are only referenced inside quoted lists in this +;; file, so the byte-compiler does not actually require these declarations. +;; Defining them keeps certain linters happy. +(defvar eat-line-mode-map) +(defvar eat-semi-char-mode-map) +(defvar eat-char-mode-map) +(defvar eat-eshell-semi-char-mode-map) +(defvar eat-eshell-char-mode-map) + +(defvar-local evil-collection-eat-send-escape-to-eat-p nil + "Track whether or not we send ESC to `eat' or `emacs'.") + +(defun evil-collection-eat-toggle-send-escape () + "Toggle the destination of the ESC key between `eat' and `emacs'. +This adjustment is necessary for programs that utilize ESC, such as Vim or an +SSH-accessed Emacs that also uses `evil-mode'." + (interactive) + (if evil-collection-eat-send-escape-to-eat-p + (evil-collection-define-key 'insert 'eat-mode-map (kbd "<escape>") + (lookup-key evil-insert-state-map (kbd "<escape>"))) + (evil-collection-define-key 'insert 'eat-mode-map + (kbd "<escape>") 'eat-self-input)) + (setq evil-collection-eat-send-escape-to-eat-p + (not evil-collection-eat-send-escape-to-eat-p)) + (message (format "Sending ESC to %s." + (if evil-collection-eat-send-escape-to-eat-p + "eat" + "emacs")))) + +;;;###autoload +(defun evil-collection-eat-setup () + "Set up `evil' bindings for `eat'." + (evil-set-initial-state 'eat-mode 'insert) + + (let* ((submit evil-collection-repl-submit-state) + (newline-state (if (eq submit 'normal) 'insert 'normal))) + (evil-collection-define-key submit 'eat-line-mode-map + (kbd "RET") 'eat-line-send-input + (kbd "\C-m") 'eat-line-send-input + [return] 'eat-line-send-input) + (evil-collection-define-key newline-state 'eat-line-mode-map + (kbd "RET") #'newline + (kbd "\C-m") #'newline + [return] #'newline)) + + (evil-collection-define-key '(normal insert) 'eat-mode-map + (kbd "C-c C-z") 'evil-collection-eat-toggle-send-escape) + + ;; `Evil' has some "C-" bindings in insert state that shadow the `eat' terminal + ;; bindings. Do not send "C-c" (prefix key) nor "C-h" (help prefix) as raw input. + (evil-collection-define-key 'insert 'eat-mode-map + (kbd "C-a") 'eat-self-input + (kbd "C-b") 'eat-self-input + (kbd "C-d") 'eat-self-input + (kbd "C-e") 'eat-self-input + (kbd "C-f") 'eat-self-input + (kbd "C-k") 'eat-self-input + (kbd "C-l") 'eat-self-input + (kbd "C-n") 'eat-self-input + (kbd "C-o") 'eat-self-input + (kbd "C-p") 'eat-self-input + (kbd "C-q") 'eat-self-input + (kbd "C-r") 'eat-self-input + (kbd "C-s") 'eat-self-input + (kbd "C-t") 'eat-self-input + (kbd "C-u") 'eat-self-input + (kbd "C-v") 'eat-self-input + (kbd "C-w") 'eat-self-input + (kbd "C-y") 'eat-self-input + (kbd "C-z") 'eat-self-input + (kbd "<delete>") 'eat-self-input) + + ;; Paste bindings: in a terminal, "paste before/after" is meaningless because + ;; the cursor position is controlled by the running program. Bind both `p' + ;; and `P' to `eat-yank' so the kill-ring is sent as terminal input. + (dolist (map '(eat-semi-char-mode-map + eat-char-mode-map + eat-eshell-semi-char-mode-map + eat-eshell-char-mode-map)) + (evil-collection-define-key 'normal map + (kbd "p") 'eat-yank + (kbd "P") 'eat-yank))) + +(provide 'evil-collection-eat) +;;; evil-collection-eat.el ends here |
