From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Mark Oteiza Newsgroups: gmane.emacs.bugs Subject: bug#28591: 27.0.50; xterm-set-window-title Date: Mon, 25 Sep 2017 13:24:24 -0400 Message-ID: <87377avghj.fsf@udel.edu> References: <87efqv9dp5.fsf@udel.edu> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1506360318 22372 195.159.176.226 (25 Sep 2017 17:25:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 25 Sep 2017 17:25:18 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.60 (gnu/linux) Cc: 28591@debbugs.gnu.org To: Katsumi Yamaoka Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Sep 25 19:25:11 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dwX82-0005KG-FN for geb-bug-gnu-emacs@m.gmane.org; Mon, 25 Sep 2017 19:25:10 +0200 Original-Received: from localhost ([::1]:43553 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwX89-0006zR-PH for geb-bug-gnu-emacs@m.gmane.org; Mon, 25 Sep 2017 13:25:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37785) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwX7z-0006q8-6o for bug-gnu-emacs@gnu.org; Mon, 25 Sep 2017 13:25:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dwX7u-0003F0-O9 for bug-gnu-emacs@gnu.org; Mon, 25 Sep 2017 13:25:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:50142) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dwX7u-0003En-Gb for bug-gnu-emacs@gnu.org; Mon, 25 Sep 2017 13:25:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dwX7u-0007k4-8V for bug-gnu-emacs@gnu.org; Mon, 25 Sep 2017 13:25:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mark Oteiza Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 25 Sep 2017 17:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28591 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 28591-submit@debbugs.gnu.org id=B28591.150636027429720 (code B ref 28591); Mon, 25 Sep 2017 17:25:02 +0000 Original-Received: (at 28591) by debbugs.gnu.org; 25 Sep 2017 17:24:34 +0000 Original-Received: from localhost ([127.0.0.1]:58823 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dwX7S-0007jI-73 for submit@debbugs.gnu.org; Mon, 25 Sep 2017 13:24:34 -0400 Original-Received: from mail-qt0-f181.google.com ([209.85.216.181]:49223) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dwX7P-0007j4-RI for 28591@debbugs.gnu.org; Mon, 25 Sep 2017 13:24:32 -0400 Original-Received: by mail-qt0-f181.google.com with SMTP id o3so7659948qte.6 for <28591@debbugs.gnu.org>; Mon, 25 Sep 2017 10:24:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=udel-edu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=3U2THie92/LadJ+VCPpvo29W5Z7VAVdX5Ti0aOKhaZo=; b=lp+z05/SDaPxIoIhWDbTWEIx8D2Xhp7SShIV9EmMlpiDYC/wOqlY070ZBG/UjVCfOO FWVlhCa4mJ38AuEjELuC1CRk6pSgzx5a/i9DL2MWK5uhBNXYxFO0DhHDp9++Jrmqtdtc blpShllxLUFNNK+nmobvuGgxJLo3wQUVQmBPak5CrdVKqTTq3GNA+gTDrKZ7zffPQqDp LGmDYr4TPV6JI0BNyGcjDoIpc9c2RIfje4vKQt+bvJ1/CoREl9iHVnAbOCn9mpUL3lUj KeauZP8+T7Jz628X3Ux8I+NLQh/QSamg2ChSF1Quv4q+H7yDb3nzV+SVQIGsAkv0MDd/ zorw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=3U2THie92/LadJ+VCPpvo29W5Z7VAVdX5Ti0aOKhaZo=; b=ZROl4PnxMYgbzrZ4wBl1rOPDPeMeMs3A6tt/wxhGGK1IltQIYWlyyL6dZoeMN+eKNm nM1vQlRoRIlcjhXx8lopZ69hdv6/Fy+7X3QwZy0U4EkCuSMuXRQ/7YSiKIYlGkM3qdN2 LuI90asp5SvwHImqIn0MyGnw8Zprw+wQURi3fANnHQCR+HUHsM2f+5WuamwMzboRANzY ajNBnqfnFhvh+35SW76UuNYoBGyM7Uin3Vb6E1sEDZ7t2D6lCXR6ZbJtYVkhlsgFbuin iAx7IwwFI44OqBfuK6SqRuxFR9Rk2qJKq8zY4VOdkgXjztWdkIocJig6ib3U0LU6M8GL E9ew== X-Gm-Message-State: AHPjjUhBy1ex/tdmgybwYZLDNIijh9Ed2rp6WmbYuYwIMvnVPrijIxMl rexx4qM+z75ohVqK/jyUHIyj0XJ2Dpk= X-Google-Smtp-Source: AOwi7QBKJrhL4z6kpjz1ec5WJRg+QyVj9EP3zpUmrgn2DDtwfKfW3DAcsZ7K1a5e+ofFFSZr01vmmw== X-Received: by 10.200.35.204 with SMTP id r12mr12711365qtr.95.1506360266072; Mon, 25 Sep 2017 10:24:26 -0700 (PDT) Original-Received: from logos (pool-173-67-36-61.bltmmd.fios.verizon.net. [173.67.36.61]) by smtp.gmail.com with ESMTPSA id s27sm5300424qtj.60.2017.09.25.10.24.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Sep 2017 10:24:25 -0700 (PDT) In-Reply-To: <87efqv9dp5.fsf@udel.edu> (Mark Oteiza's message of "Mon, 25 Sep 2017 08:15:34 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:137430 Archived-At: Mark Oteiza writes: > Katsumi Yamaoka writes: > >> The feature looks nice but I want the original title to come back >> when Emacs exits or suspends (even if it launches with -Q). > > I posted a patch here > https://lists.gnu.org/archive/html/emacs-devel/2017-09/msg00728.html > > but at the moment it's not clear to me how to handle other terminals > that use an xterm- family terminfo. The following lightly tested patch appears to do the right thing here. diff --git a/lisp/term/xterm.el b/lisp/term/xterm.el index 6a17d382b0..d7214fc849 100644 --- a/lisp/term/xterm.el +++ b/lisp/term/xterm.el @@ -708,6 +708,16 @@ xterm--version-handler ;;(xterm--init-activate-get-selection) (xterm--init-activate-set-selection)))))) +(defvar xterm-window-title-stack nil) + +(defun xterm--title-handler () + (let ((str "") + chr) + (while (and (setq chr (read-event nil nil 2)) + (not (equal chr ?\\))) + (setq str (concat str (string chr)))) + (push str xterm-window-title-stack))) + (defvar xterm-query-timeout 2 "Seconds to wait for an answer from the terminal. Can be nil to mean \"no timeout\".") @@ -837,12 +847,28 @@ xterm--init-activate-set-selection (defun xterm--init-frame-title () "Terminal initialization for XTerm frame titles." + (xterm-push-title-stack) (xterm-set-window-title) + (add-hook 'delete-frame-functions 'xterm-pop-title-stack) (add-hook 'after-make-frame-functions 'xterm-set-window-title-flag) (add-hook 'window-configuration-change-hook 'xterm-unset-window-title-flag) - (add-hook 'post-command-hook 'xterm-set-window-title) + (add-hook 'pre-redisplay-functions 'xterm-set-window-title) (add-hook 'minibuffer-exit-hook 'xterm-set-window-title)) +(defun xterm-push-title-stack () + "Store terminal window title in XTerm's internal stack." + ;; (send-string-to-terminal "\e[22;0t") + (xterm--query "\e[21;0t" + '(("\e]l" . xterm--title-handler)))) + +(defun xterm-pop-title-stack (&optional terminal) + "Pop terminal window title from XTerm's internal stack." + ;; (send-string-to-terminal "\e[23;0t" terminal) + (when xterm-window-title-stack + (send-string-to-terminal + (format "\e]2;%s\a" (pop xterm-window-title-stack)) + terminal))) + (defvar xterm-window-title-flag nil "Whether a new frame has been created, calling for a title update.") @@ -861,7 +887,7 @@ xterm-set-window-title The title is constructed from `frame-title-format'." (send-string-to-terminal (format "\e]2;%s\a" (format-mode-line frame-title-format)) - terminal)) + (if (windowp terminal) (window-frame terminal) terminal))) (defun xterm--selection-char (type) (pcase type