GNU bug report logs - #78263
[PATCH 1/3] Ignore OSC sequences in term instead of printing them

Previous Next

Package: emacs;

Reported by: Stephane Zermatten <szermatt <at> gmail.com>

Date: Mon, 5 May 2025 15:21:02 UTC

Severity: normal

Tags: patch

Done: Eli Zaretskii <eliz <at> gnu.org>

Full log


Message #11 received at 78263 <at> debbugs.gnu.org (full text, mbox):

From: Per Bothner <per <at> bothner.com>
To: Stephane Zermatten <szermatt <at> gmail.com>, 78263 <at> debbugs.gnu.org
Cc: Eli Zaretskii <eliz <at> gnu.org>, Dan Nicolaescu <dann <at> ics.uci.edu>
Subject: Re: bug#78263: [PATCH 1/3] Ignore OSC sequences in term instead of
 printing them
Date: Mon, 5 May 2025 09:36:45 -0700
The whole term-control-seq-regexp is fundamentally broken, and does not appear
in any version of term.el I have worked on or blessed.  It assumes all relevant sequences
are complete in a single call to term-emulate-terminal. That is not a safe assumption.

The correct way to parse terminal escape sequences is using a state machine, as in
my original implementation. Alternatively, if you really want to use pattern matching,
it is possible to recognize "incomplete escape sequence", and save that until the
next call.  However, I don't see any code to handle that; it is possible I'm missing something.
(That approach can in theory lead to O(n^2) behavior, which the state machine approach avoids,
but I don't think that is a major problem.)

I agree with Eli that term should when possible handle OSC sequences rather than ignoring them.
(Ones it can't handle should of course be ignored.)

On 5/5/25 7:30 AM, Stephane Zermatten wrote:
> Tags: patch
> 
> 
> This change detects OSC sequences and ignores them. This is what's
> normally expected and avoids strange outputs.
> 
> Starting with version 4, the fish shell has started sending out OSC
> sequences by default, which looks pretty bad on term. This change avoids
> this particular problem.
> 
> This is PATCH 1/3, because I'd like to propose making it possible to
> handle OSC sequences in term in follow-up changes. Emacs already has
> handlers for OSC sequences in ansi-osc, why not make use of them?
> 
> In GNU Emacs 31.0.50 (build 5, x86_64-apple-darwin23.6.0, NS
>   appkit-2487.70 Version 14.7.5 (Build 23H527)) of 2025-05-02 built on
>   boomer.zia
> Repository revision: 99ca41b6ef300653a0d15b73a0c0d446a9a9e059
> Repository branch: master
> Windowing system distributor 'Apple', version 10.3.2487
> System Description:  macOS 14.7.5
> 
> Configured using:
>   'configure --program-suffix=-head --with-tree-sitter
>   --with-native-compilation=aot'
> 

-- 
	--Per Bothner
per <at> bothner.com   http://per.bothner.com/





This bug report was last modified 3 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.