From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?Q?Cl=c3=a9ment_Pit-Claudel?= Newsgroups: gmane.emacs.devel Subject: Re: Converting compositions to strings Date: Mon, 30 Jan 2017 11:39:09 -0500 Message-ID: References: <83a8a8y3s8.fsf@gnu.org> 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 1485794513 24553 195.159.176.226 (30 Jan 2017 16:41:53 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 30 Jan 2017 16:41:53 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jan 30 17:41:49 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 1cYF1U-00066i-Ix for ged-emacs-devel@m.gmane.org; Mon, 30 Jan 2017 17:41:44 +0100 Original-Received: from localhost ([::1]:33738 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cYF1a-0003m2-4A for ged-emacs-devel@m.gmane.org; Mon, 30 Jan 2017 11:41:50 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56050) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cYEz1-0002dA-Sl for emacs-devel@gnu.org; Mon, 30 Jan 2017 11:39:12 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cYEz1-00044B-1R for emacs-devel@gnu.org; Mon, 30 Jan 2017 11:39:11 -0500 Original-Received: from mail-qk0-x243.google.com ([2607:f8b0:400d:c09::243]:34065) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cYEz0-00043z-T6; Mon, 30 Jan 2017 11:39:10 -0500 Original-Received: by mail-qk0-x243.google.com with SMTP id e1so19687912qkh.1; Mon, 30 Jan 2017 08:39:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=tT4+4r2+UzJFuPuRQ2Hqv8CilkjBzciNtO054g9srlQ=; b=eFK/8x+w9BncvkDunwrw83yVQLnTWuCVdFS4yX+EsVjAXT+P9zgBc1zddmVzobn8Zy tu1G4TMZDGheXN7WFDd/3PfEs3ke6sTxeb18gHQ3+A+5yzLPwKeZlnlCGj9W6q/oGFWn PCE0CC90Q3/2WefIzQy1CNQKsKU9ej4uhR59DK+JpPmC6fCx4mEeqVEiAEA6koLLwMCT kEE16DUBiMUJUlhp31peT3GwXkePK7QEJ1+TSTHEoE5Rs5pWcpdxCGRL/7JtI2ALykiI Eaomr/+o76+ehTOFOGWrtZecrub0CEyk7Li9Zy+/9/TB4Gmjm+Y7FWuku8xu/WMpnmZz GzCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=tT4+4r2+UzJFuPuRQ2Hqv8CilkjBzciNtO054g9srlQ=; b=N1W5HQ2xgXksn9/DpAEydphVxqZDcnuYuLlTTfdYWzs+McJ7cvc2VF3QLPJTXuCx76 dSVeq3P4WmD7VGB0+tb/FZ/Sg2c4sRMAg6YQEyoGuogj81iOUhHCWqDUNKgh2KiF0XBD kVhYcPzV4JrIjymm/wTBgO3Rfz4EbB40BnHNQaC66H+yDmPIbK3vnYiU68QuaCr/bz6y rAWBPf46uuFZszJwAKstq9Lk2SIc+H6HLf26KTf5w4leUyKocD0tQEcgMwm8RK++yn4e DpKw/limzMvz9nCzaKEvSAIINOlCI/L+5wQUrpOqDgPwzZkTO2spBUpV+LWaSJFfyihg XPqQ== X-Gm-Message-State: AIkVDXLG1ehVPDB4GP69s4jqZ2AdG7+KcCzJO3guXScIhs7nEvVxk/KMJqQedAgVhOd72w== X-Received: by 10.55.98.5 with SMTP id w5mr21598668qkb.165.1485794350095; Mon, 30 Jan 2017 08:39:10 -0800 (PST) Original-Received: from ?IPv6:2001:470:8b2d:1a:9bab:c177:73b2:20a9? ([2001:470:8b2d:1a:9bab:c177:73b2:20a9]) by smtp.gmail.com with ESMTPSA id c83sm12657198qkg.8.2017.01.30.08.39.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Jan 2017 08:39:09 -0800 (PST) In-Reply-To: <83a8a8y3s8.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c09::243 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:211770 Archived-At: 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? >> Is there a recipe that I can use to construct a string >> representation of a composition? (I realize that many compositions >> can't adequately be represented as plain strings; I'm only >> interested in those that can). > > 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))) Thanks, Clément.