]> git.eshelyaron.com Git - emacs.git/commitdiff
Align term-mode control character handling
authorDaniel Colascione <dancol@dancol.org>
Sat, 11 Jan 2025 20:48:19 +0000 (12:48 -0800)
committerEshel Yaron <me@eshelyaron.com>
Sun, 12 Jan 2025 14:58:44 +0000 (15:58 +0100)
Terminal emulators generally ignore exotic ASCII control
characters like SOH and STX. Make term-mode do the same.

* lisp/term.el (term-emulate-terminal): ignore ASCII control
characters like other terminal emulators do

(cherry picked from commit 6cea3233a12f3964c46bffb0b6215e9c8cd92962)

lisp/term.el

index 8bffce495e41169ded0266968cd55b504f0b169e..72af0360700dd41935fe09bac31f635a17c4c2b6 100644 (file)
@@ -3011,8 +3011,8 @@ See `term-prompt-regexp'."
 
 (defconst term-control-seq-regexp
   (concat
-   ;; A control character,
-   "\\(?:[\r\n\000\007\t\b\016\017]\\|"
+   ;; A control character not matched in a longer sequence below,
+   "\\(?:[\x00-\x19\x1C-\x1F\r\n\t\b]\\|"
    ;; some Emacs specific control sequences, implemented by
    ;; `term-command-hook',
    "\032[^\n]+\n\\|"
@@ -3267,8 +3267,9 @@ See `term-prompt-regexp'."
                      (?A ;; An \eAnSiT sequence (Emacs specific).
                       (term-handle-ansi-terminal-messages
                        (substring str i ctl-end)))))
-                  ;; Ignore NUL, Shift Out, Shift In.
-                  ((or ?\0 #xE #xF 'nil) nil))
+                  ;; Ignore any control character not already recognized.
+                  ((or 'nil
+                       (and (pred characterp) (pred (lambda (c) (<= c ?\x1F))))) nil))
                 ;; Leave line-wrapping state if point was moved.
                 (unless (eq term-do-line-wrapping (point))
                   (setq term-do-line-wrapping nil))