emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 15a8026: Disable auto compositions on the Linux console only


From: Lars Ingebrigtsen
Subject: master 15a8026: Disable auto compositions on the Linux console only
Date: Wed, 18 Aug 2021 10:25:07 -0400 (EDT)

branch: master
commit 15a8026cafad4a61a2ba5554c1a3e999244e412c
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    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.
---
 lisp/term/linux.el |  2 +-
 src/composite.c    | 28 ++++++++++++++++++++++++----
 src/lisp.h         |  1 +
 src/term.c         | 13 ++++++++++---
 4 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/lisp/term/linux.el b/lisp/term/linux.el
index bc61a3a..6d43e47 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 129e9d6..2bde147 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 1206a0d..7bfc69b 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 c995a44..6651b96 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,



reply via email to

[Prev in Thread] Current Thread [Next in Thread]