From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Oleksandr Gavenko Newsgroups: gmane.emacs.help Subject: Re: How switch from escaped octal character code to escaped HEX? Date: Tue, 11 Jan 2011 12:23:38 +0200 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1294741529 24023 80.91.229.12 (11 Jan 2011 10:25:29 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 11 Jan 2011 10:25:29 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jan 11 11:25:25 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PcbPo-0005m0-G9 for geh-help-gnu-emacs@m.gmane.org; Tue, 11 Jan 2011 11:25:24 +0100 Original-Received: from localhost ([127.0.0.1]:52019 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PcbPn-0008FO-QH for geh-help-gnu-emacs@m.gmane.org; Tue, 11 Jan 2011 05:25:23 -0500 Original-Received: from [140.186.70.92] (port=55756 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PcbOM-0008Cn-NI for help-gnu-emacs@gnu.org; Tue, 11 Jan 2011 05:23:56 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PcbOL-00053y-1l for help-gnu-emacs@gnu.org; Tue, 11 Jan 2011 05:23:54 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]:33313) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PcbOK-00053W-N6 for help-gnu-emacs@gnu.org; Tue, 11 Jan 2011 05:23:53 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1PcbOI-00055E-9o for help-gnu-emacs@gnu.org; Tue, 11 Jan 2011 11:23:50 +0100 Original-Received: from 91.193.68.214 ([91.193.68.214]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 11 Jan 2011 11:23:50 +0100 Original-Received: from gavenko by 91.193.68.214 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 11 Jan 2011 11:23:50 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 68 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 91.193.68.214 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:78387 Archived-At: On 03.01.2011 6:23, Stefan Monnier wrote: >>> When Emacs find that byte that does >>> not correspond to any specific displayable character it display >>> octal codes instead, like: \276 (and with different color). >>> >>> This is useful, but I prefer HEX base instead octal. > > There is no direct/easy way to do it. > But you can do it by adding the corresponding 128 entries to the > standard-display-table. > > E.g. > > (setq standard-display-table (make-display-table)) > (aset standard-display-table (unibyte-char-to-multibyte 131) > [?\\ ?x ?8 ?3]) > (aset standard-display-table (unibyte-char-to-multibyte 132) > [?\\ ?x ?8 ?4]) > > Should make the bytes 131 and 132 be displayed as \x83 and \x84 rather > than \203 and \204. > Thanks Stefan for tips. I read docs for 'buffer-display-table'. Here said: For example, (aset buffer-display-table ?X [?Y]) tells Emacs to display a capital Y instead of each X character. So if in one encoding (cp1251) letter - й, in another (row-text) - \351. I set: (aset standard-display-table (unibyte-char-to-multibyte ?\xe9) [?\\ ?x ?e ?9]) but in cp1251 it properly displayed like й, in row-text - \xe9. I afraid that it in all case must be \xe9, but not. This is nice! With this behavior I make I wont. Only one problem. In GUI Emacs octal codes colorized (some thins red color, C-u C-x = don't give font properties). New hex values is not colorized. How make this? PS. To make all 128 chars in hex I wrote: (setq standard-display-table (make-display-table)) (let ( (i ?\x80) hex hi low ) (while (<= i ?\xff) (setq hex (format "%x" i)) (setq hi (elt hex 0)) (setq low (elt hex 1)) (aset standard-display-table (unibyte-char-to-multibyte i) (vector ?\\ ?x hi low)) (setq i (+ i 1)) ) ) PPS. Noel Evans send to me private mail where hi suggest: (setq read-quoted-char-radix 16) I already have this settings a lot of years. It allow you type byte in hex: C-q 9 9 RET.