From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Converting compositions to strings Date: Mon, 30 Jan 2017 18:52:00 +0200 Message-ID: <83y3xswkwf.fsf@gnu.org> References: <83a8a8y3s8.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1485795144 14089 195.159.176.226 (30 Jan 2017 16:52:24 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 30 Jan 2017 16:52:24 +0000 (UTC) Cc: emacs-devel@gnu.org To: =?utf-8?Q?Cl=C3=A9ment?= Pit-Claudel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jan 30 17:52:20 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cYFBk-0003WA-L5 for ged-emacs-devel@m.gmane.org; Mon, 30 Jan 2017 17:52:20 +0100 Original-Received: from localhost ([::1]:33800 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cYFBq-0002oI-4z for ged-emacs-devel@m.gmane.org; Mon, 30 Jan 2017 11:52:26 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59445) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cYFBf-0002mj-A6 for emacs-devel@gnu.org; Mon, 30 Jan 2017 11:52:16 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cYFBc-0008UR-9Z for emacs-devel@gnu.org; Mon, 30 Jan 2017 11:52:15 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:33053) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cYFBc-0008UN-6E; Mon, 30 Jan 2017 11:52:12 -0500 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4123 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1cYFBa-0000E1-VV; Mon, 30 Jan 2017 11:52:11 -0500 In-reply-to: (message from =?utf-8?Q?Cl=C3=A9ment?= Pit-Claudel on Mon, 30 Jan 2017 11:39:09 -0500) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:211771 Archived-At: > Cc: emacs-devel@gnu.org > From: Clément Pit-Claudel > Date: Mon, 30 Jan 2017 11:39:09 -0500 > > On 2017-01-30 10:18, Eli Zaretskii wrote: > > The information about this can be found in the doc strong of > > compose-region, under COMPONENTS. > > Thanks. This covers only "relative" compositions, right? Is there more information on non-relative compositions somewhere? No, AFAIK this documents both relative and rule-based compositions. > > The ones that seem to be relevant to what you are looking for (I'm > > guessing) are a small class, and I don't think you can discern them > > from the others unless you look at the "rules" parts of a > > composition. > > Looking at the rules sounds fine; thanks! I think these compositions form a small class in terms of what Emacs supports, but that class seems to most if not all uses of composition that I see in my daily use of Emacs (where are other compositions used, beyond character spacing in what-cursor-position?). > > Based on your pointers, the following seems to work OK for me (I guess it could be extended to cover the (Bl . Br) case, but I haven't seen that pop up yet in practice). > > (defun esh--parse-composition (components) > "Translate composition COMPONENTS into a string." > (let ((chars (list (aref components 0))) > (nrules (/ (length components) 2))) > (dotimes (nrule nrules) > (let* ((rule (aref components (+ 1 (* 2 nrule)))) > (char (aref components (+ 2 (* 2 nrule))))) > (pcase rule > (`(Br . Bl) (push char chars)) > (_ (error "Unsupported composition COMPONENTS"))))) > (concat chars))) I think if we want to be able to produce text with all the text properties and overlays expressed explicitly as text, we need to write a back-end for xdisp.c that "displays" to a buffer. It shouldn't be hard, the number of interface routines a back-end needs to support is not large; see 'struct redisplay_interface' in dispextern.h.