GNU bug report logs -
#78263
[PATCH 1/3] Ignore OSC sequences in term instead of printing them
Previous Next
Full log
View this message in rfc822 format
> From: Stéphane Zermatten <szermatt <at> gmail.com>
> Date: Mon, 5 May 2025 19:57:45 +0300
> Cc: 78263 <at> debbugs.gnu.org,
> Dan Nicolaescu <dann <at> ics.uci.edu>,
> Eli Zaretskii <eliz <at> gnu.org>
>
> I attached a merged version of all 3 patches to this e-mail that handles OSC sequences, so they’re handled right away. I’m happy to do it that way, if it’s more convenient.
Thanks, see some minor comments below.
Jared, any further comments about the issue or the patch?
> * lisp/term.el (term-emulate-terminal) handle OSC sequences
The log message should mention all the functions/variables where you
make changes, with a short description of each change. Please also
mention the bug number.
> +(defcustom term-osc-handlers '(("0" . ansi-osc-window-title-handler)
> + ("2" . ansi-osc-window-title-handler)
> + ("7" . ansi-osc-directory-tracker)
> + ("8" . ansi-osc-hyperlink-handler))
> + "OSC sequence handler function alist.
> +
> +OSC (Operating System Command) is a category of ANSI escape sequence
> +used in terminal application to introduce custom commands. Terminals
> +ignore unknown OSC sequences by default. Handlers can be registered here
> +to add support for new OSC sequences to `term'.
> +
> +Functions in this alist are passed matching valid OSC sequences as
> +they're sent to the terminal.
> +
> +Valid OSC sequences are of the form
> + ESC ] code ; text BEL
> + ESC ] code ; text ESC \
> +
> +Each entry has the form (CODE . FUNCTION), where CODE is the string that
> +appears before the semicolon.
> +
> +FUNCTION is called with two arguments CODE and TEXT with the term buffer
> +active and its point and state active at the time the OSC sequence
> +appeared in the stream."
> + :type '(alist :key-type string :value-type function)
> + :group 'term)
New defcustoms should have a :version tag.
> +(defconst term-osc--max-bytes (* 32 1024 1024)
> + "Limit the length of OSC sequences to keep in memory.")
This begs the question: what happens with longer sequences? Can the
doc string answer that question?
> + (with-demoted-errors "term OSC error: %S"
> + (funcall
> + func code
> + (decode-coding-string
> + (substring seq-str text-start end-mark)
> + locale-coding-system t)))))
Why locale-coding-system? Wouldn't the result of calling
process-coding-system with the process running in term.el be a better
candidate?
Last, but not least: you don't seem to have a copyright assignment on
file, without which we cannot accept such a large contribution. Would
you like to start the paperwork of copyright assignment at this time?
If yes, I will send you the form to fill and the instructions.
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.