unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Mark Oteiza <mvoteiza@udel.edu>
To: Eli Zaretskii <eliz@gnu.org>
Cc: yamaoka@jpl.org, 28591@debbugs.gnu.org
Subject: bug#28591: 27.0.50; xterm-set-window-title
Date: Sat, 30 Sep 2017 15:26:27 -0400	[thread overview]
Message-ID: <20170930192627.bevj3syhcuis3y4a@logos.localdomain> (raw)
In-Reply-To: <83bmlt76k5.fsf@gnu.org>

On 29/09/17 at 08:34pm, Eli Zaretskii wrote:
> > Date: Fri, 29 Sep 2017 09:05:42 -0400
> > From: Mark Oteiza <mvoteiza@udel.edu>
> > 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")





  reply	other threads:[~2017-09-30 19:26 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-25  9:43 bug#28591: 27.0.50; xterm-set-window-title Katsumi Yamaoka
2017-09-25 12:15 ` Mark Oteiza
2017-09-25 17:24   ` Mark Oteiza
2017-09-26  0:45     ` Katsumi Yamaoka
2017-09-26  4:08       ` Mark Oteiza
2017-09-29 10:45         ` Eli Zaretskii
2017-09-29 11:57           ` Mark Oteiza
2017-09-29 12:51             ` martin rudalics
2017-09-29 13:03               ` Mark Oteiza
2017-09-29 13:05                 ` martin rudalics
2017-09-29 13:05             ` Mark Oteiza
2017-09-29 17:34               ` Eli Zaretskii
2017-09-30 19:26                 ` Mark Oteiza [this message]
2017-10-05 10:16                   ` Eli Zaretskii
2017-10-08 20:21                     ` Mark Oteiza
2017-10-09  6:23                       ` Eli Zaretskii
2017-10-09 12:40                         ` Mark Oteiza
2020-08-24 13:39                           ` Lars Ingebrigtsen
2017-09-29 17:29             ` Eli Zaretskii
2017-09-30 19:27               ` Mark Oteiza

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170930192627.bevj3syhcuis3y4a@logos.localdomain \
    --to=mvoteiza@udel.edu \
    --cc=28591@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=yamaoka@jpl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).