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: Thu, 1 Jun 2017 19:05:09 +0200 Message-ID: <20170601170509.gqdthhs2yfgzit3g@odonien.localdomain> References: <20170528204250.wjbrm2pul6cf6xam@odonien.localdomain> <83o9ucfl37.fsf@gnu.org> <20170529062859.mwoveygr5oh5iphz@odonien.localdomain> <8360gjfo51.fsf@gnu.org> <20170529201558.yogm76php5fbpz35@odonien.localdomain> <83tw42eua6.fsf@gnu.org> <20170530081628.xwl2ztjnkeqp4m47@odonien.localdomain> <83lgpeeo2k.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="atpgonreluom435a" X-Trace: blaine.gmane.org 1496336788 27925 195.159.176.226 (1 Jun 2017 17:06:28 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 1 Jun 2017 17:06:28 +0000 (UTC) User-Agent: NeoMutt/20170428-45-01e908 (1.8.2) Cc: 27122@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jun 01 19:06:20 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 1dGTY6-0006Kz-Eq for geb-bug-gnu-emacs@m.gmane.org; Thu, 01 Jun 2017 19:06:14 +0200 Original-Received: from localhost ([::1]:45772 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGTY6-0006AE-Mw for geb-bug-gnu-emacs@m.gmane.org; Thu, 01 Jun 2017 13:06:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33299) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGTXy-0006A9-14 for bug-gnu-emacs@gnu.org; Thu, 01 Jun 2017 13:06:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dGTXu-0003wv-Ok for bug-gnu-emacs@gnu.org; Thu, 01 Jun 2017 13:06:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:47259) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dGTXu-0003wf-IK for bug-gnu-emacs@gnu.org; Thu, 01 Jun 2017 13:06:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dGTXt-0002q7-Rd for bug-gnu-emacs@gnu.org; Thu, 01 Jun 2017 13:06:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Vasilij Schneidermann Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 01 Jun 2017 17:06:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27122 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 27122-submit@debbugs.gnu.org id=B27122.149633672010863 (code B ref 27122); Thu, 01 Jun 2017 17:06:01 +0000 Original-Received: (at 27122) by debbugs.gnu.org; 1 Jun 2017 17:05:20 +0000 Original-Received: from localhost ([127.0.0.1]:49936 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dGTXD-0002p9-H1 for submit@debbugs.gnu.org; Thu, 01 Jun 2017 13:05:19 -0400 Original-Received: from mail-wm0-f66.google.com ([74.125.82.66]:34582) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dGTXB-0002ov-0t for 27122@debbugs.gnu.org; Thu, 01 Jun 2017 13:05:18 -0400 Original-Received: by mail-wm0-f66.google.com with SMTP id d127so12833211wmf.1 for <27122@debbugs.gnu.org>; Thu, 01 Jun 2017 10:05:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=UqhJQGav0pDIqFnEMooMASZ+ei0SBbiX/sLWcaJmTLI=; b=Ah/26W3gXIahoRNKOff7WUblX945ECG8Nvth9Dj3+TDKpLvkmkBy3WPHNIqmhezL5f 1N1sSpoyBATgumZTIfBd7RjCOhz+P7ZSB1CC43N/fyAPFkiLg+luvXEB93lFq7cu7PZS sAZO4yrteDYnp5ekrYNYXJnoI5v/m7jAyiWY0buPnS3PtR9XuX2nRjKgeeuujvxOT3Ey 9NXc5nDQieRBpOl//IGDZZFsaBSY1UeTSdVHXPAmfIqMPocvvr7nG5tZq1+kj3LldCO2 I9JfeMf2dcMeh51kHc/rs0XLOI6vGU7vDpzdc/Ul+9lCa6v+gvAQNfWS8TCZ7tvTm8ok me0A== 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:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=UqhJQGav0pDIqFnEMooMASZ+ei0SBbiX/sLWcaJmTLI=; b=iFTtPb1OkUzR+FoTBmUPyDoRyQNIct11uIAfymTsScUGRGqrwYacl1Fd2qJE3teyVe u5849VmNNzy8LKhStSavDcERGkwdFux1HZiXHx0tKtvFlZErEgjXx5xotYzXjWy5g8nr Ft2pGrUFo6JRT3Kh7lq1swiEjoFFf0lG5PPCrnKl8uajGCs2Rxcmjn48SxQ9TkTRUFH7 VsL9QmfHpmEEbnopmyHsd6Yls1bIRX0FgVvtEBVNztyKHRi9sutWGAR0sMe7QaSQEu58 q1HvAedbBo9hZe6vDqv7P2krzbAQAjIfLTPahg/8D6UIylNhE85kgEVBuD2YHF4IOLm7 z1Zw== X-Gm-Message-State: AODbwcBOAgCI+HQz7ZOjqPEsovo134qTJy2F29KPgdHmoysccLlVajgN HxiNJl7aVLejbw== X-Received: by 10.80.146.51 with SMTP id i48mr2644065eda.48.1496336711411; Thu, 01 Jun 2017 10:05:11 -0700 (PDT) Original-Received: from localhost (2001-4dd0-2019-913-a11-96ff-fea9-8754.ipv6dyn.netcologne.de. [2001:4dd0:2019:913:a11:96ff:fea9:8754]) by smtp.gmail.com with ESMTPSA id t17sm6548377edh.1.2017.06.01.10.05.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 01 Jun 2017 10:05:10 -0700 (PDT) Content-Disposition: inline In-Reply-To: <83lgpeeo2k.fsf@gnu.org> 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:133138 Archived-At: --atpgonreluom435a Content-Type: text/plain; charset=utf-8 Content-Disposition: inline > Yes, I think test/manual/redisplay-testsuite.el is where the > additional tests should go. OK, I've added a test there that allows you to toggle between both representations. > Please end each sentence in the commit log message with a period, and > please mention the bug number there. Please also add a short log > entry for etc/NEWS. Fixed. I'm not sure what you mean by the NEWS entry though, the patch has four lines in etc/NEWS describing the new feature. Are you possibly referring to a different format or file? --atpgonreluom435a Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0001-Add-customizable-to-display-raw-bytes-as-hex.patch" >From 7c66dff5dc35e663dd3d39e2b30205924fa262c7 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 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. * doc/emacs/display.texi: Document the new variable. --- doc/emacs/display.texi | 6 ++++++ etc/NEWS | 4 ++++ lisp/cus-start.el | 1 + src/xdisp.c | 16 +++++++++++++--- test/manual/redisplay-testsuite.el | 27 ++++++++++++++++++++++++++- 5 files changed, 50 insertions(+), 4 deletions(-) diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi index d07913cefb..edcb575722 100644 --- a/doc/emacs/display.texi +++ b/doc/emacs/display.texi @@ -1756,3 +1756,9 @@ Display Custom in text that is hard to read. Call the function @code{tty-suppress-bold-inverse-default-colors} with a non-@code{nil} argument to suppress the effect of bold-face in this case. + +@vindex display-raw-bytes-as-hex + Raw bytes are displayed in octal format by default, for example a +byte with a decimal value of 128 is displayed as @code{\200}. To +change display to the hexadecimal format of @code{\x80}, set the +variable @code{display-raw-bytes-as-hex} to @code{t}. diff --git a/etc/NEWS b/etc/NEWS index 60066b7c9f..ee941624d8 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -363,6 +363,10 @@ large integers from being displayed as characters. ** Two new commands for finding the source code of Emacs Lisp libraries: 'find-library-other-window' and 'find-library-other-frame'. ++++ +** The new variable 'display-raw-bytes-as-hex' allows to change the +display of raw bytes from octal to hex. + * Editing Changes in Emacs 26.1 diff --git a/lisp/cus-start.el b/lisp/cus-start.el index 4253d40b75..744fe7f69e 100644 --- a/lisp/cus-start.el +++ b/lisp/cus-start.el @@ -583,6 +583,7 @@ minibuffer-prompt-properties--setter (const :tag "Fit (t)" :value t) (const :tag "Grow only" :value grow-only)) "25.1") + (display-raw-bytes-as-hex display boolean "26.1") ;; xfaces.c (scalable-fonts-allowed display boolean "22.1") ;; xfns.c diff --git a/src/xdisp.c b/src/xdisp.c index ddb26b8def..10124d6f3d 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_raw_bytes_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,13 @@ 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-raw-bytes-as-hex", display_raw_bytes_as_hex, + doc: /* Non-nil means display raw bytes in hexadecimal format. +The default is to use octal format (\200) whereas hexadecimal (\x80) +may be more familar to users. */); + display_raw_bytes_as_hex = false; + } diff --git a/test/manual/redisplay-testsuite.el b/test/manual/redisplay-testsuite.el index 694d55ab1d..2175cbab1b 100644 --- a/test/manual/redisplay-testsuite.el +++ b/test/manual/redisplay-testsuite.el @@ -34,7 +34,8 @@ test-insert-overlay (setq overlay (make-overlay opoint (point))) (while props (overlay-put overlay (car props) (cadr props)) - (setq props (cddr props))))) + (setq props (cddr props))) + overlay)) (defun test-redisplay-1 () (insert "Test 1: Displaying adjacent and overlapping overlays:\n\n") @@ -293,6 +294,29 @@ test-redisplay-4 (insert "\n")) +(defvar test-redisplay-5-expected-overlay nil) +(defvar test-redisplay-5-result-overlay nil) + +(defun test-redisplay-5-toggle (_event) + (interactive "e") + (setq display-raw-bytes-as-hex (not display-raw-bytes-as-hex)) + (let ((label (if display-raw-bytes-as-hex "\\x80" "\\200"))) + (overlay-put test-redisplay-5-expected-overlay 'display + (propertize label 'face 'escape-glyph)))) + +(defun test-redisplay-5 () + (insert "Test 5: Display of raw bytes:\n\n") + (insert " Expected: ") + (setq test-redisplay-5-expected-overlay + (test-insert-overlay " " 'display + (propertize "\\200" 'face 'escape-glyph))) + (insert "\n Result: ") + (setq test-redisplay-5-result-overlay + (test-insert-overlay " " 'display "\200")) + (insert "\n\n") + (insert-button "Toggle between octal and hex display" + 'action 'test-redisplay-5-toggle)) + (defun test-redisplay () (interactive) @@ -309,5 +333,6 @@ test-redisplay (test-redisplay-2) (test-redisplay-3) (test-redisplay-4) + (test-redisplay-5) (goto-char (point-min)))) -- 2.13.0 --atpgonreluom435a--