0

ASCII defines some control codes: for example 0x0A for Line Feed or 0x09 for Hoizontal Tab. Emacs gives them a meaning by the way they are rendered. 0x09 moves the succeeding text horizontally and 0x0A moves the text vertically. Most of the remaining control code are not used by Emacs. Instead they are displayed as a character with a preceding circumflex: for example Carriage Return as ^M or Form Feed as ^L.

But Unicode defines graphical representations for control codes. If the used font defines them, they can be used to display control codes.

In order to do so, it is necessary to tell Emacs to display anything else but ^M when it sees 0x0D. This is my question: how can I tell Emacs to display something else but ^M for 0x0D?

1 Answer 1

1

Using Display Tables (see also Active Display Table):

(unless buffer-display-table
  (setq buffer-display-table (make-display-table)))
(dotimes (i 32)
  (unless (or (= i ?\t) (= i ?\n))
    (aset buffer-display-table i
          (vector (make-glyph-code (+ #x2400 i) 'escape-glyph)))))
2
  • Uff this is huge. (length buffer-display-table) returns more than 4 million although Unicode defines just about 150 thousand.
    – ceving
    Jan 22, 2023 at 12:35
  • Meh. Most of it is empty, so that's not a big deal.
    – rpluim
    Jan 23, 2023 at 11:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.