From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kenichi Handa Newsgroups: gmane.emacs.devel Subject: Re: bug of display-table & make-glyph-code Date: Fri, 07 Sep 2007 21:25:41 +0900 Message-ID: References: <200708271732.22306.zslevin@gmail.com> <46DD9F41.8090700@gmx.at> <87bqch1nhz.fsf@kfs-lx.testafd.dk> NNTP-Posting-Host: lo.gmane.org X-Trace: sea.gmane.org 1189167972 10653 80.91.229.12 (7 Sep 2007 12:26:12 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 7 Sep 2007 12:26:12 +0000 (UTC) Cc: zslevin@gmail.com, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Sep 07 14:26:12 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 1ITcuZ-0006TB-RV for ged-emacs-devel@m.gmane.org; Fri, 07 Sep 2007 14:26:12 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ITcuY-0007AX-Lu for ged-emacs-devel@m.gmane.org; Fri, 07 Sep 2007 08:26:10 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1ITcuU-0007A0-16 for emacs-devel@gnu.org; Fri, 07 Sep 2007 08:26:06 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ITcuQ-00078d-NN for emacs-devel@gnu.org; Fri, 07 Sep 2007 08:26:05 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ITcuQ-00078S-9U for emacs-devel@gnu.org; Fri, 07 Sep 2007 08:26:02 -0400 Original-Received: from mx1.aist.go.jp ([150.29.246.133]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1ITcuG-0004JV-5v; Fri, 07 Sep 2007 08:25:57 -0400 Original-Received: from rqsmtp1.aist.go.jp (rqsmtp1.aist.go.jp [150.29.254.115]) by mx1.aist.go.jp with ESMTP id l87CPg08012088; Fri, 7 Sep 2007 21:25:42 +0900 (JST) env-from (handa@m17n.org) Original-Received: from smtp3.aist.go.jp by rqsmtp1.aist.go.jp with ESMTP id l87CPgrc015293; Fri, 7 Sep 2007 21:25:42 +0900 (JST) env-from (handa@m17n.org) Original-Received: by smtp3.aist.go.jp with ESMTP id l87CPfq8029801; Fri, 7 Sep 2007 21:25:41 +0900 (JST) env-from (handa@m17n.org) Original-Received: from handa by etlken.m17n.org with local (Exim 4.67) (envelope-from ) id 1ITcu5-0003t8-Nx; Fri, 07 Sep 2007 21:25:41 +0900 In-reply-to: (message from Eli Zaretskii on Fri, 07 Sep 2007 11:47:17 +0300) X-Detected-Kernel: Solaris 8 (1) 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:78146 Archived-At: In article , Eli Zaretskii writes: > > From: Kenichi Handa > > Date: Fri, 07 Sep 2007 14:11:35 +0900 > > Cc: rgm@gnu.org, zslevin@gmail.com, rms@gnu.org, rudalics@gmx.at, > > emacs-devel@gnu.org > > > > I started to study the glyph related codes, and ran into the > > function create-glyph (disp-table.el). It is a strange > > function, and I don't understand how to utilize it. Could > > someone please explain it? > I'm not sure what is there to explain, since the code looks quite > self-explanatory, if read in together with the "Glyphs" node in the > ELisp manual. Perhaps I'm missing something; if the below doesn't > help, please ask specific questions. Thank you very much for the detailed explanation. That is exactly what I just understood from the code. But, then, it seems that the design is broken (or got broken because of introduction of multibyte characters). It grows glyph-table one by one. So, at some point a glyph code is simply a character code, but after several calls of create-glyph, that same glyph code becomes an index into glyph-table, and is displayed differently. That means that we can't reliably store a vector of non-ASCII characters (>= U+100) in a slot of display-table. In addition, the docstring of buffer-display-table says that each element is a vector of characters (or nil). It doesn't say that contents of the vector is actually regarded as a glyph code. The Glyphs node of info says this: ---------------------------------------------------------------------- A glyph is represented in Lisp as a "glyph code". A glyph code can be "simple" or it can be defined by the "glyph table". A simple glyph code is just a way of specifying a character and a face to output it in. *Note Faces::. The following functions are used to manipulate simple glyph codes: -- Function: make-glyph-code char &optional face This function returns a simple glyph code representing char CHAR with face FACE. ---------------------------------------------------------------------- But, for instance, the return value of (make-glyph-code 256) is a simple glyph or not depending on the current length of glyph-table. --- Kenichi Handa handa@m17n.org > `create-glyph' is used on a character terminal to create a glyph that > is displayed instead of some character C. The way you use it is like > this: > (aset standard-display-table c > (vector (create-glyph (concat "\e(0" (char-to-string gc) "\e(B"))))) > This sets up the slot for C in standard-display-table to send to the > terminal the string `(concat "\e(0" (char-to-string gc) "\e(B")))' > (where GC is a code of some other character). > standard-display-table needs an integer code of a glyph to put in the > slot used to display C. Therefore, `create-glyph' returns such an > integer, which is an index into a glyph table. In the glyph table, > the first 256 slots are left unused, to avoid affecting the ASCII and > unibyte non-ASCII ranges. Starting from entry #256 (zero-based), > `create-glyph' adds a new entry for its argument (which is a string to > be sent to the terminal when a specific character is displayed), and > stores that string argument in glyph-table. > Thereafter, when character C is to be displayed, Emacs will look it up > in standard-display-table and see that its slot has a glyph index. > Emacs will then look up that index's slot in glyph-table, fetch the > string stored at that slot, and send the string to the terminal. > Presumably, the string uses character terminal escape sequences to > produce the desired effect, such as underlining the character etc. > Did I manage to answer your question? > _______________________________________________ > Emacs-devel mailing list > Emacs-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-devel