From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Michael Welsh Duggan Newsgroups: gmane.emacs.devel Subject: Re: [conversion fails] Date: Sun, 11 Feb 2018 22:53:24 -0500 Message-ID: <87po5aoocr.fsf@md5i.com> References: <878tcbdpf3.fsf@mat.ucm.es> <876078p1gy.fsf@md5i.com> <87tvurldff.fsf@mat.ucm.es> <87wozmnhny.fsf@md5i.com> <8760750vz4.fsf_-_@mat.ucm.es> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1518407809 15922 195.159.176.226 (12 Feb 2018 03:56:49 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 12 Feb 2018 03:56:49 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Feb 12 04:56:45 2018 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 1el5Dy-000251-FG for ged-emacs-devel@m.gmane.org; Mon, 12 Feb 2018 04:56:16 +0100 Original-Received: from localhost ([::1]:35505 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1el5G0-0005c3-0C for ged-emacs-devel@m.gmane.org; Sun, 11 Feb 2018 22:58:20 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56238) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1el5BK-0001U9-CJ for emacs-devel@gnu.org; Sun, 11 Feb 2018 22:53:31 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1el5BF-0004kf-SQ for emacs-devel@gnu.org; Sun, 11 Feb 2018 22:53:29 -0500 Original-Received: from md5i.com ([75.151.244.229]:60592) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1el5BF-0004hc-NB for emacs-devel@gnu.org; Sun, 11 Feb 2018 22:53:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=md5i.com; s=dkim; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID: In-Reply-To:Date:References:Subject:To:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=n40Bda7jo+0MnGUbvBbd2nW1PMGW/wqRl61fZVypEbw=; b=l6/vsJh7UbnZO/9q5syP1UqhTI qQq07YXobN3IH/4HbkU/KNqzBh0zjlUd+xiU8fKL4JAK3Mh1rbXLXD7KFQ5352dZbH+sD0xJUlRgl 79twwAWSQvRLqBFS201HMPsk8; Original-Received: from md5i by md5i.com with local (Exim 4.90) (envelope-from ) id 1el5BE-0002IJ-Ly for emacs-devel@gnu.org; Sun, 11 Feb 2018 22:53:24 -0500 In-Reply-To: <8760750vz4.fsf_-_@mat.ucm.es> (Uwe Brauer's message of "Sat, 10 Feb 2018 15:18:07 +0100") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 75.151.244.229 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:222675 Archived-At: Uwe Brauer writes: > > Uwe Brauer writes: > > > In the unaccentuate case (which is what your original question), it > > should be easy to write that functionality using `quail-find-key' > > as a base. You would have to decide how to handle failures > > (character can't be typed using the current input method). > > Actually taking iso-accentuate and un accuate as a reference it is the > accentuate part which I want to implement, for example > for the greek-ibycus > > I want to replace a) by =E1=BC=80 Okay. > > The accentuate case looks more difficult. Quail allows more than one > > translation candidate for a single key sequence, which leaves no good > > I am puzzled now, I thought any input method should be an bijection. So > the old iso method was, wasn't it? Not all input methods are bijections. Especially not many of the Asian input methods. > > way handle these characters. A simple example from the ipa input > > method: tsh can translate into =CA=A7, t=CA=83, or t=E2=81=80=CA=83. > > I tried that out, but I obtain =CA=A7 none of the others. Really? Try typing the following using the ipa input method: tsh1tsh2tsh3 The number selects the specific form. If something else it typed rather than the number, it will use the last remembered version, defaulting to version 1. I hacked up the following, which is minimally tested, but may work for you. I tried to use public functions from quail, but the (null (cdr map)) is probably an implementation detail, and might break in a future version. There are almost certainly better ways to write this function. If presented with an ambiguity (like above), it will choose the last remembered variant (defaulting to 1). (defun accentuate-region (start end) "Replace the region by using it as keys using the current input method" (interactive "r") (save-excursion=20 (goto-char start) (let* ((data (delete-and-extract-region start end)) (size (length data)) (idx 0) (cand "")) (while (< idx size) (let* ((next-cand (concat cand (list (aref data idx)))) (map (quail-lookup-key next-cand)) (def (and map (quail-map-definition map)))) (if (null map) (progn (insert next-cand) (setq cand "")) (if (and def (null (cdr map))) (progn (insert (quail-get-current-str (length next-cand) def)) (setq cand ""))=20 (setq cand next-cand))) (incf idx))) (insert cand)))) --=20 Michael Welsh Duggan (md5i@md5i.com)