GNU bug report logs - #28591
27.0.50; xterm-set-window-title

Previous Next

Package: emacs;

Reported by: Katsumi Yamaoka <yamaoka <at> jpl.org>

Date: Mon, 25 Sep 2017 09:44:02 UTC

Severity: minor

Found in version 27.0.50

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 28591 in the body.
You can then email your comments to 28591 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#28591; Package emacs. (Mon, 25 Sep 2017 09:44:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Katsumi Yamaoka <yamaoka <at> jpl.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 25 Sep 2017 09:44:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Katsumi Yamaoka <yamaoka <at> jpl.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.0.50; xterm-set-window-title
Date: Mon, 25 Sep 2017 18:43:45 +0900
Hi,

The feature looks nice but I want the original title to come back
when Emacs exits or suspends (even if it launches with -Q).

Thanks.

In GNU Emacs 27.0.50 (build 1, i686-pc-cygwin, GTK+ Version 3.18.9)
 of 2017-09-25 built on localhost
Windowing system distributor 'The Cygwin/X Project', version 11.0.11900000




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28591; Package emacs. (Mon, 25 Sep 2017 12:16:01 GMT) Full text and rfc822 format available.

Message #8 received at 28591 <at> debbugs.gnu.org (full text, mbox):

From: Mark Oteiza <mvoteiza <at> udel.edu>
To: Katsumi Yamaoka <yamaoka <at> jpl.org>
Cc: 28591 <at> debbugs.gnu.org
Subject: Re: bug#28591: 27.0.50; xterm-set-window-title
Date: Mon, 25 Sep 2017 08:15:34 -0400
Katsumi Yamaoka <yamaoka <at> jpl.org> 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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28591; Package emacs. (Mon, 25 Sep 2017 17:25:02 GMT) Full text and rfc822 format available.

Message #11 received at 28591 <at> debbugs.gnu.org (full text, mbox):

From: Mark Oteiza <mvoteiza <at> udel.edu>
To: Katsumi Yamaoka <yamaoka <at> jpl.org>
Cc: 28591 <at> debbugs.gnu.org
Subject: Re: bug#28591: 27.0.50; xterm-set-window-title
Date: Mon, 25 Sep 2017 13:24:24 -0400
Mark Oteiza <mvoteiza <at> udel.edu> writes:

> Katsumi Yamaoka <yamaoka <at> jpl.org> 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28591; Package emacs. (Tue, 26 Sep 2017 00:46:01 GMT) Full text and rfc822 format available.

Message #14 received at 28591 <at> debbugs.gnu.org (full text, mbox):

From: Katsumi Yamaoka <yamaoka <at> jpl.org>
To: Mark Oteiza <mvoteiza <at> udel.edu>
Cc: 28591 <at> debbugs.gnu.org
Subject: Re: bug#28591: 27.0.50; xterm-set-window-title
Date: Tue, 26 Sep 2017 09:45:01 +0900
On Mon, 25 Sep 2017 13:24:24 -0400, Mark Oteiza wrote:
> Mark Oteiza <mvoteiza <at> udel.edu> writes:

>> Katsumi Yamaoka <yamaoka <at> jpl.org> 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.

I use:

$ xterm -v
XTerm(327)

$ xterm&
Then the title bar of the launched xterm shows "xterm".

> The following lightly tested patch appears to do the right thing here.

Thanks.  I tried.  But nothing seems to be changed unfortunately.
When I run `emacs -nw' in the xterm, the title becomes to
"emacs <at> hostname" but the original title "xterm" is not pushed to
the `xterm-window-title-stack' variable.  And the title does not
come back to "xterm" when I exit or suspend Emacs -nw.

I tried adding `(error "XXX")' to the `xterm--title-handler'
function but nothing happens (with no error).  So, the function
doesn't seem to run by way of `xterm-push-title-stack'.

Regards,




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28591; Package emacs. (Tue, 26 Sep 2017 04:09:02 GMT) Full text and rfc822 format available.

Message #17 received at 28591 <at> debbugs.gnu.org (full text, mbox):

