mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
Teach Emacs to set XTerm window titles
* lisp/term/xterm.el (terminal-init-xterm): Add initialization. (xterm--init-frame-title, xterm-set-window-title-flag): (xterm-unset-window-title-flag, xterm-set-window-title): New functions. (xterm-window-title-flag): New variable. (xterm-set-window-title): New custom variable. * etc/NEWS: Mention it.
This commit is contained in:
parent
b1f83c10df
commit
3a09343eab
2 changed files with 40 additions and 0 deletions
5
etc/NEWS
5
etc/NEWS
|
|
@ -37,6 +37,11 @@ When you add a new item, use the appropriate mark if you are sure it applies,
|
|||
|
||||
* Changes in Specialized Modes and Packages in Emacs 27.1
|
||||
|
||||
** Enhanced xterm support
|
||||
|
||||
*** New variable 'xterm-set-window-title' controls whether Emacs
|
||||
sets the XTerm window title. The default is to set the window title.
|
||||
|
||||
|
||||
* New Modes and Packages in Emacs 27.1
|
||||
|
||||
|
|
|
|||
|
|
@ -68,6 +68,11 @@ string bytes that can be copied is 3/4 of this value."
|
|||
: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 @@ We run the first FUNCTION whose STRING matches the input events."
|
|||
(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,34 @@ We run the first FUNCTION whose STRING matches the input events."
|
|||
"Terminal initialization for `gui-set-selection'."
|
||||
(set-terminal-parameter nil 'xterm--set-selection t))
|
||||
|
||||
(defun xterm--init-frame-title ()
|
||||
"Terminal initialization for XTerm frame titles."
|
||||
(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 a new frame has been created, calling for a title update.")
|
||||
|
||||
(defun xterm-set-window-title-flag (_frame)
|
||||
"Set `xterm-window-title-flag'.
|
||||
See `xterm--init-frame-title'"
|
||||
(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 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))
|
||||
|
||||
(defun xterm--selection-char (type)
|
||||
(pcase type
|
||||
('PRIMARY "p")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue