diff --git a/etc/NEWS b/etc/NEWS index a5806a99e31..e764545c508 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -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 diff --git a/src/cm.c b/src/cm.c index 4693b69c26e..f453fc2650a 100644 --- a/src/cm.c +++ b/src/cm.c @@ -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! */ /* diff --git a/src/term.c b/src/term.c index 1a5ed74d698..8777a3b6a65 100644 --- a/src/term.c +++ b/src/term.c @@ -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);