From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Vinicius Jose Latorre Newsgroups: gmane.emacs.devel Subject: Re: Integer & glyph (trunk and emacs_unicode) Date: Fri, 16 Nov 2007 10:25:05 -0300 Message-ID: <473D9A31.8040408@ig.com.br> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1195215920 23406 80.91.229.12 (16 Nov 2007 12:25:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 16 Nov 2007 12:25:20 +0000 (UTC) Cc: Stefan Monnier , "GNU Emacs \(devel\)" To: Drew Adams Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Nov 16 13:25:25 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1It0GB-0005Jd-UI for ged-emacs-devel@m.gmane.org; Fri, 16 Nov 2007 13:25:24 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1It0Fy-0003zB-Vy for ged-emacs-devel@m.gmane.org; Fri, 16 Nov 2007 07:25:11 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1It0Fv-0003wE-UZ for emacs-devel@gnu.org; Fri, 16 Nov 2007 07:25:07 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1It0Ft-0003pC-FR for emacs-devel@gnu.org; Fri, 16 Nov 2007 07:25:07 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1It0Ft-0003p0-8e for emacs-devel@gnu.org; Fri, 16 Nov 2007 07:25:05 -0500 Original-Received: from an-out-0708.google.com ([209.85.132.248]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1It0Ft-0008Eb-0a for emacs-devel@gnu.org; Fri, 16 Nov 2007 07:25:05 -0500 Original-Received: by an-out-0708.google.com with SMTP id c38so176103ana for ; Fri, 16 Nov 2007 04:25:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; bh=dZxZimbdc3wQnW4D9EMfkldcKV11mEwJWH0jHldZvrw=; b=Wg4iFJq0t6aAjjpuuxfaX+N5RmAhvick56+wvYYeHLM2kQLD7GzSPDyY3taTloQllhBGCCcas+joe1hDxeQBrvGZ+J7O1zbdsl54lGny4Y4VBkQV/P4WiyjpdgpolIp2wdrOx0BZcKQw4smzCUvXUhcCKHsuDShck12u5rmixWE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; b=Oiq0nlIBWhdwU+/MhX6hiqDO/5OYazu71nbINig53EFNqfxs6esCvnyUFuvY7U3pUd+5ZuScPlxaXQ84ya43frdN7IQU6FSsRKv8SNxTi1byd0BVRwAdPZYxyOYNt4cD3csJp5qmCLGvmFpIyvVeFrEezw2ybJLnYx3b5AZJ7S8= Original-Received: by 10.100.91.17 with SMTP id o17mr2515418anb.1195215904069; Fri, 16 Nov 2007 04:25:04 -0800 (PST) Original-Received: from ?192.168.0.100? ( [200.208.45.231]) by mx.google.com with ESMTPS id b29sm4087585ana.2007.11.16.04.24.59 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 16 Nov 2007 04:25:00 -0800 (PST) User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.9) Gecko/20071030 SeaMonkey/1.1.6 In-Reply-To: X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:83338 Archived-At: Drew Adams wrote: >>> (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)) >> Yes, this fix the problem. Also it could be made a constant for the number of bits for char like: (defconst glyph-char-bits (if (<= emacs-major-version 22) 19 22) "Specify the number of bits used by a char code in a glyph.") And the code: (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 glyph-char-bits) (- glyph-char-bits)))) (logior char (lsh id glyph-char-bits)) char)) Is there any problem if I implement this solution in trunk and Emacs unicode? > > I'm not really following this, but is this about the change from `19' to > `22' in this code (this is my own version, to accommodate both the old and > new)? > > (defun make-glyph-code (char &optional face) > "Return a glyph code representing char CHAR with face FACE." > (if face > (logior char (lsh (face-id face) > (if (<= emacs-major-version 22) 19 22))) > char)) > > That is, is this related to thread "bug of display-table & make-glyph-code, > 2007-09-10? > No, the problem is this test: (if (and face (<= (face-id face) #xfff)) Which assumes 12 bits for face (constant #xFFF), it should be 10 bits (#x3FF). This test in Emacs unicode should be with #x3F (7 bits). But the solution given by Stefan is better as it is only needed to specify the number of bits used in a char code.