aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVasilij Schneidermann2017-06-01 21:25:58 +0300
committerEli Zaretskii2017-06-01 21:25:58 +0300
commitcb9aa3515ac00826fd27ade7dfc829134ed38acc (patch)
tree1363798d47fc5a7433519129fb726651a4c12a2e /src
parente5de79992a22f2932abb5f1f2600f576a60ae6ef (diff)
downloademacs-cb9aa3515ac00826fd27ade7dfc829134ed38acc.tar.gz
emacs-cb9aa3515ac00826fd27ade7dfc829134ed38acc.zip
Add customizable to display raw bytes as hex
* src/xdisp.c (get_next_display_element): Dispatch used format string for unprintables based on new display-raw-bytes-as-hex variable. (display-raw-bytes-as-hex): New variable. (Bug#27122) * lisp/cus-start.el: Add defcustom form for display-raw-bytes-as-hex. * doc/emacs/display.texi: Document the new variable. * etc/NEWS: Mention display-raw-bytes-as-hex. * test/manual/redisplay-testsuite.el (test-redisplay-5-toggle) (test-redisplay-5): New tests. (test-redisplay): Call test-redisplay-5.
Diffstat (limited to 'src')
-rw-r--r--src/xdisp.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index eaa701e9cf1..53210e5be5b 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -7055,7 +7055,7 @@ get_next_display_element (struct it *it)
7055 translated too. 7055 translated too.
7056 7056
7057 Non-printable characters and raw-byte characters are also 7057 Non-printable characters and raw-byte characters are also
7058 translated to octal form. */ 7058 translated to octal or hexadecimal form. */
7059 if (((c < ' ' || c == 127) /* ASCII control chars. */ 7059 if (((c < ' ' || c == 127) /* ASCII control chars. */
7060 ? (it->area != TEXT_AREA 7060 ? (it->area != TEXT_AREA
7061 /* In mode line, treat \n, \t like other crl chars. */ 7061 /* In mode line, treat \n, \t like other crl chars. */
@@ -7162,9 +7162,12 @@ get_next_display_element (struct it *it)
7162 int len, i; 7162 int len, i;
7163 7163
7164 if (CHAR_BYTE8_P (c)) 7164 if (CHAR_BYTE8_P (c))
7165 /* Display \200 instead of \17777600. */ 7165 /* Display \200 or \x80 instead of \17777600. */
7166 c = CHAR_TO_BYTE8 (c); 7166 c = CHAR_TO_BYTE8 (c);
7167 len = sprintf (str, "%03o", c + 0u); 7167 const char *format_string = display_raw_bytes_as_hex
7168 ? "x%02x"
7169 : "%03o";
7170 len = sprintf (str, format_string, c + 0u);
7168 7171
7169 XSETINT (it->ctl_chars[0], escape_glyph); 7172 XSETINT (it->ctl_chars[0], escape_glyph);
7170 for (i = 0; i < len; i++) 7173 for (i = 0; i < len; i++)
@@ -32231,6 +32234,13 @@ display table takes effect; in this case, Emacs does not consult
32231 /* Initialize to t, since we need to disable reordering until 32234 /* Initialize to t, since we need to disable reordering until
32232 loadup.el successfully loads charprop.el. */ 32235 loadup.el successfully loads charprop.el. */
32233 redisplay__inhibit_bidi = true; 32236 redisplay__inhibit_bidi = true;
32237
32238 DEFVAR_BOOL ("display-raw-bytes-as-hex", display_raw_bytes_as_hex,
32239 doc: /* Non-nil means display raw bytes in hexadecimal format.
32240The default is to use octal format (\200) whereas hexadecimal (\x80)
32241may be more familar to users. */);
32242 display_raw_bytes_as_hex = false;
32243
32234} 32244}
32235 32245
32236 32246