emacs-devel
[Top][All Lists]
Advanced

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

Re: Integer & glyph (trunk and emacs_unicode)


From: Stefan Monnier
Subject: Re: Integer & glyph (trunk and emacs_unicode)
Date: Thu, 15 Nov 2007 16:12:11 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux)

> (defun make-glyph-code (char &optional face)
>   "Return a glyph code representing char CHAR with face FACE."
>   ;; Due to limitations on Emacs integer values, faces with
>   ;; face id greater that 4091 are silently ignored.
>   (if (and face (<= (face-id face) #xfff))
>       (logior char (lsh (face-id face) 19))
>     char))

> So, it assumes 12 bits for face id and 19 bits for char code,
> the result is an integer of 31 bits.

I suspect that the "19" used to be something else (e.g. 16 when
integers were 28bits, so 16+12=28).

In any case, the test should be made more robust by not assuming
anything about the available range of integers (which has changed over
the years and can change depending on your config).
How 'bout

   (let ((id (and face (face-id face)))
     (if (and (numberp id)
              ;; Due to limitations on Emacs integer values, only
              ;; face ids below a certain limit can be used.
              (= id (lsh (lsh id 19) -19)))
         (logior char (lsh id 19))
       char))


-- Stefan




reply via email to

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