* src/character.c (syms_of_character) <printable-chars>: Doc fix.
* lisp/international/characters.el (printable-chars): Fix values
for non-ASCII characters.
* doc/lispref/nonascii.texi (Character Properties): Add
cross-reference for what is a printable character.
* doc/lispref/display.texi (Usual Display):
* doc/lispref/searching.texi (Char Classes): Add indexing.
(Bug#76611)
(cherry picked from commit
68a37760dec83a8126b03bcacc60a96644a6831f)
ends the preceding line and starts a new line.
@cindex ASCII control characters
+@cindex non-printable ASCII characters
@item
The non-printable @dfn{@acronym{ASCII} control characters}---character
codes 0 through 31, as well as the @key{DEL} character (character code
The value of this variable is a char-table that specifies, for each
character, whether it is printable or not. That is, if evaluating
@code{(aref printable-chars char)} results in @code{t}, the character
-is printable, and if it results in @code{nil}, it is not.
+is printable, and if it results in @code{nil}, it is not. The
+definition of what is a printable character is the same as for the
+@samp{[:print:]} character class in regular expressions, @pxref{Char
+Classes}.
@end defvar
@node Character Sets
@item [:digit:]
This matches @samp{0} through @samp{9}. Thus, @samp{[-+[:digit:]]}
matches any digit, as well as @samp{+} and @samp{-}.
+@cindex graphic characters
@item [:graph:]
This matches graphic characters---everything except spaces,
@acronym{ASCII} and non-@acronym{ASCII} control characters,
This matches any multibyte character (@pxref{Text Representations}).
@item [:nonascii:]
This matches any non-@acronym{ASCII} character.
+@cindex printable characters
@item [:print:]
This matches any printing character---either spaces or graphic
characters matched by @samp{[:graph:]}.
(lambda (range _ignore) (set-char-table-range char-width-table range 2))
'arabic-2-column)
+\f
+;;; Setting printable-chars. The default is nil for control characters,
+;;; otherwise t.
+;;; The table is initialized in character.c with a crude approximation,
+;;; which considers any non-ASCII character above U+009F to be printable.
+;;; Note: this should be consistent with [:print:] character class,
+;;; see character.c:printablep.
+(let ((table (unicode-property-table-internal 'general-category)))
+ (when table
+ (map-char-table (lambda (key val)
+ ;; Cs: Surrogates
+ ;; Cn: Unassigned
+ (when (memq val '(Cs Cn))
+ (set-char-table-range printable-chars key nil)))
+ table)))
+
;; Internal use only.
;; Alist of locale symbol vs charsets. In a language environment
;; corresponding to the locale, width of characters in the charsets is
DEFVAR_LISP ("auto-fill-chars", Vauto_fill_chars,
doc: /*
A char-table for characters which invoke auto-filling.
-Such characters have value t in this table. */);
+Such characters have the value t in this table. */);
Vauto_fill_chars = Fmake_char_table (Qauto_fill_chars, Qnil);
CHAR_TABLE_SET (Vauto_fill_chars, ' ', Qt);
CHAR_TABLE_SET (Vauto_fill_chars, '\n', Qt);
Vambiguous_width_chars = Fmake_char_table (Qnil, Qnil);
DEFVAR_LISP ("printable-chars", Vprintable_chars,
- doc: /* A char-table for each printable character. */);
+ doc: /* A char-table for printable characters.
+Such characters have the value t in this table. */);
Vprintable_chars = Fmake_char_table (Qnil, Qnil);
Fset_char_table_range (Vprintable_chars,
Fcons (make_fixnum (32), make_fixnum (126)), Qt);