bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#57821: 29.0.50; ANSI sequence not filtered in compilation buffer


From: Matthias Meulien
Subject: bug#57821: 29.0.50; ANSI sequence not filtered in compilation buffer
Date: Fri, 16 Sep 2022 22:59:21 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Matthias Meulien <orontee@gmail.com> writes:
>
>> The OSC sequences sent by flatpak-builder are meant to update the window
>> title (See https://terminalguide.namepad.de/seq/osc-2/).  I plan to
>> provide an osc-compilation-filter (modelled on
>> ansi-color-compilation-filter) to be added to compilation-filter-hook.
>>
>> One possible mode is to filter out all osc sequences.  An other mode
>> would be to call per command handlers as done by
>> comint-osc-process-output.
>>
>> Any thought?
>
> The default could be to filter out all unknown OSC sequences?

Yes.  The following already achieves this:

(defconst osc-control-seq-regexp
  ;; See ECMA 48, section 8.3.89 "OSC - OPERATING SYSTEM COMMAND".
  "\e\\][\x08-\x0D]*[\x20-\x7E]*\\(\a\\|\e\\\\\\)"
  "Regexp matching an OSC control sequence.")

(defun osc-filter-region (begin end)
  "Filter out all OSC control sequences from region BEGIN to END."
  (save-excursion
    (goto-char begin)
    ;; Delete escape sequences.
    (while (re-search-forward osc-control-seq-regexp end t)
      (delete-region (match-beginning 0) (match-end 0)))))

(defun osc-compilation-filter ()
  (let ((inhibit-read-only t))
    (osc-filter-region compilation-filter-start (point))))

(add-hook 'compilation-filter-hook #'osc-compilation-filter)


I'll try to implement the `osc-compilation-filter' this week-end.  What
would be the right place for this, progmodes/compile.el?  A new osc.el
file?

Side notes:

1. I just learnt about the optional COMINT argument of `compile': It
solves the original problem of filtering OSC sequences from compilation
output buffers; One has to add `comint-osc-process-output' to
`comint-output-filter-functions' and then must call `compile' with
universal argument...

2. With the patch attached to bug#57866 installed, OSC 2 sequences are
collected from comint buffers and the frame title can be updated.
-- 
Matthias





reply via email to

[Prev in Thread] Current Thread [Next in Thread]