]> git.eshelyaron.com Git - emacs.git/commitdiff
Support "replacement characters" on TTY frames
authorEli Zaretskii <eliz@gnu.org>
Sat, 27 Aug 2022 08:56:00 +0000 (11:56 +0300)
committerEli Zaretskii <eliz@gnu.org>
Sat, 27 Aug 2022 08:56:00 +0000 (11:56 +0300)
* src/nsterm.m (ns_draw_glyphless_glyph_string_foreground):
* src/pgtkterm.c (pgtk_draw_glyphless_glyph_string_foreground):
* src/haikuterm.c (haiku_draw_glyphless_glyph_string_foreground):
* src/xterm.c (x_draw_glyphless_glyph_string_foreground):
* src/w32term.c (w32_draw_glyphless_glyph_string_foreground):
* src/xdisp.c (lookup_glyphless_char_display): Handle extra-slot
of 'glyphless-char-display' that is a cons cell.
(syms_of_xdisp) <glyphless-char-display>: Update doc string.

* etc/NEWS:
* doc/lispref/display.texi (Glyphless Chars): Document the new
feature.

* lisp/faces.el (glyphless-char): Make the face stand out on TTY
frames that don't support the underline attribute.

doc/lispref/display.texi
etc/NEWS
lisp/faces.el
src/haikuterm.c
src/nsterm.m
src/pgtkterm.c
src/term.c
src/w32term.c
src/xdisp.c
src/xterm.c

index bb2b2d98a36a90c96237084383e962a1ee39581b..a56f467e0b573854d752e1bc9558aec420e4fd3d 100644 (file)
@@ -8542,7 +8542,11 @@ hexadecimal notation.
 
 @item an @acronym{ASCII} string
 Display a box containing that string.  The string should contain at
-most 6 @acronym{ASCII} characters.
+most 6 @acronym{ASCII} characters.  As an exception, if the string
+includes just one character, on text-mode terminals that character
+will be displayed without a box; this allows to handle such
+``acronyms'' as a replacement character for characters that cannot be
+displayed by the terminal.
 
 @item a cons cell @code{(@var{graphical} . @var{text})}
 Display with @var{graphical} on graphical displays, and with
index 9eeab7bb9a2d03c9a8b26bf0725047b5d4ded1d3..a2537235eba5e1156efd5dbc7cf0deda122620e1 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1512,7 +1512,7 @@ non-nil, the text will now be added to the Isearch instead.
 *** Changes for values 'no' and 'no-ding' of 'isearch-wrap-pause'.
 Now with these values the search will wrap around not only on repeating
 with 'C-s C-s', but also after typing a character.
-
+1
 +++
 *** New user option 'char-fold-override'.
 Non-nil means that the default definitions of equivalent characters
