emacs-devel
[Top][All Lists]
Advanced

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

Printing elisp char literals


From: Stefan Monnier
Subject: Printing elisp char literals
Date: Mon, 26 May 2003 16:27:55 -0400

Let's say I have an integer.  How can I check whether it's a char ?
`char-valid-p' is only part of the answer, because I'd like to know
if the integer is a char-with-modifiers also.  The best I could come
up with right now is:

   (char-valid-p (logand char ?\x3fffff))

Is the mask available somewhere or do I simply have to hardcode it
like that ?

Furthermore, in order to print this integer in a form like ?\C-a,
what should I do ?  The best I could come up with is:

    (let ((s (single-key-description char)))
      (while (string-match "\\`\\(\\\\[MCAHSs]-\\)*\\(\\)[MCAHSs]-." s)
        (setq s (replace-match "\\" t t s 2)))
      (concat "?" s))


-- Stefan





reply via email to

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