From: Mark Oteiza <mvoteiza <at> udel.edu>
To: Katsumi Yamaoka <yamaoka <at> jpl.org>
Cc: 28591 <at> debbugs.gnu.org
Subject: Re: bug#28591: 27.0.50; xterm-set-window-title
Date: Tue, 26 Sep 2017 00:08:08 -0400
On 26/09/17 at 12:45am, Katsumi Yamaoka wrote:
> On Mon, 25 Sep 2017 13:24:24 -0400, Mark Oteiza wrote:
> > Mark Oteiza <mvoteiza <at> udel.edu> writes:
> 
> >> Katsumi Yamaoka <yamaoka <at> jpl.org> 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.
> 
> I use:
> 
> $ xterm -v
> XTerm(327)
> 
> $ xterm&
> Then the title bar of the launched xterm shows "xterm".
> 
> > The following lightly tested patch appears to do the right thing here.
> 
> Thanks.  I tried.  But nothing seems to be changed unfortunately.
> When I run `emacs -nw' in the xterm, the title becomes to
> "emacs <at> hostname" but the original title "xterm" is not pushed to
> the `xterm-window-title-stack' variable.  And the title does not
> come back to "xterm" when I exit or suspend Emacs -nw.
> 
> I tried adding `(error "XXX")' to the `xterm--title-handler'
> function but nothing happens (with no error).  So, the function
> doesn't seem to run by way of `xterm-push-title-stack'.

Grr, thanks.  I see what you're seeing in XTerm 330.  I am stumped--not
sure this is possible in Elisp, so I'm inclined to revert.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28591; Package emacs. (Fri, 29 Sep 2017 10:47:01 GMT) Full text and rfc822 format available.

Message #20 received at 28591 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Mark Oteiza <mvoteiza <at> udel.edu>
Cc: yamaoka <at> jpl.org, 28591 <at> debbugs.gnu.org
Subject: Re: bug#28591: 27.0.50; xterm-set-window-title
Date: Fri, 29 Sep 2017 13:45:36 +0300
> Date: Tue, 26 Sep 2017 00:08:08 -0400
> From: Mark Oteiza <mvoteiza <at> udel.edu>
> Cc: 28591 <at> debbugs.gnu.org
> 
> > > The following lightly tested patch appears to do the right thing here.
> > 
> > Thanks.  I tried.  But nothing seems to be changed unfortunately.
> > When I run `emacs -nw' in the xterm, the title becomes to
> > "emacs <at> hostname" but the original title "xterm" is not pushed to
> > the `xterm-window-title-stack' variable.  And the title does not
> > come back to "xterm" when I exit or suspend Emacs -nw.
> > 
> > I tried adding `(error "XXX")' to the `xterm--title-handler'
> > function but nothing happens (with no error).  So, the function
> > doesn't seem to run by way of `xterm-push-title-stack'.
> 
> Grr, thanks.  I see what you're seeing in XTerm 330.  I am stumped--not
> sure this is possible in Elisp, so I'm inclined to revert.

That'd be too drastic, I think.  The code did work for you, right?  So
it definitely works for some configurations out there, and I think we
could leave it in Emacs, turned off by default, and allow its optional
activation with the proper warning that it might not work for some
versions of xterm.

WDYT?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28591; Package emacs. (Fri, 29 Sep 2017 11:58:01 GMT) Full text and rfc822 format available.

Message #23 received at 28591 <at> debbugs.gnu.org (full text, mbox):

