all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#27122: 26.0.50; [PATCH] Add customizable to display unprintables as hex
@ 2017-05-28 20:42 Vasilij Schneidermann
  2017-05-29  2:33 ` Eli Zaretskii
  0 siblings, 1 reply; 17+ messages in thread
From: Vasilij Schneidermann @ 2017-05-28 20:42 UTC (permalink / raw)
  To: 27122

[-- Attachment #1: Type: text/plain, Size: 445 bytes --]

Hello,

I find it tedious when looking at unprintables in Emacs just to have to
decode them from their octal to hexadecimal form for further lookup.
I've therefore written a patch that allows Emacs to display such
unprintables in hexadecimal format instead.  I'm not sure about the
naming though and whether a hardcoded secondary format string is the way
to go.  Once that's resolved, I'll add documentation to the patch.

Vasilij Schneidermann

[-- Attachment #2: 0001-Add-customizable-to-display-unprintables-as-hex.patch --]
[-- Type: text/x-diff, Size: 2093 bytes --]

From fb5c6bc81b3f63ce6258af0f54b876bf13f566ea Mon Sep 17 00:00:00 2001
From: Vasilij Schneidermann <mail@vasilij.de>
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


^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2017-06-01 18:19 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-28 20:42 bug#27122: 26.0.50; [PATCH] Add customizable to display unprintables as hex Vasilij Schneidermann
2017-05-29  2:33 ` Eli Zaretskii
2017-05-29  6:28   ` Vasilij Schneidermann
2017-05-29 18:46     ` Robert Cochran
2017-05-29 19:52       ` Eli Zaretskii
2017-05-29 20:20         ` Vasilij Schneidermann
2017-05-29 23:55           ` Robert Cochran
2017-05-30  0:11             ` npostavs
2017-05-30  0:47               ` Robert Cochran
2017-05-29 19:39     ` Eli Zaretskii
2017-05-29 20:15       ` Vasilij Schneidermann
2017-05-30  6:24         ` Eli Zaretskii
2017-05-30  8:16           ` Vasilij Schneidermann
2017-05-30  8:38             ` Eli Zaretskii
2017-06-01 17:05               ` Vasilij Schneidermann
2017-06-01 18:19                 ` Eli Zaretskii
2017-05-30 12:06           ` npostavs

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.