help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: displaying octal sequences in emacs 21.3.1


From: Oliver Scholz
Subject: Re: displaying octal sequences in emacs 21.3.1
Date: Sat, 09 Oct 2004 12:48:38 +0200
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3.50 (windows-nt)

Roland Winkler <Roland.Winkler@physik.uni-erlangen.de> writes:

> Eli Zaretskii <eliz@is.elta.co.il> writes:
>
>> On 2 Jul 1999, Roland Winkler wrote:
>> 
>> > My default setting for editing files is unibyte with
>> > iso-latin-1. What should I do if in certain buffers I want
>> > everything beyond 7bit asci to be displayed with the
>> > corresponding octal number?
[...]

I use this:

;; -------------------------------------------------------------------
;;; `eight-bit-graphic' and `eight-bit-control'

;; Display characters from the charsets `eight-bit-control' and
;; `eight-bit-graphic' as octal numbers in a different face.

(defface egoge-8bit-char-face
  '((t
     (:weight bold :inherit font-lock-warning-face)))
  "Face used to display characters from the charsets
`eight-bit-graphic' and `eight-bit-control'.")

(defun egoge-display-eight-bit-as-octal (&optional face)
  (let ((face-offset (if face
                         (* (face-id face)
                            (expt 2 19))
                       0))
        char)
    (dotimes (i 128)
      (setq char (+ i 128))
      (aset standard-display-table char
            (vconcat (mapcar (lambda (c)
                               (+ face-offset c))
                             (format "\\%o" char)))))))

(unless (> emacs-major-version 21)
  (egoge-display-eight-bit-as-octal 'egoge-8bit-char-face))


It works in multibyte buffers, too.  And it works for all buffers.
IMO this is the right thing.  If you want to edit Latin-1, use a
multibyte buffer; if you want to see the octal sequences for
non-ascii, use a unibyte buffer.

[And actually I think something like this should be the default in
Emacs.]

    Oliver
-- 
18 Vendémiaire an 213 de la Révolution
Liberté, Egalité, Fraternité!


reply via email to

[Prev in Thread] Current Thread [Next in Thread]