Disable auto compositions on the Linux console only

* lisp/term/linux.el (terminal-init-linux): Disable auto
compositions on "linux" consoles (bug#21363).

* src/composite.c (inhibit_auto_composition): New function to
implement this.
(composition_compute_stop_pos, composition_adjust_point)
(Ffind_composition_internal): Use it.
(syms_of_composite): Document it.

* src/lisp.h: Export tty_type_name.

* src/term.c (tty_type_name): Factored out.
(Ftty_type): Use it.
This commit is contained in:
Lars Ingebrigtsen 2021-08-18 16:24:40 +02:00
parent 3a1d713c19
commit 15a8026caf
4 changed files with 36 additions and 8 deletions

View file

@ -13,7 +13,7 @@
(tty-no-underline)
;; Compositions confuse cursor movement.
(global-auto-composition-mode -1)
(setq-default auto-composition-mode "linux")
(ignore-errors (when gpm-mouse-mode (require 't-mouse) (gpm-mouse-enable)))

View file

@ -961,6 +961,23 @@ char_composable_p (int c)
&& (XFIXNUM (val) <= UNICODE_CATEGORY_Zs))))));
}
static inline bool
inhibit_auto_composition (void)
{
if (NILP (Vauto_composition_mode))
return true;
if (STRINGP (Vauto_composition_mode))
{
char *name = tty_type_name (Qnil);
if (name && ! strcmp (SSDATA (Vauto_composition_mode), name))
return true;
}
return false;
}
/* Update cmp_it->stop_pos to the next position after CHARPOS (and
BYTEPOS) where character composition may happen. If BYTEPOS is
negative, compute it. ENDPOS is a limit of searching. If it is
@ -1015,7 +1032,7 @@ composition_compute_stop_pos (struct composition_it *cmp_it, ptrdiff_t charpos,
cmp_it->ch = -1;
}
if (NILP (BVAR (current_buffer, enable_multibyte_characters))
|| NILP (Vauto_composition_mode))
|| inhibit_auto_composition ())
return;
if (bytepos < 0)
{
@ -1741,7 +1758,7 @@ composition_adjust_point (ptrdiff_t last_pt, ptrdiff_t new_pt)
}
if (NILP (BVAR (current_buffer, enable_multibyte_characters))
|| NILP (Vauto_composition_mode))
|| inhibit_auto_composition ())
return new_pt;
/* Next check the automatic composition. */
@ -1941,7 +1958,7 @@ See `find-composition' for more details. */)
if (!find_composition (from, to, &start, &end, &prop, string))
{
if (!NILP (BVAR (current_buffer, enable_multibyte_characters))
&& ! NILP (Vauto_composition_mode)
&& ! inhibit_auto_composition ()
&& find_automatic_composition (from, to, (ptrdiff_t) -1,
&start, &end, &gstring, string))
return list3 (make_fixnum (start), make_fixnum (end), gstring);
@ -2040,7 +2057,10 @@ The default value is the function `compose-chars-after'. */);
DEFVAR_LISP ("auto-composition-mode", Vauto_composition_mode,
doc: /* Non-nil if Auto-Composition mode is enabled.
Use the command `auto-composition-mode' to change this variable. */);
Use the command `auto-composition-mode' to change this variable.
If this variable is a string, `auto-composition-mode' will be disabled
in buffers that have a terminal type that equals this string.*/);
Vauto_composition_mode = Qt;
DEFVAR_LISP ("auto-composition-function", Vauto_composition_function,

View file

@ -4652,6 +4652,7 @@ extern AVOID fatal (const char *msgid, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2);
/* Defined in terminal.c. */
extern void syms_of_terminal (void);
extern char * tty_type_name (Lisp_Object);
/* Defined in font.c. */
extern void syms_of_font (void);

View file

@ -2169,6 +2169,14 @@ set_tty_color_mode (struct tty_display_info *tty, struct frame *f)
#endif /* !DOS_NT */
char *
tty_type_name (Lisp_Object terminal)
{
struct terminal *t = decode_tty_terminal (terminal);
return t? t->display_info.tty->type: NULL;
}
DEFUN ("tty-type", Ftty_type, Stty_type, 0, 1, 0,
doc: /* Return the type of the tty device that TERMINAL uses.
Returns nil if TERMINAL is not on a tty device.
@ -2177,10 +2185,9 @@ TERMINAL can be a terminal object, a frame, or nil (meaning the
selected frame's terminal). */)
(Lisp_Object terminal)
{
struct terminal *t = decode_tty_terminal (terminal);
char *name = tty_type_name (terminal);
return (t && t->display_info.tty->type
? build_string (t->display_info.tty->type) : Qnil);
return (name? build_string (name) : Qnil);
}
DEFUN ("controlling-tty-p", Fcontrolling_tty_p, Scontrolling_tty_p, 0, 1, 0,