GNU bug report logs -
#80091
[PATCH] Update cursor display using Xterm escape sequences
Previous Next
To reply to this bug, email your comments to 80091 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org:
bug#80091; Package
emacs.
(Mon, 29 Dec 2025 03:15:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Jared Finder <jared <at> finder.org>:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org.
(Mon, 29 Dec 2025 03:15:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
This patch adds a user option to xterm.el, xterm-set-cursor-type, which
enables sending xterm escape sequences to update the way the cursor is
displayed. Many modern terminals support escape sequences to switch the
cursor between a filled box, a vertical bar, and a horizontal bar.
I put this behind a user option because instead of capability checking
because the patch achieves this using post-command-hook.
-- MJF
[0001-Update-cursor-display-using-Xterm-escape-sequences.patch (text/x-diff, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org:
bug#80091; Package
emacs.
(Mon, 29 Dec 2025 11:44:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 80091 <at> debbugs.gnu.org (full text, mbox):
Hello,
On Sun 28 Dec 2025 at 07:14pm -08, Jared Finder wrote:
> This patch adds a user option to xterm.el, xterm-set-cursor-type, which
> enables sending xterm escape sequences to update the way the cursor is
> displayed. Many modern terminals support escape sequences to switch the
> cursor between a filled box, a vertical bar, and a horizontal bar.
>
> I put this behind a user option because instead of capability checking because
> the patch achieves this using post-command-hook.
Thanks. This needs documenting in NEWS and possibly also the manual.
Can you recommend a terminal that supports this on GNU/Linux so I can
test the patch?
--
Sean Whitton
Information forwarded
to
bug-gnu-emacs <at> gnu.org:
bug#80091; Package
emacs.
(Mon, 29 Dec 2025 17:38:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 80091 <at> debbugs.gnu.org (full text, mbox):
On 2025-12-29 03:43, Sean Whitton wrote:
> Hello,
>
> On Sun 28 Dec 2025 at 07:14pm -08, Jared Finder wrote:
>
>> This patch adds a user option to xterm.el, xterm-set-cursor-type,
>> which
>> enables sending xterm escape sequences to update the way the cursor is
>> displayed. Many modern terminals support escape sequences to switch
>> the
>> cursor between a filled box, a vertical bar, and a horizontal bar.
>>
>> I put this behind a user option because instead of capability checking
>> because
>> the patch achieves this using post-command-hook.
>
> Thanks. This needs documenting in NEWS and possibly also the manual.
Updated patch attached.
> Can you recommend a terminal that supports this on GNU/Linux so I can
> test the patch?
Try any of the following terminals:
Installable on Debian:
* xfce4-terminal 1.1.4
* gnome-terminal 3.56.2, VTE 0.80.1
* konsole 25.04.2
Terminals on other OSes work too:
* Windows Terminal (on Windows)
* iTerm2 (on MacOS)
As an aside, all of these terminals except Konsole also appear to
support altering the cursor's color as well. I've renamed the user
option to 'xterm-update-cursor' to allow it to also control the cursor
color, which I will do in a future patch.
-- MJF
Information forwarded
to
bug-gnu-emacs <at> gnu.org:
bug#80091; Package
emacs.
(Mon, 29 Dec 2025 17:38:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 80091 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
This time with the patch actually attached.
On 2025-12-29 09:37, Jared Finder wrote:
> On 2025-12-29 03:43, Sean Whitton wrote:
>> Hello,
>>
>> On Sun 28 Dec 2025 at 07:14pm -08, Jared Finder wrote:
>>
>>> This patch adds a user option to xterm.el, xterm-set-cursor-type,
>>> which
>>> enables sending xterm escape sequences to update the way the cursor
>>> is
>>> displayed. Many modern terminals support escape sequences to switch
>>> the
>>> cursor between a filled box, a vertical bar, and a horizontal bar.
>>>
>>> I put this behind a user option because instead of capability
>>> checking because
>>> the patch achieves this using post-command-hook.
>>
>> Thanks. This needs documenting in NEWS and possibly also the manual.
>
> Updated patch attached.
>
>> Can you recommend a terminal that supports this on GNU/Linux so I can
>> test the patch?
>
> Try any of the following terminals:
>
> Installable on Debian:
> * xfce4-terminal 1.1.4
> * gnome-terminal 3.56.2, VTE 0.80.1
> * konsole 25.04.2
>
> Terminals on other OSes work too:
> * Windows Terminal (on Windows)
> * iTerm2 (on MacOS)
>
> As an aside, all of these terminals except Konsole also appear to
> support altering the cursor's color as well. I've renamed the user
> option to 'xterm-update-cursor' to allow it to also control the cursor
> color, which I will do in a future patch.
>
> -- MJF
[0001-Update-cursor-display-using-Xterm-escape-sequences.patch (text/x-diff, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org:
bug#80091; Package
emacs.
(Tue, 30 Dec 2025 13:58:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 80091 <at> debbugs.gnu.org (full text, mbox):
Hello,
Jared Finder [29/Dec 9:37am -08] wrote:
>> Try any of the following terminals:
>> Installable on Debian:
>> * xfce4-terminal 1.1.4
>> * gnome-terminal 3.56.2, VTE 0.80.1
>> * konsole 25.04.2
Thanks, I'll try it.
> diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi
> index dd898e0cf88..f9665a59843 100644
> --- a/doc/emacs/display.texi
> +++ b/doc/emacs/display.texi
> @@ -2040,12 +2040,14 @@ Cursor Display
>
> @vindex visible-cursor
> On a text terminal, the cursor's appearance is controlled by the
> -terminal, largely out of the control of Emacs. Some terminals offer
> -two different cursors: a visible static cursor, and a very
> -visible blinking cursor. By default, Emacs uses the very visible
> -cursor, and switches to it when you start or resume Emacs. If the
> -variable @code{visible-cursor} is @code{nil} when Emacs starts or
> -resumes, it uses the normal cursor.
> +terminal, largely out of the control of Emacs. Some terminals offer two
> +different cursors: a visible static cursor, and a very visible blinking
> +cursor. By default, Emacs uses the very visible cursor, and switches to
> +it when you start or resume Emacs. If the variable @code{visible-cursor}
> +is @code{nil} when Emacs starts or resumes, it uses the normal cursor. On
> +many Xterm compatible terminals, the cursor's type can be changed by Emacs
> +as well. If the user option @code{xterm-set-cursor-type} is set, Emacs
> +updates the cursor's type similar to how it does so on graphical displays.
>
> @vindex cursor-type
> On a graphical display, many more properties of the text cursor can
Here you're introducing a forward-reference because the notion of a
cursor type is introduced right below. Forward-references like that are
generally bad. So I think your new text needs to be further down,
perhaps in its own paragraph.
Also, in all the docs, it should be "Xterm-compatible" not "Xterm
compatible".
> ++++
> +** New user option 'xterm-update-cursor' to update cursor display on TTYs.
> +When enabled, Emacs send Xterm escape sequences on Xterm compatible TTYs
> +to update the cursor's appearance based on 'cursor-type', similar to how
> +the cursor appears on graphical displays. See the Info node "(emacs) Cursor
> +Display" for more information.
It might be worth mentioning here something like "For example if you
usually use a bar cursor on graphical displays then Emacs will use a bar
cursor in compatible text frames, too." because "cursor type" might not
be meaningful on its own to someone not familiar with the feature.
> +
>
> * Editing Changes in Emacs 31.1
>
> diff --git a/lisp/term/xterm.el b/lisp/term/xterm.el
> index e7469263036..1cb3495063c 100644
> --- a/lisp/term/xterm.el
> +++ b/lisp/term/xterm.el
> @@ -80,6 +80,11 @@ xterm-store-paste-on-kill-ring
> :version "28.1"
> :type 'boolean)
>
> +(defcustom xterm-update-cursor nil
> + "If non-nil, update the cursor to match `cursor-type'."
Maybe "... try to update the text terminal cursor to match ...".
> +
> +Cursor type symbols are the same as for `cursor-type'.")
> +
> +(defun xterm--set-cursor-type (terminal type)
> + (let ((type-int (or (plist-get xterm--cursor-type-to-int type) 1))
> + (old (terminal-parameter terminal 'xterm--cursor-style)))
> +
> + (when old
> + (set-terminal-parameter terminal 'tty-mode-set-strings
> + (delete (format "\e[%d q" old)
> + (terminal-parameter terminal 'tty-mode-set-strings))))
Please rearrange to avoid this long line.
--
Sean Whitton
Information forwarded
to
bug-gnu-emacs <at> gnu.org:
bug#80091; Package
emacs.
(Tue, 30 Dec 2025 14:09:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 80091 <at> debbugs.gnu.org (full text, mbox):
Hello again,
Jared Finder [29/Dec 9:37am -08] wrote:
> ;; We likewise unconditionally enable support for focus tracking.
> (xterm--init-focus-tracking))
>
> +(defun xterm--post-command-hook ()
> + "Hook for xterm features that need to be frequently updated."
> +
> + (unless (display-graphic-p)
> + (when xterm-set-window-title
> + (xterm-set-window-title))
> + (when xterm-update-cursor
> + (xterm--update-cursor-type))))
> +
> (defun terminal-init-xterm ()
> "Terminal initialization function for xterm."
> (unwind-protect
> @@ -1052,7 +1068,7 @@ xterm--init-frame-title
> (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 'post-command-hook 'xterm--post-command-hook)
> (add-hook 'minibuffer-exit-hook 'xterm-set-window-title))
This changes the logic in that previously xterm-set-window-title was
unconditionally added to post-command-hook but now it's guarded by both
(display-graphic-p) and xterm-set-window-title.
Are you sure that is okay to do?
--
Sean Whitton
Information forwarded
to
bug-gnu-emacs <at> gnu.org:
bug#80091; Package
emacs.
(Tue, 30 Dec 2025 19:49:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 80091 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 2025-12-30 06:07, Sean Whitton wrote:
> Hello,
>
> Jared Finder [29/Dec 9:37am -08] wrote:
>>> Try any of the following terminals:
>>> Installable on Debian:
>>> * xfce4-terminal 1.1.4
>>> * gnome-terminal 3.56.2, VTE 0.80.1
>>> * konsole 25.04.2
>
> Thanks, I'll try it.
New patch attached for prior feedback. It also was easy to add support
for updating the cursor color so I added that to the patch. All the
terminals I tested also support updating the cursor color except Konsole
which does not support OSC 12 at all.
> Jared Finder [29/Dec 9:37am -08] wrote:
>> ;; We likewise unconditionally enable support for focus tracking.
>> (xterm--init-focus-tracking))
>>
>> +(defun xterm--post-command-hook ()
>> + "Hook for xterm features that need to be frequently updated."
>> +
>> + (unless (display-graphic-p)
>> + (when xterm-set-window-title
>> + (xterm-set-window-title))
>> + (when xterm-update-cursor
>> + (xterm--update-cursor-type))))
>> +
>> (defun terminal-init-xterm ()
>> "Terminal initialization function for xterm."
>> (unwind-protect
>> @@ -1052,7 +1068,7 @@ xterm--init-frame-title
>> (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 'post-command-hook 'xterm--post-command-hook)
>> (add-hook 'minibuffer-exit-hook 'xterm-set-window-title))
>
> This changes the logic in that previously xterm-set-window-title was
> unconditionally added to post-command-hook but now it's guarded by both
> (display-graphic-p) and xterm-set-window-title.
> Are you sure that is okay to do?
I'm not sure I follow. I don't see the behavior change pointed out
here.
Prior to my patch, the function xterm-set-window-title was only added to
post-command-hook if xterm--init-frame-title was called, which only
happened if the user option xterm-set-window-title is enabled while
xterm--init is run. The behavior with my patch is the same, only
xterm--post-command-hook is added instead.
Maybe you're referring to running xterm-set-window-title as part of
post-command-hook? This is also unchanged. Prior to my patch
xterm-set-window-title internally guarded itself with display-graphic-p.
-- MJF
[0001-Update-cursor-display-using-Xterm-escape-sequences.patch (text/x-diff, attachment)]
This bug report was last modified today.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.