* bug#57866: [PATCH] Extend comint-osc-handlers to support OSC 2
@ 2022-09-16 17:59 Matthias Meulien
2022-09-18 11:11 ` Lars Ingebrigtsen
0 siblings, 1 reply; 2+ messages in thread
From: Matthias Meulien @ 2022-09-16 17:59 UTC (permalink / raw)
To: 57866
[-- Attachment #1: Type: text/plain, Size: 1198 bytes --]
Tags: patch
The attached patch adds support for OSC 2 escape sequences in comint buffers.
To test one can update `frame-title-format' with something like:
(setq frame-title-format
'("%b"
(:eval
(when (and
comint-osc-window-title
(not (string-empty-p comint-osc-window-title)))
(concat " - " comint-osc-window-title)))
(:eval
(if multiple-frames
""
(concat " - GNU Emacs at " system-name)))))
After M-x shell call a command (like flatpak-builder) that emits OSC 2
commands, the frame title is updated while the command runs.
Note that one is expected to extend Bash prompt command to print an OSC
2 command to clear the title:
set -x
osc_clear() {
printf "\e]2;\e\\"
}
PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }osc_clear
set +x
Regards,
In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, cairo version
1.16.0) of 2022-09-14 built on carbon
Repository revision: f0798ac13dcb4c01a883f165e03c3cd7f208667c
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Debian GNU/Linux 11 (bullseye)
Configured using:
'configure --with-native-compilation --with-x-toolkit=no'
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Extend-comint-osc-handlers-to-support-OSC-2.patch --]
[-- Type: text/patch, Size: 1934 bytes --]
From 9ae3c83873169765721395966205f8cd10dcc333 Mon Sep 17 00:00:00 2001
From: Matthias Meulien <orontee@gmail.com>
Date: Thu, 15 Sep 2022 14:30:07 +0200
Subject: [PATCH] Extend comint-osc-handlers to support OSC 2
* lisp/comint.el (comint-osc-handlers): Add new
comint-osc-window-title-handler.
(comint-osc-window-title): Local variable to store window title.
(comint-osc-window-title-handler): Set comint-osc-window-title
according to OSC 2 command.
---
lisp/comint.el | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/lisp/comint.el b/lisp/comint.el
index 696dac3d12..9445482f1b 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -3914,7 +3914,8 @@ comint-redirect-results-list-from-process
;; to `comint-osc-handlers' allows a customized treatment of further
;; sequences.
-(defvar-local comint-osc-handlers '(("7" . comint-osc-directory-tracker)
+(defvar-local comint-osc-handlers '(("2" . comint-osc-window-title-handler)
+ ("7" . comint-osc-directory-tracker)
("8" . comint-osc-hyperlink-handler))
"Alist of handlers for OSC escape sequences.
See `comint-osc-process-output' for details.")
@@ -3955,6 +3956,18 @@ comint-osc-process-output
(put-text-property pos0 bound 'invisible t)
(setq comint-osc--marker (copy-marker pos0))))))))
+;; Window title handling (OSC 2)
+
+(defvar-local comint-osc-window-title nil)
+(defun comint-osc-window-title-handler (_ text)
+ "Set value of `comint-osc-window-title' from an OSC 2 escape sequence.
+The variable `comint-osc-window-title' can be reffered to in
+`frame-title-format' to dynamically set the frame title.
+
+This function is intended to be included as an entry of
+`comint-osc-handlers'."
+ (setq comint-osc-window-title text))
+
;; Current directory tracking (OSC 7)
(declare-function url-host "url/url-parse.el")
--
2.30.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* bug#57866: [PATCH] Extend comint-osc-handlers to support OSC 2
2022-09-16 17:59 bug#57866: [PATCH] Extend comint-osc-handlers to support OSC 2 Matthias Meulien
@ 2022-09-18 11:11 ` Lars Ingebrigtsen
0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2022-09-18 11:11 UTC (permalink / raw)
To: Matthias Meulien; +Cc: 57866
Matthias Meulien <orontee@gmail.com> writes:
> The attached patch adds support for OSC 2 escape sequences in comint buffers.
This patch was obsoleted by the one in bug#57821, so I'm closing this
bug report.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-09-18 11:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-16 17:59 bug#57866: [PATCH] Extend comint-osc-handlers to support OSC 2 Matthias Meulien
2022-09-18 11:11 ` Lars Ingebrigtsen
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.