Allow optionally disabling the use of TABs for TTY cursor movement

* src/term.c (syms_of_term) <tty-cursor-movement-use-TAB>: New var.
<tty-cursor-movement-use-TAB-BS>: Doc fix.
* src/cm.c (calccost): Use it to disable use of TABs for cursor
motion on text terminals.

* etc/NEWS: Announce the new variable.
This commit is contained in:
Eli Zaretskii 2026-05-31 11:36:15 +03:00
parent 3a0bce8f02
commit 64f4ce7b2d
3 changed files with 26 additions and 2 deletions

View file

@ -37,6 +37,18 @@ exit status to 256 if sending input to that process returned EPIPE.
Now when this happens, Emacs closes the file descriptor to write to the
child process, but allows it to continue execution as normal.
---
** New variable 'tty-cursor-movement-use-TAB'.
If this is set to the nil value, Emacs will not use TABs to optimize
cursor motion on text-mode terminals. This is for the rare cases where
the hardware tabs of the terminal were set to a non-default value by the
'tabs' command or similar, or if using TABs for cursor movement has any
other undesired effects. The default is t, which preserves past
behavior.
If this variable is nil, 'tty-cursor-movement-use-TAB-BS' has no effect,
and Emacs will never use TABs for any cursor-movement sequences.
* Editing Changes in Emacs 32.1

View file

@ -225,7 +225,8 @@ calccost (struct tty_display_info *tty,
goto dodelta; /* skip all the tab junk */
}
/* Tabs (the toughie) */
if (tty->Wcm->cc_tab >= BIG || !tty->Wcm->cm_usetabs)
if (!tty_cursor_movement_use_TAB
|| tty->Wcm->cc_tab >= BIG || !tty->Wcm->cm_usetabs)
goto olddelta; /* forget it! */
/*

View file

@ -5263,9 +5263,20 @@ On TTY frames, as a display optimization, Emacs may move to a position
by "overshooting" with TAB characters and one BACKSPACE character, when
this is more efficient. This combination can interfere with the
functioning of some software, such as screen readers. Set this to
non-nil to enable this optimization. */);
non-nil to enable this optimization.
If `tty-cursor-movement-use-TAB' is nil, this variable has no effect,
as Emacs will never use TABs for cursor movement. */);
tty_cursor_movement_use_TAB_BS = 0;
DEFVAR_BOOL ("tty-cursor-movement-use-TAB", tty_cursor_movement_use_TAB,
doc: /* Whether TTY frames may use TAB for cursor motion.
On TTY frames, as a display optimization, Emacs may move cursor to a
position with TAB characters, when this is more efficient. This might
produce wrong results if the hardware tabs of the terminal were set to
be of different width than Emacs expects. Set this to nil to disable
using TABs for cursor motion. */);
tty_cursor_movement_use_TAB = 1;
defsubr (&Stty_display_color_p);
defsubr (&Stty_display_color_cells);
defsubr (&Stty_no_underline);