From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Vasilij Schneidermann Newsgroups: gmane.emacs.bugs Subject: bug#27122: 26.0.50; [PATCH] Add customizable to display unprintables as hex Date: Sun, 28 May 2017 22:42:50 +0200 Message-ID: <20170528204250.wjbrm2pul6cf6xam@odonien.localdomain> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="hiprkzy2dona2hx2" X-Trace: blaine.gmane.org 1496004493 11747 195.159.176.226 (28 May 2017 20:48:13 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 28 May 2017 20:48:13 +0000 (UTC) User-Agent: NeoMutt/20170428-45-01e908 (1.8.2) To: 27122@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun May 28 22:48:09 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dF56e-0002wl-Pl for geb-bug-gnu-emacs@m.gmane.org; Sun, 28 May 2017 22:48:09 +0200 Original-Received: from localhost ([::1]:45210 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dF56k-0003n7-BE for geb-bug-gnu-emacs@m.gmane.org; Sun, 28 May 2017 16:48:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56515) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dF56d-0003lX-MZ for bug-gnu-emacs@gnu.org; Sun, 28 May 2017 16:48:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dF56Y-0002V6-Qh for bug-gnu-emacs@gnu.org; Sun, 28 May 2017 16:48:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:39457) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dF56Y-0002Um-MB for bug-gnu-emacs@gnu.org; Sun, 28 May 2017 16:48:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dF56Y-0001XU-GS for bug-gnu-emacs@gnu.org; Sun, 28 May 2017 16:48:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Vasilij Schneidermann Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 28 May 2017 20:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 27122 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.14960044625887 (code B ref -1); Sun, 28 May 2017 20:48:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 28 May 2017 20:47:42 +0000 Original-Received: from localhost ([127.0.0.1]:42134 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dF56D-0001Wt-PT for submit@debbugs.gnu.org; Sun, 28 May 2017 16:47:42 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:36689) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dF56C-0001We-IA for submit@debbugs.gnu.org; Sun, 28 May 2017 16:47:40 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dF55v-0001up-4q for submit@debbugs.gnu.org; Sun, 28 May 2017 16:47:35 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:59219) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dF55u-0001uh-W0 for submit@debbugs.gnu.org; Sun, 28 May 2017 16:47:23 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55074) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dF53q-0003B1-Ct for bug-gnu-emacs@gnu.org; Sun, 28 May 2017 16:47:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dF51a-0000dj-Mf for bug-gnu-emacs@gnu.org; Sun, 28 May 2017 16:45:14 -0400 Original-Received: from mail-wm0-x235.google.com ([2a00:1450:400c:c09::235]:36674) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dF51a-0000d7-AY for bug-gnu-emacs@gnu.org; Sun, 28 May 2017 16:42:54 -0400 Original-Received: by mail-wm0-x235.google.com with SMTP id 7so33457305wmo.1 for ; Sun, 28 May 2017 13:42:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mime-version:content-disposition :user-agent; bh=aC9ajxtvo6KJ+kFxWEeO5u9t4uMmvyZfRCoUvbywT2g=; b=g7owySoZQkf8QkpajbzqLhM3ExO2+hgnFUk1lwvwX+7D7R7g8hN9YLAUj0XYjaFbdb qrBbvnd9NAynshGvI5V6aOgci0LW45FZxGMqQGWI70FeRHoC/RJHBdykhIX5bggaa4TP k5KWcwIX4+1r0VMslvU7pcw+yeMqEzr5S168HlkhSKwY4q7WSZyhgCgwyarx54KQayUy IJYLp5n6B6Cu/qF8eMyK/MsSgcvfXQ4aFldlwdJ2S+RuFAten3ApCfvZuVfP+KpzKGGG uCLkLQil8S8jVEWxm4xtOsq5CPeb4dTqkQYSbsoT4BEW01yW45UKN2naKYuXGHY0vpWr En4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=aC9ajxtvo6KJ+kFxWEeO5u9t4uMmvyZfRCoUvbywT2g=; b=pac2QG8JQhtgIkC8pCZm/bodk2CkjFmi+UaV3wUN7WvxB2LTaDB/uvvF8htHoYDM53 GUr3TniH0iEA9iK+NW76mMMS74pilimQo2HJuzLdTHidDC97zA5108YslRrxslUhDAns xQcOZqcuT53ErBHC43/42Aokfhe+llFe/22shmlyQkVXwNyCv6hq1sFBw3tvcHsz9bwC Uv7JvHjTVUYRcwmxr0Mtaop58CHdKsatoyzxQIxUnJHXc3OtqNQyH7rX/jUoQk+zqj7o 2g9tReFeZAPTAe4z6bGTO93FUnAaT8waEkwkw+MATLK91KDYFQ0cmGUNwQhGcbxIPLS1 WV7g== X-Gm-Message-State: AODbwcBi04XwNbbgRo8yF6SqR81J4FtaKy8ZvMnKyVKgP0yZXOZVUDPP TLc0b7fF74y2PFFUY8M= X-Received: by 10.80.154.165 with SMTP id p34mr10265313edb.127.1496004172650; Sun, 28 May 2017 13:42:52 -0700 (PDT) Original-Received: from localhost (dslb-094-220-195-039.094.220.pools.vodafone-ip.de. [94.220.195.39]) by smtp.gmail.com with ESMTPSA id b3sm3517665ede.9.2017.05.28.13.42.51 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 28 May 2017 13:42:51 -0700 (PDT) Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:132969 Archived-At: --hiprkzy2dona2hx2 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline 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 --hiprkzy2dona2hx2 Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0001-Add-customizable-to-display-unprintables-as-hex.patch" >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 --hiprkzy2dona2hx2--