diff options
author | Mattias EngdegÄrd <mattiase@acm.org> | 2020-11-02 23:37:16 +0100 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2020-11-06 13:55:32 +0100 |
commit | 0c5eb1c7e798fdf16c3f2694285fe0d18367c6ea (patch) | |
tree | 5fc075ff856b1c770d48dc34f836dd89de700793 /src/character.c | |
parent | 527413fb2ff8c073d89ee2d22d38a67c74678b27 (diff) | |
download | emacs-0c5eb1c7e798fdf16c3f2694285fe0d18367c6ea.tar.gz emacs-0c5eb1c7e798fdf16c3f2694285fe0d18367c6ea.tar.bz2 emacs-0c5eb1c7e798fdf16c3f2694285fe0d18367c6ea.zip |
Reduce integer-output-format to print-integers-as-characters
The variable now only controls whether characters are printed, not
the radix. Control chars are printed in human-readable syntax
only when special escapes such as ?\n are available. Spaces,
formatting and combining chars are excluded (bug#44155).
Done in collaboration with Juri Linkov.
* src/character.c (graphic_base_p):
* src/print.c (named_escape): New functions.
(print_object): Change semantics as described above.
(syms_of_print): Rename integer-output-format. Update doc string.
* doc/lispref/streams.texi (Output Variables):
* etc/NEWS:
* test/src/print-tests.el (print-integers-as-characters):
Rename and update according to new semantics. The test now passes.
Diffstat (limited to 'src/character.c')
-rw-r--r-- | src/character.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/character.c b/src/character.c index 5860f6a0c8c..00b73293a3f 100644 --- a/src/character.c +++ b/src/character.c @@ -982,6 +982,27 @@ printablep (int c) || gen_cat == UNICODE_CATEGORY_Cn)); /* unassigned */ } +/* Return true if C is graphic character that can be printed independently. */ +bool +graphic_base_p (int c) +{ + Lisp_Object category = CHAR_TABLE_REF (Vunicode_category_table, c); + if (! FIXNUMP (category)) + return false; + EMACS_INT gen_cat = XFIXNUM (category); + + return (!(gen_cat == UNICODE_CATEGORY_Mn /* mark, nonspacing */ + || gen_cat == UNICODE_CATEGORY_Mc /* mark, combining */ + || gen_cat == UNICODE_CATEGORY_Me /* mark, enclosing */ + || gen_cat == UNICODE_CATEGORY_Zs /* separator, space */ + || gen_cat == UNICODE_CATEGORY_Zl /* separator, line */ + || gen_cat == UNICODE_CATEGORY_Zp /* separator, paragraph */ + || gen_cat == UNICODE_CATEGORY_Cc /* other, control */ + || gen_cat == UNICODE_CATEGORY_Cs /* other, surrogate */ + || gen_cat == UNICODE_CATEGORY_Cf /* other, format */ + || gen_cat == UNICODE_CATEGORY_Cn)); /* other, unassigned */ +} + /* Return true if C is a horizontal whitespace character, as defined by https://www.unicode.org/reports/tr18/tr18-19.html#blank. */ bool |