@@ -1525,11 +1525,24 @@ command accepts the Unicode name of an Emoji (for example, "smiling
 face" or "heart with arrow"), like 'C-x 8 e e', with minibuffer
 completion, and adds the Emoji into the search string.
 
+** Glyphless characters
+
 +++
-** New minor mode 'glyphless-display-mode'.
+*** New minor mode 'glyphless-display-mode'.
 This allows an easy way to toggle seeing all glyphless characters in
 the current buffer.
 
+*** The extra slot of 'glyphless-char-display' can now have cons values.
+The extra slot of the 'glyphless-char-display' char-table can now have
+values that are cons cells, specifying separate values for text-mode
+and GUI terminals.
+
+*** "Replacement character" feature for undisplayable characters on TTYs.
+The 'acronym' method of displaying glyphless characters on text-mode
+frames treats single-character acronyms specially: they are displayed
+without the surrounding [..] "box", thus in effect treating such
+"acronyms" as replacement characters.
+
 ** Registers
 
 +++
index 0246e038dd41821d81d74907e1718d58be95fde4..336078b0403568d27a143d8c146e50eef703a017 100644 (file)
@@ -2978,7 +2978,7 @@ bindings.  See also the face `tooltip'."
   :group 'help)
 
 (defface glyphless-char
-  '((((type tty)) :inherit underline)
+  '((((type tty)) :inherit escape-glyph :underline t)
     (((type pc)) :inherit escape-glyph)
     (t :height 0.6))
   "Face for displaying non-graphic characters (e.g. U+202A (LRE)).
index c2d4e34ba2514601e60ff5e52f095a5008ddd1f0..df1c39974f81dcb25d353ba65cb513436b3ebaad 100644 (file)
@@ -1252,6 +1252,8 @@ haiku_draw_glyphless_glyph_string_foreground (struct glyph_string *s)
                   ? CHAR_TABLE_REF (Vglyphless_char_display,
                                     glyph->u.glyphless.ch)
                   : XCHAR_TABLE (Vglyphless_char_display)->extras[0]);
+             if (CONSP (acronym))
+               acronym = XCAR (acronym);
              if (STRINGP (acronym))
                str = SSDATA (acronym);
            }
index e3f47eb905e7897ffc64ba7a1e2c899c5ff387b5..6c6151701b843335ab06ddf881f9638bfb89b811 100644 (file)
@@ -4241,6 +4241,8 @@ ns_draw_glyphless_glyph_string_foreground (struct glyph_string *s)
                   ? CHAR_TABLE_REF (Vglyphless_char_display,
                                     glyph->u.glyphless.ch)
                   : XCHAR_TABLE (Vglyphless_char_display)->extras[0]);
+             if (CONSP (acronym))
+               acronym = XCAR (acronym);
              if (STRINGP (acronym))
                str = SSDATA (acronym);
            }
index b283cef7cde22914c019ec321140324b30e0a480..491ba338821792851f86df7b75146a24118b2b17 100644 (file)
@@ -1584,6 +1584,8 @@ pgtk_draw_glyphless_glyph_string_foreground (struct glyph_string *s)
                   ? CHAR_TABLE_REF (Vglyphless_char_display,
                                     glyph->u.glyphless.ch)
                   : XCHAR_TABLE (Vglyphless_char_display)->extras[0]);
+             if (CONSP (acronym))
+               acronym = XCAR (acronym);
              if (STRINGP (acronym))
                str = SSDATA (acronym);
            }
index 3bea621dbda584fbcabccd613b3b7943de2223bb..2e43d89232f9bf10118424a74035e32f59465c29 100644 (file)
@@ -1862,12 +1862,24 @@ produce_glyphless_glyph (struct it *it, Lisp_Object acronym)
            acronym = CHAR_TABLE_REF (Vglyphless_char_display, it->c);
          if (CONSP (acronym))
            acronym = XCDR (acronym);
-         buf[0] = '[';
          str = STRINGP (acronym) ? SSDATA (acronym) : "";
-         for (len = 0; len < 6 && str[len] && ASCII_CHAR_P (str[len]); len++)
-           buf[1 + len] = str[len];
-         buf[1 + len] = ']';
-         len += 2;
+         /* A special kludgey feature for single-character acronyms:
+            don't put them in a box, effectively treating them as a
+            replacement character.  */
+         if (STRINGP (acronym) && SCHARS (acronym) == 1)
+           {
+             buf[0] = str[0];
+             len = 1;
+           }
+         else
+           {
+             buf[0] = '[';
+             for (len = 0;
+                  len < 6 && str[len] && ASCII_CHAR_P (str[len]); len++)
+               buf[1 + len] = str[len];
+             buf[1 + len] = ']';
+             len += 2;
+           }
        }
       else
        {
index d0577efccc1748fb13cb1c691fc58717b0abe54e..dff21489e5b32dc663593bcef441c8671888e51f 100644 (file)
@@ -1490,6 +1490,8 @@ w32_draw_glyphless_glyph_string_foreground (struct glyph_string *s)
                   ? CHAR_TABLE_REF (Vglyphless_char_display,
                                     glyph->u.glyphless.ch)
                   : XCHAR_TABLE (Vglyphless_char_display)->extras[0]);
+             if (CONSP (acronym))
+               acronym = XCAR (acronym);
              if (STRINGP (acronym))
                str = SSDATA (acronym);
            }
index 86a119c0f63a7db5e0a4e428b36d7a1560755997..70f6936dd0babddacc4efc5db51a6fc3c1b68569 100644 (file)
@@ -7842,15 +7842,14 @@ lookup_glyphless_char_display (int c, struct it *it)
       && CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (Vglyphless_char_display)) >= 1)
     {
       if (c >= 0)
-       {
-         glyphless_method = CHAR_TABLE_REF (Vglyphless_char_display, c);
-      if (CONSP (glyphless_method))
-       glyphless_method = FRAME_WINDOW_P (it->f)
-             ? XCAR (glyphless_method)
-             : XCDR (glyphless_method);
-       }
+       glyphless_method = CHAR_TABLE_REF (Vglyphless_char_display, c);
       else
        glyphless_method = XCHAR_TABLE (Vglyphless_char_display)->extras[0];
+
+      if (CONSP (glyphless_method))
+       glyphless_method = FRAME_WINDOW_P (it->f)
+         ? XCAR (glyphless_method)
+         : XCDR (glyphless_method);
     }
 
  retry:
@@ -37117,7 +37116,9 @@ GRAPHICAL and TEXT should each have one of the values listed above.
 The char-table has one extra slot to control the display of a character for
 which no font is found.  This slot only takes effect on graphical terminals.
 Its value should be an ASCII acronym string, `hex-code', `empty-box', or
-`thin-space'.  The default is `empty-box'.
+`thin-space'.  It could also be a cons cell of any two of these, to specify
+separate values for graphical and text terminals.
+The default is `empty-box'.
 
 If a character has a non-nil entry in an active display table, the
 display table takes effect; in this case, Emacs does not consult
index c716d07adaf5c635a97a1e24cb99c7538807f6dd..e7f5525502107912cd85ef8113e6f7544620ece2 100644 (file)
@@ -8316,6 +8316,8 @@ x_draw_glyphless_glyph_string_foreground (struct glyph_string *s)
                   ? CHAR_TABLE_REF (Vglyphless_char_display,
                                     glyph->u.glyphless.ch)
                   : XCHAR_TABLE (Vglyphless_char_display)->extras[0]);
+             if (CONSP (acronym))
+               acronym = XCAR (acronym);
              if (STRINGP (acronym))
                str = SSDATA (acronym);
            }