From 524d7a10bf5b0db16410d00b11376bca73f69eba Mon Sep 17 00:00:00 2001 From: Matthias Meulien Date: Sat, 17 Sep 2022 17:54:24 +0200 Subject: [PATCH 2/3] Handle OSC command to set window title * lisp/osc.el (osc-handlers): (osc-window-title): (osc-window-title-handler): --- 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 @@ osc-apply-on-region (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") -- 2.30.2