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: Sat, 30 Sep 2017 15:26:27 -0400 Message-ID: <20170930192627.bevj3syhcuis3y4a@logos.localdomain> References: <87efqv9dp5.fsf@udel.edu> <87377avghj.fsf@udel.edu> <20170926040808.zofxjqrl735zeye3@logos.localdomain> <83ing1941b.fsf@gnu.org> <20170929115700.ag4xni2tckiak4nt@logos.localdomain> <20170929130542.tk47k53s5dibjfoe@logos.localdomain> <83bmlt76k5.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1506799635 30171 195.159.176.226 (30 Sep 2017 19:27:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 30 Sep 2017 19:27:15 +0000 (UTC) User-Agent: NeoMutt/20170912-48-0df7d3-dirty Cc: yamaoka@jpl.org, 28591@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Sep 30 21:27: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 1dyNPr-0007BF-6B for geb-bug-gnu-emacs@m.gmane.org; Sat, 30 Sep 2017 21:27:11 +0200 Original-Received: from localhost ([::1]:40175 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dyNPs-0003kO-Qo for geb-bug-gnu-emacs@m.gmane.org; Sat, 30 Sep 2017 15:27:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59324) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dyNPm-0003kG-E9 for bug-gnu-emacs@gnu.org; Sat, 30 Sep 2017 15:27:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dyNPi-00079Y-VV for bug-gnu-emacs@gnu.org; Sat, 30 Sep 2017 15:27:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:32790) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dyNPi-00077x-QZ for bug-gnu-emacs@gnu.org; Sat, 30 Sep 2017 15:27:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dyNPi-0005z2-Af for bug-gnu-emacs@gnu.org; Sat, 30 Sep 2017 15:27: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: Sat, 30 Sep 2017 19:27: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.150679959622956 (code B ref 28591); Sat, 30 Sep 2017 19:27:02 +0000 Original-Received: (at 28591) by debbugs.gnu.org; 30 Sep 2017 19:26:36 +0000 Original-Received: from localhost ([127.0.0.1]:41471 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dyNPI-0005yB-CT for submit@debbugs.gnu.org; Sat, 30 Sep 2017 15:26:36 -0400 Original-Received: from mail-qt0-f179.google.com ([209.85.216.179]:57018) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dyNPG-0005xy-Pf for 28591@debbugs.gnu.org; Sat, 30 Sep 2017 15:26:35 -0400 Original-Received: by mail-qt0-f179.google.com with SMTP id l25so3215243qtf.13 for <28591@debbugs.gnu.org>; Sat, 30 Sep 2017 12:26:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=udel-edu.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=WtyC1x2K77K5FOai8DMrgTBegkRdXf5RBbbPhl/1WkE=; b=XX/ST20vN8NTlflInb/hds7ioYxUxpcvW7kbXBAGYrlOzEXltSn7ORZp0mHJoZ16aV E6LYMpilUUVfOVO2ZkNUoff25PM1LCSnfzYSfYnOlZt0aNbtYxDeBmRNLTT/+ZaZCOX8 v+jp8ci2p3L2S0Q1NkXFqnEtOldJzSqNZb+UFpNGcZIpTJF17ES54tObPOHCQAGpsVab +uCcZ/om1Ra8iC+1ujuH77SRVhUJ97F0NZb8DzXrnP1OmRifQxMvME+fPt7HWF4Gqef5 nrL0l/IVw2gaPECgEvAD4fv23zkZBnl1qifF5r36NvETcF9TDUHA8Q7rz3UVdiPixLm2 +MZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=WtyC1x2K77K5FOai8DMrgTBegkRdXf5RBbbPhl/1WkE=; b=XQcy/6jqvKJera4ecoEdbf38iviMlu8B69J0J9hz+jJUTy3W0txeZvuRUCIFmHpWId lfbZWaBmmGL0FYNv214+63Dj+blZWLz00VT4PM6rBWuP03A0GghAVTq/jwM+kshzlg7V 2Tidvnvbfxpdv2nWg0kZkkyKbIkPhf+Ez1vIma/HYgMNGDNYBgT9fVxV4UknRbQAS0xE CUBqVVQG037Kyp/qmzbdlyVYg2BuPy6PVRDKSfZHSHhvJ3SMMvb/QC6n3kNVBHISuKCR 5XFvIh7bmsEUDzlw4ZcPRfVR11BND9/QGftY2Nl5hwOast97IetbCnSuJb5zCQTPyZBd MVYA== X-Gm-Message-State: AMCzsaWaAiTiH5iS83WnWHT7QhcJ6W0J9ILz5iioz8rFA4PDsJG0Hjub 3PXRsACWO8TxuQNAMg9hYIsKEu74l2g= X-Google-Smtp-Source: AOwi7QCYF1GF2jN3nzaXWZFltvJM1kU7SU/Ank0eDdRBjkRHa9I46KwLf5bwz+sIQo8krJm1XtKWOg== X-Received: by 10.200.15.8 with SMTP id e8mr12832438qtk.315.1506799589248; Sat, 30 Sep 2017 12:26:29 -0700 (PDT) Original-Received: from logos.localdomain (pool-173-67-36-61.bltmmd.fios.verizon.net. [173.67.36.61]) by smtp.gmail.com with ESMTPSA id o138sm2296390qke.89.2017.09.30.12.26.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 30 Sep 2017 12:26:28 -0700 (PDT) Content-Disposition: inline In-Reply-To: <83bmlt76k5.fsf@gnu.org> 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:137708 Archived-At: On 29/09/17 at 08:34pm, Eli Zaretskii wrote: > > Date: Fri, 29 Sep 2017 09:05:42 -0400 > > From: Mark Oteiza > > Cc: yamaoka@jpl.org, 28591@debbugs.gnu.org > > > > Correction: deleting a frame does not restore the window title as > > Katsumi pointed out. > > So you are saying the title is only restored when Emacs exits? > Otherwise, I think I'm missing something: in what case(s) your > restoration code does work? There is no restoration code at the moment--I totally overlooked it because of my shell configuration. The following works for me on a VTE based terminal. The commented bits I would expect to do _something_ on XTerm, but I have been unable to get titles to restore on XTerm, whether or not I set the allowWindowOps and disallowedWindowOps resources. diff --git a/lisp/term/xterm.el b/lisp/term/xterm.el index 6a17d382b0..337c75e0ea 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)))))) +(defun xterm--title-handler () + (let ((str "") + chr) + (while (and (setq chr (read-event nil nil 2)) + (not (eq chr ?\\))) + (setq str (concat str (string chr)))) + (push (replace-regexp-in-string "\e$" "" str) + (terminal-parameter (frame-terminal (selected-frame)) + 'xterm-saved-title)))) + (defvar xterm-query-timeout 2 "Seconds to wait for an answer from the terminal. Can be nil to mean \"no timeout\".") @@ -837,12 +847,25 @@ xterm--init-activate-set-selection (defun xterm--init-frame-title () "Terminal initialization for XTerm frame titles." + ;; (xterm-push-title-stack) + (xterm-push-window-title (frame-terminal (selected-frame))) (xterm-set-window-title) + (add-hook 'suspend-tty-functions 'xterm-pop-window-title) + (add-hook 'resume-tty-functions 'xterm-push-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 'delete-terminal-functions 'xterm-pop-window-title) + ;; (add-hook 'delete-terminal-functions 'xterm-pop-title-stack) + (add-hook 'buffer-list-update-hook 'xterm-set-window-title) (add-hook 'minibuffer-exit-hook 'xterm-set-window-title)) +;; (defun xterm-push-title-stack () +;; (send-string-to-terminal "\e[22;0t")) + +;; (defun xterm-pop-title-stack (&optional terminal) +;; (send-string-to-terminal "\e[23;0t" terminal)) + (defvar xterm-window-title-flag nil "Whether a new frame has been created, calling for a title update.") @@ -863,6 +886,15 @@ xterm-set-window-title (format "\e]2;%s\a" (format-mode-line frame-title-format)) terminal)) +(defun xterm-pop-window-title (terminal) + (send-string-to-terminal + (format "\e]2;%s\a" (pop (terminal-parameter terminal 'xterm-saved-title))) + terminal)) + +(defun xterm-push-window-title (terminal) + (xterm--query "\e[21;0t" '(("\e]l" . xterm--title-handler))) + (xterm-set-window-title terminal)) + (defun xterm--selection-char (type) (pcase type ('PRIMARY "p")