[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 530fdab880 2/4: Handle OSC command to set window title
From: |
Lars Ingebrigtsen |
Subject: |
master 530fdab880 2/4: Handle OSC command to set window title |
Date: |
Sun, 18 Sep 2022 08:52:24 -0400 (EDT) |
branch: master
commit 530fdab880e9da25bf37a64d167358454f362b56
Author: Matthias Meulien <orontee@gmail.com>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Handle OSC command to set window title
* lisp/osc.el (osc-handlers): Bind osc-window-title-handler to OSC
command 2.
(osc-window-title): Local variable storing string extracted from OSC
command 2.
(osc-window-title-handler): Copy text from OSC command 2 to
osc-window-title (bug#57821).
---
lisp/osc.el | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/lisp/osc.el b/lisp/osc.el
index 224981a856..619972dab1 100644
--- a/lisp/osc.el
+++ b/lisp/osc.el
@@ -23,12 +23,13 @@
;;; Commentary:
;; Interpretation of OSC (Operating System Commands) escape
-;; sequences. Handlers for OSC 7 and 8 (for current directory and
-;; hyperlinks respectively) are provided.
+;; sequences. Handlers for OSC 2, 7 and 8 (for window title, current
+;; directory and hyperlinks respectively) are provided.
;;; Code:
-(defvar-local osc-handlers '(("7" . osc-directory-tracker)
+(defvar-local osc-handlers '(("2" . osc-window-title-handler)
+ ("7" . osc-directory-tracker)
("8" . osc-hyperlink-handler))
"Alist of handlers for OSC escape sequences.
See `osc-apply-on-region' for details.")
@@ -67,6 +68,18 @@ point where the escape sequence was located."
(put-text-property pos0 end 'invisible t)
(setq osc--marker (copy-marker pos0)))))))
+;; Window title handling (OSC 2)
+
+(defvar-local osc-window-title nil)
+(defun osc-window-title-handler (_ text)
+ "Set value of `osc-window-title' from an OSC 2 escape sequence.
+The variable `osc-window-title' can be referred to in
+`frame-title-format' to dynamically set the frame title.
+
+This function is intended to be included as an entry of
+`osc-handlers'."
+ (setq osc-window-title text))
+
;; Current directory tracking (OSC 7)
(declare-function url-host "url/url-parse.el")