From: Mark Oteiza <mvoteiza <at> udel.edu>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: yamaoka <at> jpl.org, 28591 <at> debbugs.gnu.org
Subject: Re: bug#28591: 27.0.50; xterm-set-window-title
Date: Fri, 29 Sep 2017 07:57:00 -0400
On 29/09/17 at 01:45pm, Eli Zaretskii wrote:
> > Date: Tue, 26 Sep 2017 00:08:08 -0400
> > From: Mark Oteiza <mvoteiza <at> udel.edu>
> > Cc: 28591 <at> debbugs.gnu.org
> > 
> > > > The following lightly tested patch appears to do the right thing here.
> > > 
> > > Thanks.  I tried.  But nothing seems to be changed unfortunately.
> > > When I run `emacs -nw' in the xterm, the title becomes to
> > > "emacs <at> hostname" but the original title "xterm" is not pushed to
> > > the `xterm-window-title-stack' variable.  And the title does not
> > > come back to "xterm" when I exit or suspend Emacs -nw.
> > > 
> > > I tried adding `(error "XXX")' to the `xterm--title-handler'
> > > function but nothing happens (with no error).  So, the function
> > > doesn't seem to run by way of `xterm-push-title-stack'.
> > 
> > Grr, thanks.  I see what you're seeing in XTerm 330.  I am stumped--not
> > sure this is possible in Elisp, so I'm inclined to revert.
> 
> That'd be too drastic, I think.  The code did work for you, right?  So
> it definitely works for some configurations out there, and I think we
> could leave it in Emacs, turned off by default, and allow its optional
> activation with the proper warning that it might not work for some
> versions of xterm.

