summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2021-08-18 16:24:40 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2021-08-18 16:24:40 +0200
commit15a8026cafad4a61a2ba5554c1a3e999244e412c (patch)
tree81cabc61397a1f71786b46e4dd10c5247efbedbf
parent3a1d713c19147a0eeb4829a8d3815e3292cbf1f3 (diff)
downloademacs-15a8026cafad4a61a2ba5554c1a3e999244e412c.tar.gz
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.
-rw-r--r--lisp/term/linux.el2
-rw-r--r--src/composite.c28
-rw-r--r--src/lisp.h1
-rw-r--r--src/term.c13
4 files changed, 36 insertions, 8 deletions
diff --git a/lisp/term/linux.el b/lisp/term/linux.el
index bc61a3a7cc3..6d43e477ac9 100644
--- a/lisp/term/linux.el
+++ b/lisp/term/linux.el
@@ -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)))
diff --git a/src/composite.c b/src/composite.c
index 129e9d6bb25..2bde14776f3 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -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,
diff --git a/src/lisp.h b/src/lisp.h
index 1206a0d1f6c..7bfc69b647b 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -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);
diff --git a/src/term.c b/src/term.c
index c995a4499cf..6651b967927 100644
--- a/src/term.c
+++ b/src/term.c
@@ -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,