Backward compatibility option for 'nobreak-char-display'

* src/xdisp.c (syms_of_xdisp) <nobreak-char-ascii-display>: New
variable.
(get_next_display_element): If 'nobreak-char-ascii-display' is
non-nil, display non-ASCII space and hyphen characters as their
ASCII equivalents.  (Bug#50983)

* etc/NEWS:
* etc/PROBLEMS: Mention 'nobreak-char-ascii-display'.
This commit is contained in:
Eli Zaretskii 2021-10-05 17:12:49 +03:00
parent ea1b728a06
commit b5afbedc90
3 changed files with 46 additions and 3 deletions

View file

@ -828,7 +828,24 @@ buffers. This can be controlled by customizing the user option
*** 'nobreak-char-display' now also affects all non-ASCII space characters.
Previously, this was limited only to 'NO-BREAK SPACE' and hyphen
characters. Now it also covers the rest of the non-ASCII Unicode
space characters.
space characters. Also, unlike in previous versions of Emacs, the
non-ASCII characters are displayed as themselves when
'nobreak-char-display' is t, i.e. they are not replaced on display
with the ASCII space and hyphen characters.
---
*** New backward compatibility variable 'nobreak-char-ascii-display'.
This variable is nil by default, and non-ASCII space and hyphen
characters are displayed as themselves, even if 'nobreak-char-display'
is non-nil. If 'nobreak-char-ascii-display' is set to a non-nil
value, the non-ASCII space and hyphen characters are instead displayed
as their ASCII counterparts: spaces and ASCII hyphen (a.k.a. "dash")
characters. This provides backward compatibility feature for the
change described above, where the non-ASCII characters are no longer
replaced with their ASCII counterparts when 'nobreak-char-display' is
t. You may need this on text-mode terminals that produce messed up
display when non-ASCII spaces and hyphens are written to the display.
(This variable is only effective when 'nobreak-char-display' is t.)
+++
*** Improved support for terminal emulators that encode the Meta flag.

View file

@ -1995,6 +1995,10 @@ a regular ASCII dash character '-':
(aset standard-display-table
#xAD (vector (make-glyph-code ?- 'escape-glyph)))
Another workaround is to set 'nobreak-char-ascii-display' to a non-nil
value, which will cause any non-ASCII space and hyphen characters to
be displayed as their ASCII counterparts, with a special face.
Kitty also differs from many other character terminals in how it
handles character compositions. As one example, Emoji sequences that
begin with a non-Emoji character and end in U+FE0F VARIATION SELECTOR

View file

@ -7668,7 +7668,8 @@ get_next_display_element (struct it *it)
/* Merge `nobreak-space' into the current face. */
face_id = merge_faces (it->w, Qnobreak_space, 0,
it->face_id);
XSETINT (it->ctl_chars[0], it->c);
XSETINT (it->ctl_chars[0],
nobreak_char_ascii_display ? ' ' : it->c);
ctl_len = 1;
goto display_control;
}
@ -7681,7 +7682,8 @@ get_next_display_element (struct it *it)
/* Merge `nobreak-space' into the current face. */
face_id = merge_faces (it->w, Qnobreak_hyphen, 0,
it->face_id);
XSETINT (it->ctl_chars[0], it->c);
XSETINT (it->ctl_chars[0],
nobreak_char_ascii_display ? '-' : it->c);
ctl_len = 1;
goto display_control;
}
@ -35034,6 +35036,26 @@ glyph followed by an ordinary space or hyphen.
A value of nil means no special handling of these characters. */);
Vnobreak_char_display = Qt;
DEFVAR_BOOL ("nobreak-char-ascii-display", nobreak_char_ascii_display,
doc: /* Control display of non-ASCII space and hyphen chars.
If the value of this variable is nil, the default, Emacs displays
non-ASCII chars which have the same appearance as an ASCII space
or hyphen as themselves, with the `nobreak-space' or `nobreak-hyphen'
face, respectively.
If the value is t, these characters are displayed as their ASCII
counterparts: whitespace characters as ASCII space, hyphen characters
as ASCII hyphen (a.k.a. \"dash\"), using the `nobreak-space' or
the `nobreak-hyphen' face.
This variable has effect only if `nobreak-char-display' is t;
otherwise it is ignored.
All of the non-ASCII characters in the Unicode horizontal whitespace
character class, as well as U+00AD (soft hyphen), U+2010 (hyphen), and
U+2011 (non-breaking hyphen) are affected. */);
nobreak_char_ascii_display = false;
DEFVAR_LISP ("void-text-area-pointer", Vvoid_text_area_pointer,
doc: /* The pointer shape to show in void text areas.
A value of nil means to show the text pointer. Other options are