[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Printing elisp char literals
From: |
David Kastrup |
Subject: |
Re: Printing elisp char literals |
Date: |
26 May 2003 22:49:22 +0200 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 |
"Stefan Monnier" <monnier+gnu/address@hidden> writes:
> 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))
IIRC, XEmacs has sort of an opaque character representation type, so
it might be worth borrowing an idea or two from them in this regard
before reinventing the wheel. Stephen, any idea of whether something
might apply here?
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum