>From fb5c6bc81b3f63ce6258af0f54b876bf13f566ea Mon Sep 17 00:00:00 2001 From: Vasilij Schneidermann Date: Sun, 28 May 2017 22:31:34 +0200 Subject: [PATCH] Add customizable to display unprintables as hex * src/xdisp.c (get_next_display_element): Dispatch used format string for unprintables based on new display-unprintables-as-hex variable (display-unprintables-as-hex): New variable --- src/xdisp.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/xdisp.c b/src/xdisp.c index ddb26b8def..b2b2f30594 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -7044,7 +7044,7 @@ get_next_display_element (struct it *it) translated too. Non-printable characters and raw-byte characters are also - translated to octal form. */ + translated to octal or hexadecimal form. */ if (((c < ' ' || c == 127) /* ASCII control chars. */ ? (it->area != TEXT_AREA /* In mode line, treat \n, \t like other crl chars. */ @@ -7151,9 +7151,12 @@ get_next_display_element (struct it *it) int len, i; if (CHAR_BYTE8_P (c)) - /* Display \200 instead of \17777600. */ + /* Display \200 or \x80 instead of \17777600. */ c = CHAR_TO_BYTE8 (c); - len = sprintf (str, "%03o", c + 0u); + const char *format_string = display_unprintables_as_hex + ? "x%02x" + : "%03o"; + len = sprintf (str, format_string, c + 0u); XSETINT (it->ctl_chars[0], escape_glyph); for (i = 0; i < len; i++) @@ -32209,6 +32212,14 @@ display table takes effect; in this case, Emacs does not consult /* Initialize to t, since we need to disable reordering until loadup.el successfully loads charprop.el. */ redisplay__inhibit_bidi = true; + + DEFVAR_BOOL ("display-unprintables-as-hex", + display_unprintables_as_hex, + doc: /* Non-nil means display unprintables in hexadecimal format. +The default is to use octal format (\200) whereas hexadecimal (\x80) +may be more familar to users. */); + display_unprintables_as_hex = false; + } -- 2.13.0