Subject: 28.2; C-SPC not working in term char mode

From: Al Petrofsky <[email-masked]>
Date: Fri, 16 Jun 2023 20:06:57 -0400

emacs-28.2 -Q
   M-x term RET RET
   C-SPC

This should send an ASCII NUL (a zero byte) to the pty, but instead it
displays "Mark set" in the echo area.

To fix it, C-SPC needs to get special handling akin to the handling of
C-/.  Here's a patch that also makes C-M-SPC and C-M-/ work.

--- term.el 2022-09-06 17:31:54.000000000 -0400
+++ term-c-spc-fixed.el 2023-06-15 11:21:41.780140053 -0400
@@ -916,6 +916,9 @@
     (define-key map [next] 'term-send-next)
     (define-key map [xterm-paste] #'term--xterm-paste)
     (define-key map [?\C-/] #'term-send-C-_)
+    (define-key map [?\C- ] #'term-send-C-@)
+    (define-key map [?\C-\M-/] #'term-send-C-M-_)
+    (define-key map [?\C-\M- ] #'term-send-C-M-@)
     map)
   "Keyboard map for sending characters directly to the inferior process.")

@@ -1359,6 +1362,9 @@
 (defun term-send-del   () (interactive) (term-send-raw-string "\e[3~"))
 (defun term-send-backspace  () (interactive) (term-send-raw-string "\C-?"))
 (defun term-send-C-_  () (interactive) (term-send-raw-string "\C-_"))
+(defun term-send-C-@  () (interactive) (term-send-raw-string "\C-@"))
+(defun term-send-C-M-_  () (interactive) (term-send-raw-string "\e\C-_"))
+(defun term-send-C-M-@  () (interactive) (term-send-raw-string "\e\C-@"))

 (defun term-char-mode ()
   "Switch to char (\"raw\") sub-mode of term mode.