From: Vasilij Schneidermann <v.schneidermann@gmail.com>
To: 27122@debbugs.gnu.org
Subject: bug#27122: 26.0.50; [PATCH] Add customizable to display unprintables as hex
Date: Sun, 28 May 2017 22:42:50 +0200 [thread overview]
Message-ID: <20170528204250.wjbrm2pul6cf6xam@odonien.localdomain> (raw)
[-- 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
next reply other threads:[~2017-05-28 20:42 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-28 20:42 Vasilij Schneidermann [this message]
2017-05-29 2:33 ` bug#27122: 26.0.50; [PATCH] Add customizable to display unprintables as hex 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170528204250.wjbrm2pul6cf6xam@odonien.localdomain \
--to=v.schneidermann@gmail.com \
--cc=27122@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).