all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How switch from escaped octal character code to escaped HEX?
@ 2010-12-28 15:39 Oleksandr Gavenko
  2010-12-28 15:51 ` Oleksandr Gavenko
       [not found] ` <mailman.6.1293551515.18545.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 11+ messages in thread
From: Oleksandr Gavenko @ 2010-12-28 15:39 UTC (permalink / raw)
  To: help-gnu-emacs

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.

How can I change this behavior.

To hard find right keywords for search in manual and Google ((





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

* Re: How switch from escaped octal character code to escaped HEX?
  2010-12-28 15:39 How switch from escaped octal character code to escaped HEX? Oleksandr Gavenko
@ 2010-12-28 15:51 ` Oleksandr Gavenko
       [not found] ` <mailman.6.1293551515.18545.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 11+ messages in thread
From: Oleksandr Gavenko @ 2010-12-28 15:51 UTC (permalink / raw)
  To: help-gnu-emacs

On 28.12.2010 17:39, Oleksandr Gavenko 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.
>
> How can I change this behavior.
>
> To hard find right keywords for search in manual and Google ((
>
This from manual:

    As a special case, if the character lies in the range 128 (0200
octal) through 159 (0237 octal), it stands for a "raw" byte that does
not correspond to any specific displayable character.  Such a
"character" lies within the `eight-bit-control' character set, and is
displayed as an escaped octal character code.  In this case, `C-x ='
shows `part of display ...' instead of `file'.

I want change with behavior from octal to hex.




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

* Re: How switch from escaped octal character code to escaped HEX?
       [not found] ` <mailman.6.1293551515.18545.help-gnu-emacs@gnu.org>
@ 2011-01-03  4:23   ` Stefan Monnier
  2011-01-03  7:14     ` Deniz Dogan
                       ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Stefan Monnier @ 2011-01-03  4:23 UTC (permalink / raw)
  To: help-gnu-emacs

>> 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.


        Stefan


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

* Re: How switch from escaped octal character code to escaped HEX?
  2011-01-03  4:23   ` Stefan Monnier
@ 2011-01-03  7:14     ` Deniz Dogan
  2011-01-03 10:13       ` Deniz Dogan
  2011-01-04  4:03       ` Stefan Monnier
       [not found]     ` <mailman.8.1294038895.27854.help-gnu-emacs@gnu.org>
                       ` (2 subsequent siblings)
  3 siblings, 2 replies; 11+ messages in thread
From: Deniz Dogan @ 2011-01-03  7:14 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

2011/1/3 Stefan Monnier <monnier@iro.umontreal.ca>:
>>> 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.
>
>

What is the reasoning behind displaying it in octal rather than
decimal or hexadecimal in the first place? I didn't know people cared
about octals anymore.

-- 
Deniz Dogan



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

* Re: How switch from escaped octal character code to escaped HEX?
  2011-01-03  7:14     ` Deniz Dogan
@ 2011-01-03 10:13       ` Deniz Dogan
  2011-01-03 14:37         ` Peter Dyballa
  2011-01-04  4:03       ` Stefan Monnier
  1 sibling, 1 reply; 11+ messages in thread
From: Deniz Dogan @ 2011-01-03 10:13 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

2011/1/3 Deniz Dogan <deniz.a.m.dogan@gmail.com>:
> 2011/1/3 Stefan Monnier <monnier@iro.umontreal.ca>:
>>>> 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.
>>
>>
>
> What is the reasoning behind displaying it in octal rather than
> decimal or hexadecimal in the first place? I didn't know people cared
> about octals anymore.
>

I read on Wikipedia: "Octal representation of non-ASCII bytes may be
particularly handy with UTF-8, where any start byte has octal value
\3nn and any continuation byte has octal value \2nn."

Is this the reason perhaps?

-- 
Deniz Dogan



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

* Re: How switch from escaped octal character code to escaped HEX?
       [not found]     ` <mailman.8.1294038895.27854.help-gnu-emacs@gnu.org>
@ 2011-01-03 13:42       ` Barry Margolin
  0 siblings, 0 replies; 11+ messages in thread
From: Barry Margolin @ 2011-01-03 13:42 UTC (permalink / raw)
  To: help-gnu-emacs

In article <mailman.8.1294038895.27854.help-gnu-emacs@gnu.org>,
 Deniz Dogan <deniz.a.m.dogan@gmail.com> wrote:

> What is the reasoning behind displaying it in octal rather than
> decimal or hexadecimal in the first place? I didn't know people cared
> about octals anymore.

I think it's historical.  The original MIT developers tended to use 
octal more than hex.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***


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

* Re: How switch from escaped octal character code to escaped HEX?
  2011-01-03 10:13       ` Deniz Dogan
@ 2011-01-03 14:37         ` Peter Dyballa
  0 siblings, 0 replies; 11+ messages in thread
From: Peter Dyballa @ 2011-01-03 14:37 UTC (permalink / raw)
  To: Deniz Dogan; +Cc: help-gnu-emacs, Stefan Monnier


Am 03.01.2011 um 11:13 schrieb Deniz Dogan:

> I read on Wikipedia: "Octal representation of non-ASCII bytes may be
> particularly handy with UTF-8, where any start byte has octal value
> \3nn and any continuation byte has octal value \2nn."
>
> Is this the reason perhaps?

Certainly not! GNU Emacs was octal before someone imagined "Unicode"...

It comes from sparse memory. One byte is two nibbles! (1 € is almost 2  
ancient DM.) UNIX file permissions are octal. C is great in shifting  
bits around.

--
Greetings

   Pete

Almost anything is easier to get into than out of.
				– Allen's Law




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

* Re: How switch from escaped octal character code to escaped HEX?
  2011-01-03  7:14     ` Deniz Dogan
  2011-01-03 10:13       ` Deniz Dogan
@ 2011-01-04  4:03       ` Stefan Monnier
  1 sibling, 0 replies; 11+ messages in thread
From: Stefan Monnier @ 2011-01-04  4:03 UTC (permalink / raw)
  To: Deniz Dogan; +Cc: help-gnu-emacs

> What is the reasoning behind displaying it in octal rather than
> decimal or hexadecimal in the first place?

As mentioned by someone else, this goes back to the beginning of Emacs,
so we're talking >20 years ago.  IIUC octal was more common back then.

There are still some advantages to using octal: e.g., by using fewer
different chars, there is a higher likelihood that the boundary of the
\NNN sequence will be self obvious: when you see \01234, it's not
obvious that it's \012 followed by 3 and 4, but when you see \012ab the
boundary is self-evident.  With hexadecimal, the cases where the
boundary is not self-evident are more common.


        Stefan



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

* Re: How switch from escaped octal character code to escaped HEX?
  2011-01-03  4:23   ` Stefan Monnier
  2011-01-03  7:14     ` Deniz Dogan
       [not found]     ` <mailman.8.1294038895.27854.help-gnu-emacs@gnu.org>
@ 2011-01-11 10:23     ` Oleksandr Gavenko
       [not found]     ` <mailman.0.1294741438.20926.help-gnu-emacs@gnu.org>
  3 siblings, 0 replies; 11+ messages in thread
From: Oleksandr Gavenko @ 2011-01-11 10:23 UTC (permalink / raw)
  To: help-gnu-emacs

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.




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

* Re: How switch from escaped octal character code to escaped HEX?
       [not found]     ` <mailman.0.1294741438.20926.help-gnu-emacs@gnu.org>
@ 2011-01-11 17:34       ` Stefan Monnier
  2011-01-12  9:22         ` Oleksandr Gavenko
  0 siblings, 1 reply; 11+ messages in thread
From: Stefan Monnier @ 2011-01-11 17:34 UTC (permalink / raw)
  To: help-gnu-emacs

> New hex values is not colorized. How make this?

(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 (make-glyph-code ?\\ 'escape-glyph)
		  (make-glyph-code ?x 'escape-glyph)
		  (make-glyph-code hi 'escape-glyph)
		  (make-glyph-code low 'escape-glyph)))
    (setq i (+ i 1))))


-- Stefan


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

* Re: How switch from escaped octal character code to escaped HEX?
  2011-01-11 17:34       ` Stefan Monnier
@ 2011-01-12  9:22         ` Oleksandr Gavenko
  0 siblings, 0 replies; 11+ messages in thread
From: Oleksandr Gavenko @ 2011-01-12  9:22 UTC (permalink / raw)
  To: help-gnu-emacs

On 11.01.2011 19:34, Stefan Monnier wrote:
>> New hex values is not colorized. How make this?
>
> (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 (make-glyph-code ?\\ 'escape-glyph)
> 		  (make-glyph-code ?x 'escape-glyph)
> 		  (make-glyph-code hi 'escape-glyph)
> 		  (make-glyph-code low 'escape-glyph)))
>      (setq i (+ i 1))))
>
Oh! Very thanks!!!!!!!!

glyphs is interesting concept which I don't know.




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

end of thread, other threads:[~2011-01-12  9:22 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-28 15:39 How switch from escaped octal character code to escaped HEX? Oleksandr Gavenko
2010-12-28 15:51 ` Oleksandr Gavenko
     [not found] ` <mailman.6.1293551515.18545.help-gnu-emacs@gnu.org>
2011-01-03  4:23   ` Stefan Monnier
2011-01-03  7:14     ` Deniz Dogan
2011-01-03 10:13       ` Deniz Dogan
2011-01-03 14:37         ` Peter Dyballa
2011-01-04  4:03       ` Stefan Monnier
     [not found]     ` <mailman.8.1294038895.27854.help-gnu-emacs@gnu.org>
2011-01-03 13:42       ` Barry Margolin
2011-01-11 10:23     ` Oleksandr Gavenko
     [not found]     ` <mailman.0.1294741438.20926.help-gnu-emacs@gnu.org>
2011-01-11 17:34       ` Stefan Monnier
2011-01-12  9:22         ` Oleksandr Gavenko

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.