Everything except foregrounding a client works (I did not test this),
where the following occurs:

  Error in post-command-hook (xterm-set-window-title): (error "Terminal
  is currently suspended")

post-command-hook is used to catch changing windows within a frame--I
do not know if there is another hook (or event perhaps) that would
better serve this purpose.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28591; Package emacs. (Fri, 29 Sep 2017 12:52:02 GMT) Full text and rfc822 format available.

Message #26 received at 28591 <at> debbugs.gnu.org (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: Mark Oteiza <mvoteiza <at> udel.edu>, Eli Zaretskii <eliz <at> gnu.org>
Cc: yamaoka <at> jpl.org, 28591 <at> debbugs.gnu.org
Subject: Re: bug#28591: 27.0.50; xterm-set-window-title
Date: Fri, 29 Sep 2017 14:51:37 +0200
> post-command-hook is used to catch changing windows within a frame--I
> do not know if there is another hook (or event perhaps) that would
> better serve this purpose.

‘window-configuration-change-hook’ is the canonical hook to "to catch
changing windows within a frame".  But maybe I'm missing something.

martin





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28591; Package emacs. (Fri, 29 Sep 2017 13:04:02 GMT) Full text and rfc822 format available.

Message #29 received at 28591 <at> debbugs.gnu.org (full text, mbox):

From: Mark Oteiza <mvoteiza <at> udel.edu>
To: martin rudalics <rudalics <at> gmx.at>
Cc: 28591 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>, yamaoka <at> jpl.org
Subject: Re: bug#28591: 27.0.50; xterm-set-window-title
Date: Fri, 29 Sep 2017 09:03:10 -0400
On 29/09/17 at 02:51pm, martin rudalics wrote:
> > post-command-hook is used to catch changing windows within a frame--I
> > do not know if there is another hook (or event perhaps) that would
> > better serve this purpose.
> 
> ‘window-configuration-change-hook’ is the canonical hook to "to catch
> changing windows within a frame".  But maybe I'm missing something.

Sorry, I meant changing window focus; for instance with `other-window'.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28591; Package emacs. (Fri, 29 Sep 2017 13:06:02 GMT) Full text and rfc822 format available.

Message #32 received at 28591 <at> debbugs.gnu.org (full text, mbox):

From: Mark Oteiza <mvoteiza <at> udel.edu>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: yamaoka <at> jpl.org, 28591 <at> debbugs.gnu.org
Subject: Re: bug#28591: 27.0.50; xterm-set-window-title
Date: Fri, 29 Sep 2017 09:05:42 -0400
On 29/09/17 at 07:57am, Mark Oteiza wrote:
> On 29/09/17 at 01:45pm, Eli Zaretskii wrote:
> > > Date: Tue, 26 Sep 2017 00:08:08 -0400
> > > From: Mark Oteiza <mvoteiza <at> udel.edu>
> > > Cc: 28591 <at> debbugs.gnu.org
> > > 
> > > > > The following lightly tested patch appears to do the right thing here.
> > > > 
> > > > Thanks.  I tried.  But nothing seems to be changed unfortunately.
> > > > When I run `emacs -nw' in the xterm, the title becomes to
> > > > "emacs <at> hostname" but the original title "xterm" is not pushed to
> > > > the `xterm-window-title-stack' variable.  And the title does not
> > > > come back to "xterm" when I exit or suspend Emacs -nw.
> > > > 
> > > > I tried adding `(error "XXX")' to the `xterm--title-handler'
> > > > function but nothing happens (with no error).  So, the function
> > > > doesn't seem to run by way of `xterm-push-title-stack'.
> > > 
> > > Grr, thanks.  I see what you're seeing in XTerm 330.  I am stumped--not
> > > sure this is possible in Elisp, so I'm inclined to revert.
> > 
> > That'd be too drastic, I think.  The code did work for you, right?  So
> > it definitely works for some configurations out there, and I think we
> > could leave it in Emacs, turned off by default, and allow its optional
> > activation with the proper warning that it might not work for some
> > versions of xterm.
> 
> Everything except foregrounding a client works (I did not test this),
> where the following occurs:

Correction: deleting a frame does not restore the window title as
Katsumi pointed out.

I have a shell hook that sets the window title which I keep
forgetting to disable when testing this




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28591; Package emacs. (Fri, 29 Sep 2017 13:06:02 GMT) Full text and rfc822 format available.

Message #35 received at 28591 <at> debbugs.gnu.org (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: Mark Oteiza <mvoteiza <at> udel.edu>
Cc: 28591 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>, yamaoka <at> jpl.org
Subject: Re: bug#28591: 27.0.50; xterm-set-window-title
Date: Fri, 29 Sep 2017 15:05:38 +0200
> Sorry, I meant changing window focus; for instance with `other-window'.

Then try ‘buffer-list-update-hook’.

martin





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28591; Package emacs. (Fri, 29 Sep 2017 17:30:02 GMT) Full text and rfc822 format available.

Message #38 received at 28591 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Mark Oteiza <mvoteiza <at> udel.edu>
Cc: yamaoka <at> jpl.org, 28591 <at> debbugs.gnu.org
Subject: Re: bug#28591: 27.0.50; xterm-set-window-title
Date: Fri, 29 Sep 2017 20:29:38 +0300
> Date: Fri, 29 Sep 2017 07:57:00 -0400
> From: Mark Oteiza <mvoteiza <at> udel.edu>
> Cc: yamaoka <at> jpl.org, 28591 <at> debbugs.gnu.org
> 
> Everything except foregrounding a client works (I did not test this),
> where the following occurs:
> 
>   Error in post-command-hook (xterm-set-window-title): (error "Terminal
>   is currently suspended")

This error comes from here:

  DEFUN ("send-string-to-terminal", Fsend_string_to_terminal,
	 Ssend_string_to_terminal, 1, 2, 0,
	 doc: /* Send STRING to the terminal without alteration.
  Control characters in STRING will have terminal-dependent effects.

  Optional parameter TERMINAL specifies the tty terminal device to use.
  It may be a terminal object, a frame, or nil for the terminal used by
  the currently selected frame.  In batch mode, STRING is sent to stdout
  when TERMINAL is nil.  */)
    (Lisp_Object string, Lisp_Object terminal)
  {

    ...
	if (! tty->output)
	  error ("Terminal is currently suspended");

So one way of fixing it would be to have a suspend-hook set some flag
which your post-command-hook would check, and avoid calling
send-string-to-terminal when the terminal is suspended.

Another possibility would be to add a utility function, called
'tty-suspended-p', which you could then test in your
post-command-hook.  Its implementation should test the tty->output
value.

Would any of this make sense?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28591; Package emacs. (Fri, 29 Sep 2017 17:35:02 GMT) Full text and rfc822 format available.

Message #41 received at 28591 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Mark Oteiza <mvoteiza <at> udel.edu>
Cc: yamaoka <at> jpl.org, 28591 <at> debbugs.gnu.org
Subject: Re: bug#28591: 27.0.50; xterm-set-window-title
Date: Fri, 29 Sep 2017 20:34:02 +0300
> Date: Fri, 29 Sep 2017 09:05:42 -0400
> From: Mark Oteiza <mvoteiza <at> udel.edu>
> Cc: yamaoka <at> jpl.org, 28591 <at> 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?





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28591; Package emacs. (Sat, 30 Sep 2017 19:27:02 GMT) Full text and rfc822 format available.

Message #44 received at 28591 <at> debbugs.gnu.org (full text, mbox):

From: Mark Oteiza <mvoteiza <at> udel.edu>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: yamaoka <at> jpl.org, 28591 <at> debbugs.gnu.org
Subject: Re: bug#28591: 27.0.50; xterm-set-window-title
Date: Sat, 30 Sep 2017 15:26:27 -0400
On 29/09/17 at 08:34pm, Eli Zaretskii wrote:
> > Date: Fri, 29 Sep 2017 09:05:42 -0400
> > From: Mark Oteiza <mvoteiza <at> udel.edu>
> > Cc: yamaoka <at> jpl.org, 28591 <at> 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")




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28591; Package emacs. (Sat, 30 Sep 2017 19:28:01 GMT) Full text and rfc822 format available.

Message #47 received at 28591 <at> debbugs.gnu.org (full text, mbox):

From: Mark Oteiza <mvoteiza <at> udel.edu>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: yamaoka <at> jpl.org, 28591 <at> debbugs.gnu.org
Subject: Re: bug#28591: 27.0.50; xterm-set-window-title
Date: Sat, 30 Sep 2017 15:27:34 -0400
On 29/09/17 at 08:29pm, Eli Zaretskii wrote:
> > Date: Fri, 29 Sep 2017 07:57:00 -0400
> > From: Mark Oteiza <mvoteiza <at> udel.edu>
> > Cc: yamaoka <at> jpl.org, 28591 <at> debbugs.gnu.org
> > 
> > Everything except foregrounding a client works (I did not test this),
> > where the following occurs:
> > 
> >   Error in post-command-hook (xterm-set-window-title): (error "Terminal
> >   is currently suspended")
> 
> This error comes from here:
> 
>   DEFUN ("send-string-to-terminal", Fsend_string_to_terminal,
> 	 Ssend_string_to_terminal, 1, 2, 0,
> 	 doc: /* Send STRING to the terminal without alteration.
>   Control characters in STRING will have terminal-dependent effects.
> 
>   Optional parameter TERMINAL specifies the tty terminal device to use.
>   It may be a terminal object, a frame, or nil for the terminal used by
>   the currently selected frame.  In batch mode, STRING is sent to stdout
>   when TERMINAL is nil.  */)
>     (Lisp_Object string, Lisp_Object terminal)
>   {
> 
>     ...
> 	if (! tty->output)
> 	  error ("Terminal is currently suspended");
> 
> So one way of fixing it would be to have a suspend-hook set some flag
> which your post-command-hook would check, and avoid calling
> send-string-to-terminal when the terminal is suspended.
> 
> Another possibility would be to add a utility function, called
> 'tty-suspended-p', which you could then test in your
> post-command-hook.  Its implementation should test the tty->output
> value.
> 
> Would any of this make sense?

It would, but I ended up taking Martin's suggestion and replacing the
use of post-command-hook with instead using buffer-list-update-hook,
which doesn't have this problem.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28591; Package emacs. (Thu, 05 Oct 2017 10:17:01 GMT) Full text and rfc822 format available.

Message #50 received at 28591 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Mark Oteiza <mvoteiza <at> udel.edu>
Cc: yamaoka <at> jpl.org, 28591 <at> debbugs.gnu.org
Subject: Re: bug#28591: 27.0.50; xterm-set-window-title
Date: Thu, 05 Oct 2017 13:16:24 +0300
> Date: Sat, 30 Sep 2017 15:26:27 -0400
> From: Mark Oteiza <mvoteiza <at> udel.edu>
> Cc: yamaoka <at> jpl.org, 28591 <at> debbugs.gnu.org
> 
> > 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.

OK, how about pushing this to master, with some defcustom, by default
off, to control whether this feature is used?  With any luck, we might
have contributions for others to increase the number of configurations
supported by this feature.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28591; Package emacs. (Sun, 08 Oct 2017 20:22:01 GMT) Full text and rfc822 format available.

Message #53 received at 28591 <at> debbugs.gnu.org (full text, mbox):

From: Mark Oteiza <mvoteiza <at> udel.edu>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: yamaoka <at> jpl.org, 28591 <at> debbugs.gnu.org
Subject: Re: bug#28591: 27.0.50; xterm-set-window-title
Date: Sun, 8 Oct 2017 16:21:40 -0400
On 05/10/17 at 01:16pm, Eli Zaretskii wrote:
> > Date: Sat, 30 Sep 2017 15:26:27 -0400
> > From: Mark Oteiza <mvoteiza <at> udel.edu>
> > Cc: yamaoka <at> jpl.org, 28591 <at> debbugs.gnu.org
> > 
> > > 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.
> 
> OK, how about pushing this to master, with some defcustom, by default
> off, to control whether this feature is used?  With any luck, we might
> have contributions for others to increase the number of configurations
> supported by this feature.

After running with the patch for a bit, I notice sometimes there is
a long (second or two) delay when opening a new frame--I guess because
of a possible delay like is mentioned in delete-frame-functions.
I would prefer to simply turn the existing code off by default than
introduce possibly more broken behavior, especially when it only
supports a subset of xterm-like terminals.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28591; Package emacs. (Mon, 09 Oct 2017 06:24:02 GMT) Full text and rfc822 format available.

Message #56 received at 28591 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Mark Oteiza <mvoteiza <at> udel.edu>
Cc: yamaoka <at> jpl.org, 28591 <at> debbugs.gnu.org
Subject: Re: bug#28591: 27.0.50; xterm-set-window-title
Date: Mon, 09 Oct 2017 09:23:26 +0300
> Date: Sun, 8 Oct 2017 16:21:40 -0400
> From: Mark Oteiza <mvoteiza <at> udel.edu>
> Cc: yamaoka <at> jpl.org, 28591 <at> debbugs.gnu.org
> 
> I would prefer to simply turn the existing code off by default than
> introduce possibly more broken behavior, especially when it only
> supports a subset of xterm-like terminals.

Fine with me, thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28591; Package emacs. (Mon, 09 Oct 2017 12:41:02 GMT) Full text and rfc822 format available.

Message #59 received at 28591 <at> debbugs.gnu.org (full text, mbox):

From: Mark Oteiza <mvoteiza <at> udel.edu>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: yamaoka <at> jpl.org, 28591 <at> debbugs.gnu.org
Subject: Re: bug#28591: 27.0.50; xterm-set-window-title
Date: Mon, 9 Oct 2017 08:40:36 -0400
On 09/10/17 at 09:23am, Eli Zaretskii wrote:
> > Date: Sun, 8 Oct 2017 16:21:40 -0400
> > From: Mark Oteiza <mvoteiza <at> udel.edu>
> > Cc: yamaoka <at> jpl.org, 28591 <at> debbugs.gnu.org
> > 
> > I would prefer to simply turn the existing code off by default than
> > introduce possibly more broken behavior, especially when it only
> > supports a subset of xterm-like terminals.
> 
> Fine with me, thanks.

Change pushed.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28591; Package emacs. (Mon, 24 Aug 2020 13:40:01 GMT) Full text and rfc822 format available.

Message #62 received at 28591 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Mark Oteiza <mvoteiza <at> udel.edu>
Cc: 28591 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>, yamaoka <at> jpl.org
Subject: Re: bug#28591: 27.0.50; xterm-set-window-title
Date: Mon, 24 Aug 2020 15:39:27 +0200
Mark Oteiza <mvoteiza <at> udel.edu> writes:

>> > I would prefer to simply turn the existing code off by default than
>> > introduce possibly more broken behavior, especially when it only
>> > supports a subset of xterm-like terminals.
>> 
>> Fine with me, thanks.
>
> Change pushed.

Skimming this thread, it seems like the reported problem was fixed, and
I'm closing this bug report.  If this is wrong, please respond to the
debbugs address and we'll reopen the report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug closed, send any further explanations to 28591 <at> debbugs.gnu.org and Katsumi Yamaoka <yamaoka <at> jpl.org> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 24 Aug 2020 13:40:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 22 Sep 2020 11:24:12 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 189 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.