Remap 'insert-char' to read and input a character

* eat.el (eat-input-char): New function.
* eat.el (eat-semi-char-mode-map)
(eat-eshell-semi-char-mode-map): Remap 'insert-char' to
'eat-input-char'.
This commit is contained in:
Akib Azmain Turja 2022-12-04 19:32:14 +06:00
parent a21e665120
commit 775328790c
No known key found for this signature in database
GPG key ID: 5535FCF54D88616B

15
eat.el
View file

@ -4035,7 +4035,7 @@ event."
(eat-term-input-event eat--terminal n e))))
(defun eat-quoted-input ()
"Read a char and send it as INPUT."
"Read a character and send it as INPUT."
(declare (interactive-only "Use `eat-self-input' instead."))
(interactive)
;; HACK: Quick hack to allow inputting `C-g'. Any better way to do
@ -4046,6 +4046,17 @@ event."
(quit-flag nil))
(read-event))))
(defun eat-input-char (character count)
"Input CHARACTER, COUNT times.
Interactively, ask for the character CHARACTER to input. The numeric prefix
argument COUNT specifies how many times to insert CHARACTER."
(declare (interactive-only "Use `eat-self-input' instead."))
(interactive (list (read-char-by-name
"Insert character (Unicode name or hex): ")
(prefix-numeric-value current-prefix-arg)))
(eat-self-input count character))
(defun eat-yank (&optional arg)
"Same as `yank', but for Eat.
@ -4114,6 +4125,7 @@ ARG is passed to `yank-pop', which see."
(define-key map [?\M-y] #'eat-yank-pop)
(define-key map [?\C-c ?\C-c] #'eat-self-input)
(define-key map [?\C-c ?\C-e] #'eat-emacs-mode)
(define-key map [remap insert-char] #'eat-input-char)
map)
"Keymap for Eat semi-char mode.")
@ -4708,6 +4720,7 @@ PROGRAM can be a shell command."
(define-key map [?\C-y] #'eat-yank)
(define-key map [?\M-y] #'eat-yank-pop)
(define-key map [?\C-c ?\C-e] #'eat-eshell-emacs-mode)
(define-key map [remap insert-char] #'eat-input-char)
map)
"Keymap for Eat Eshell semi-char mode.")