Subject: bug#49932: 28.0.50; Error in GUI frames when xterm-set-window-title is set

From: Lars Ingebrigtsen <[email-masked]>
Date: Mon, 09 Aug 2021 15:43:37 +0200

Knut Anders Hatlen <[email-masked]> writes:

> 5. Start a new GUI frame with 'emacsclient -c', and again observe that
>    "Device 1 is not a termcap terminal device" is reported.
>
> I believe xterm-set-window-title should not affect GUI frames.

The problem seems to be:

(defun xterm-set-window-title (&optional terminal)
  "Set the window title of the Xterm TERMINAL.
The title is constructed from `frame-title-format'."
  (send-string-to-terminal
   (format "\e]2;%s\a" (format-mode-line frame-title-format))
   terminal))

Debugger entered: nil
  xterm-set-window-title()
  xterm--init-frame-title()
  xterm--init()
  terminal-init-xterm()
  tty-run-terminal-initialization(#<frame F11 0x5631310b99f0> nil t)
  tty-create-frame-with-faces(((client . #<process server <15>>) (environment "_=./$
  #f(compiled-function (params) #<bytecode -0x1d5fbf53102d34d1>)(((client . #<proce$
  apply(#f(compiled-function (params) #<bytecode -0x1d5fbf53102d34d1>) ((client . #$
  frame-creation-function(((client . #<process server <15>>) (environment "_=./li

That is, it's not specifying what terminal to set the title in -- so
it's set in all terminals, no matter what, all the time?  That is:

  (add-hook 'post-command-hook 'xterm-set-window-title)
  (add-hook 'minibuffer-exit-hook 'xterm-set-window-title))

Which just seems less than optimal in many ways -- running this from
post-command-hook seems pretty excessive?  But...

Anyway, I've now just made the function not do anything on graphical
displays, which should make the problem go away, but perhaps this should
be implemented a different way?

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