GNU bug report logs -
#28340
26.0.50; xterm frame titles
Previous Next
Reported by: Mark Oteiza <mvoteiza <at> udel.edu>
Date: Sun, 3 Sep 2017 21:38:01 UTC
Severity: wishlist
Found in version 26.0.50
Done: Mark Oteiza <mvoteiza <at> udel.edu>
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 28340 in the body.
You can then email your comments to 28340 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#28340
; Package
emacs
.
(Sun, 03 Sep 2017 21:38:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Mark Oteiza <mvoteiza <at> udel.edu>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sun, 03 Sep 2017 21:38:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Wishlist item.
Hi,
I tacked setting window/iconified window titles into term/xterm.el, but
found a quirk I suspect is related to Bug#18137 (which refers to
42fe2e88d and Bug#15025). Because clients don't always have focus,
opening a new client won't trigger hooks that I would think trigger,
perhaps even after-make-frame-functions or window-size-change-functions.
diff --git a/lisp/term/xterm.el b/lisp/term/xterm.el
index e6d224dd3d..03dd516ebf 100644
--- a/lisp/term/xterm.el
+++ b/lisp/term/xterm.el
@@ -802,6 +802,7 @@ terminal-init-xterm
(when (memq 'setSelection xterm-extra-capabilities)
(xterm--init-activate-set-selection)))
+ (xterm--init-frame-title)
;; Unconditionally enable bracketed paste mode: terminals that don't
;; support it just ignore the sequence.
(xterm--init-bracketed-paste-mode)
@@ -828,6 +829,22 @@ xterm--init-activate-set-selection
"Terminal initialization for `gui-set-selection'."
(set-terminal-parameter nil 'xterm--set-selection t))
+(defun xterm--init-frame-title ()
+ "Terminal initialization for `gui-set-selection'."
+ (xterm-set-window-title)
+ (add-hook 'post-command-hook 'xterm-set-window-title)
+ (add-hook 'minibuffer-exit-hook 'xterm-set-window-title))
+
+(defun xterm-set-window-title ()
+ "Set the window title of the Xterm with the current Emacs frame."
+ (send-string-to-terminal
+ (format "\e]2;%s\a" (format-mode-line frame-title-format))))
+
+(defun xterm-set-icon-title ()
+ "Set the window title of the Xterm with the current Emacs frame."
+ (send-string-to-terminal
+ (format "\e]1;%s\a" (format-mode-line icon-title-format))))
+
(defun xterm--selection-char (type)
(pcase type
('PRIMARY "p")
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#28340
; Package
emacs
.
(Mon, 04 Sep 2017 04:18:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 28340 <at> debbugs.gnu.org (full text, mbox):
> From: Mark Oteiza <mvoteiza <at> udel.edu>
> Date: Sun, 03 Sep 2017 17:37:24 -0400
>
> Wishlist item.
>
> Hi,
>
> I tacked setting window/iconified window titles into term/xterm.el, but
Thanks. This needs a NEWS entry, and I think there should be a
defcustom to turn this off, for those who'd like the default title
provided by xterm.
> found a quirk I suspect is related to Bug#18137 (which refers to
> 42fe2e88d and Bug#15025). Because clients don't always have focus,
> opening a new client won't trigger hooks that I would think trigger,
> perhaps even after-make-frame-functions or window-size-change-functions.
Maybe one of the hooks provided by server.el would fit the bill?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#28340
; Package
emacs
.
(Tue, 12 Sep 2017 01:22:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 28340 <at> debbugs.gnu.org (full text, mbox):
On 04/09/17 at 07:16am, Eli Zaretskii wrote:
> > From: Mark Oteiza <mvoteiza <at> udel.edu>
> > Date: Sun, 03 Sep 2017 17:37:24 -0400
> > I tacked setting window/iconified window titles into term/xterm.el, but
>
> Thanks. This needs a NEWS entry, and I think there should be a
> defcustom to turn this off, for those who'd like the default title
> provided by xterm.
Ok.
> > found a quirk I suspect is related to Bug#18137 (which refers to
> > 42fe2e88d and Bug#15025). Because clients don't always have focus,
> > opening a new client won't trigger hooks that I would think trigger,
> > perhaps even after-make-frame-functions or window-size-change-functions.
>
> Maybe one of the hooks provided by server.el would fit the bill?
Nope, none of those appear relevant, and hooking into them does nothing
apparent. Even doing the following, I get the title as the selected
buffer in the previously selected frame.
Messaging (frame-list) in xterm-test shows that the car of the list is
always the new frame, but still the frame title is incorrect--a new
frame created by emacsclient -t ends up on the scratch buffer. I say
"ends up" because sometimes I see another buffer flash before I see the
scratch buffer. This all seems a little buggy to me, but I know
Bug#18137 and its ancestors were tough.
(defun xterm--init-frame-title ()
"Terminal initialization for `gui-set-selection'."
(xterm-set-window-title)
(add-hook 'after-make-frame-functions 'xterm-test)
(add-hook 'server-switch-hook 'xterm-test)
;; (add-hook 'window-size-change-functions 'xterm-set-window-title)
;; (add-hook 'post-command-hook 'xterm-set-window-title)
;; (add-hook 'minibuffer-exit-hook 'xterm-set-window-title)
)
(defun xterm-test (&optional frame)
(select-frame (car (frame-list)))
(xterm-set-window-title frame))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#28340
; Package
emacs
.
(Wed, 20 Sep 2017 07:48:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 28340 <at> debbugs.gnu.org (full text, mbox):
> Date: Mon, 11 Sep 2017 21:21:22 -0400
> From: Mark Oteiza <mvoteiza <at> udel.edu>
> Cc: 28340 <at> debbugs.gnu.org
>
> > Maybe one of the hooks provided by server.el would fit the bill?
>
> Nope, none of those appear relevant, and hooking into them does nothing
> apparent. Even doing the following, I get the title as the selected
> buffer in the previously selected frame.
>
> Messaging (frame-list) in xterm-test shows that the car of the list is
> always the new frame, but still the frame title is incorrect--a new
> frame created by emacsclient -t ends up on the scratch buffer. I say
> "ends up" because sometimes I see another buffer flash before I see the
> scratch buffer. This all seems a little buggy to me, but I know
> Bug#18137 and its ancestors were tough.
What about window-configuration-change-hook, does that help? You
could set some flag in after-make-frame-functions, and then test and
reset that flag in window-configuration-change-hook, when you see that
a buffer is switched in the frame. Would that work?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#28340
; Package
emacs
.
(Wed, 20 Sep 2017 12:24:01 GMT)
Full text and
rfc822 format available.
Message #17 received at 28340 <at> debbugs.gnu.org (full text, mbox):
On 20/09/17 at 07:47am, Eli Zaretskii wrote:
> > Date: Mon, 11 Sep 2017 21:21:22 -0400
> > From: Mark Oteiza <mvoteiza <at> udel.edu>
> > Cc: 28340 <at> debbugs.gnu.org
> >
> > > Maybe one of the hooks provided by server.el would fit the bill?
> >
> > Nope, none of those appear relevant, and hooking into them does nothing
> > apparent. Even doing the following, I get the title as the selected
> > buffer in the previously selected frame.
> >
> > Messaging (frame-list) in xterm-test shows that the car of the list is
> > always the new frame, but still the frame title is incorrect--a new
> > frame created by emacsclient -t ends up on the scratch buffer. I say
> > "ends up" because sometimes I see another buffer flash before I see the
> > scratch buffer. This all seems a little buggy to me, but I know
> > Bug#18137 and its ancestors were tough.
>
> What about window-configuration-change-hook, does that help? You
> could set some flag in after-make-frame-functions, and then test and
> reset that flag in window-configuration-change-hook, when you see that
> a buffer is switched in the frame. Would that work?
This appears to work, thank you. Please see attached.
diff --git a/lisp/term/xterm.el b/lisp/term/xterm.el
index 4f79703833..a11acbc4db 100644
--- a/lisp/term/xterm.el
+++ b/lisp/term/xterm.el
@@ -68,6 +68,11 @@ xterm-max-cut-length
:version "25.1"
:type 'integer)
+(defcustom xterm-set-window-title t
+ "Whether Emacs should set window titles to an Emacs frame in an XTerm."
+ :version "27.1"
+ :type 'boolean)
+
(defconst xterm-paste-ending-sequence "\e[201~"
"Characters send by the terminal to end a bracketed paste.")
@@ -802,6 +807,8 @@ terminal-init-xterm
(when (memq 'setSelection xterm-extra-capabilities)
(xterm--init-activate-set-selection)))
+ (when xterm-set-window-title
+ (xterm--init-frame-title))
;; Unconditionally enable bracketed paste mode: terminals that don't
;; support it just ignore the sequence.
(xterm--init-bracketed-paste-mode)
@@ -828,6 +835,31 @@ xterm--init-activate-set-selection
"Terminal initialization for `gui-set-selection'."
(set-terminal-parameter nil 'xterm--set-selection t))
+(defun xterm--init-frame-title ()
+ "Terminal initialization for `gui-set-selection'."
+ (xterm-set-window-title)
+ (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 'minibuffer-exit-hook 'xterm-set-window-title))
+
+(defvar xterm-window-title-flag nil
+ "Whether the a new frame has been created, calling for a title update.")
+
+(defun xterm-set-window-title-flag (_frame)
+ (setq xterm-window-title-flag t))
+
+(defun xterm-unset-window-title-flag ()
+ (when xterm-window-title-flag
+ (setq xterm-window-title-flag nil)
+ (xterm-set-window-title)))
+
+(defun xterm-set-window-title (&optional terminal)
+ "Set the window title of the Xterm with the current Emacs frame."
+ (send-string-to-terminal
+ (format "\e]2;%s\a" (format-mode-line frame-title-format))
+ terminal))
+
(defun xterm--selection-char (type)
(pcase type
('PRIMARY "p")
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#28340
; Package
emacs
.
(Wed, 20 Sep 2017 15:09:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 28340 <at> debbugs.gnu.org (full text, mbox):
> Date: Wed, 20 Sep 2017 08:23:51 -0400
> From: Mark Oteiza <mvoteiza <at> udel.edu>
> Cc: 28340 <at> debbugs.gnu.org
>
> > What about window-configuration-change-hook, does that help? You
> > could set some flag in after-make-frame-functions, and then test and
> > reset that flag in window-configuration-change-hook, when you see that
> > a buffer is switched in the frame. Would that work?
>
> This appears to work, thank you. Please see attached.
Thanks, this LGTM. It needs a NEWS entry about the new defcustom, and
then it can go in.
Reply sent
to
Mark Oteiza <mvoteiza <at> udel.edu>
:
You have taken responsibility.
(Wed, 20 Sep 2017 16:07:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Mark Oteiza <mvoteiza <at> udel.edu>
:
bug acknowledged by developer.
(Wed, 20 Sep 2017 16:07:03 GMT)
Full text and
rfc822 format available.
Message #25 received at 28340-done <at> debbugs.gnu.org (full text, mbox):
On 20/09/17 at 01:47pm, Eli Zaretskii wrote:
> > Date: Wed, 20 Sep 2017 08:23:51 -0400
> > From: Mark Oteiza <mvoteiza <at> udel.edu>
> > Cc: 28340 <at> debbugs.gnu.org
> >
> > > What about window-configuration-change-hook, does that help? You
> > > could set some flag in after-make-frame-functions, and then test and
> > > reset that flag in window-configuration-change-hook, when you see that
> > > a buffer is switched in the frame. Would that work?
> >
> > This appears to work, thank you. Please see attached.
>
> Thanks, this LGTM. It needs a NEWS entry about the new defcustom, and
> then it can go in.
Thanks. Done, pushed as 3a09343e
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 19 Oct 2017 11:24:05 GMT)
Full text and
rfc822 format available.
This bug report was last modified 7 years and 242 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.