From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Matthias Meulien Newsgroups: gmane.emacs.bugs Subject: bug#57866: [PATCH] Extend comint-osc-handlers to support OSC 2 Date: Fri, 16 Sep 2022 19:59:26 +0200 Message-ID: <877d2319q9.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16847"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) To: 57866@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Sep 16 20:00:42 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oZFdo-00049P-F2 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 16 Sep 2022 20:00:40 +0200 Original-Received: from localhost ([::1]:49620 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oZFdn-00026J-4y for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 16 Sep 2022 14:00:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36170) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oZFdV-000244-HJ for bug-gnu-emacs@gnu.org; Fri, 16 Sep 2022 14:00:22 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45199) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oZFdC-0000AQ-Mx for bug-gnu-emacs@gnu.org; Fri, 16 Sep 2022 14:00:20 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oZFdC-0006OK-3P for bug-gnu-emacs@gnu.org; Fri, 16 Sep 2022 14:00:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Matthias Meulien Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 16 Sep 2022 18:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 57866 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.166335118124510 (code B ref -1); Fri, 16 Sep 2022 18:00:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 16 Sep 2022 17:59:41 +0000 Original-Received: from localhost ([127.0.0.1]:44277 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oZFcr-0006NG-5q for submit@debbugs.gnu.org; Fri, 16 Sep 2022 13:59:41 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:55812) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oZFco-0006N7-NZ for submit@debbugs.gnu.org; Fri, 16 Sep 2022 13:59:40 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60458) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oZFco-0001up-I1 for bug-gnu-emacs@gnu.org; Fri, 16 Sep 2022 13:59:38 -0400 Original-Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]:46593) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oZFcm-0008VQ-K9 for bug-gnu-emacs@gnu.org; Fri, 16 Sep 2022 13:59:38 -0400 Original-Received: by mail-wm1-x32c.google.com with SMTP id n40-20020a05600c3ba800b003b49aefc35fso244428wms.5 for ; Fri, 16 Sep 2022 10:59:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:message-id:date:subject:to:from:from:to:cc :subject:date; bh=qh8/uqR6qisDJzW32p3qy2IhMe1gxsYhCZWkc61jFSA=; b=K9zdsnK4tGNkqLu3H+OQ21CmSjqWIQkAg3zYhCsaAHXKrYlTVTeGUxcW4CtIE1EIeR Su14ALSTTyXl2u+MPOOUBpBBQiCnz2SwM3yI6USJ+kxObC2vHBNsxMXdaPEw6qLfD4Sb xbLLfvL4kEBoiS+uxa9xjPnE1UlMJVsqV1QrI/q0iXXXtzD6CVnABX1XR6foemlhQK3I LoZ0Vw4ZcU0/GPRXKyUNxqGdu7w8FeiKwrJgn7x2Q42QNIOmvAB4ikN6Co7xn5vYomY7 eKggi4KsJAZz38yTI8YINmb8j6W2Watus70Dmtce07v7GPYtl2K3w/JDogkLbZOI/GBL t3mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:date:subject:to:from :x-gm-message-state:from:to:cc:subject:date; bh=qh8/uqR6qisDJzW32p3qy2IhMe1gxsYhCZWkc61jFSA=; b=owGcAybr4EtWXt1OnAFyv/E8V7BbYSviIls4tFV6PSBS1KOzBD+aIhPv1nsJoDz++n Obc/i2P6nJ79ZnKYXjdIQqvJ7Zf9uvrAKtYK/yrJrNulsm1X7oTEV62j+QBBtoeAd/x9 TwHow+FBtZv6fQcHLDQmA6644Fgu6UlcukP65SQDgRQXmaTRHAezNPqgL7l5Wkr6Mxdo KZmvLQ+Cpnh4w6IOXGzr7L0JZosE8s65dTcFu+sz74Bf1Er11uXtJ88nim+hHZu1EWpk auG28hEiebE7oSHh+lRNv1KNHYf0HZKKCOLnNNClESYNGeGHleDjGT5baxQLME26CXw9 PmPA== X-Gm-Message-State: ACgBeo190lUsYg4dTHEv59oNEppm/fVzfcxuHrB1IY08138oxLib7tIV l7bMIWhOy4kkgfojc8ytdQp0pvOOUCQ= X-Google-Smtp-Source: AA6agR7nsIhhBhHHEt0jvFcZNRLMLGWGU0IuWIn7RjsWwpJVPK9liR9jOFTPoYIO8T5JSiJ+Ke6PNQ== X-Received: by 2002:a7b:cc85:0:b0:3b4:9fc7:cd4d with SMTP id p5-20020a7bcc85000000b003b49fc7cd4dmr10127573wma.68.1663351168133; Fri, 16 Sep 2022 10:59:28 -0700 (PDT) Original-Received: from carbon.localdomain ([2a01:e0a:245:c850:98f5:429a:aa8e:95bb]) by smtp.gmail.com with ESMTPSA id d5-20020adffbc5000000b00228d6bc8450sm6218628wrs.108.2022.09.16.10.59.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 10:59:27 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=orontee@gmail.com; helo=mail-wm1-x32c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:242795 Archived-At: --=-=-= Content-Type: text/plain 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' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Extend-comint-osc-handlers-to-support-OSC-2.patch >From 9ae3c83873169765721395966205f8cd10dcc333 Mon Sep 17 00:00:00 2001 From: Matthias Meulien 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 --=-=-=--