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: Mon, 12 Feb 2018 22:43:08 -0500 Message-ID: <87lgfxo8qb.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> <87po5aoocr.fsf@md5i.com> <87sha6o5ij.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 1518493327 14805 195.159.176.226 (13 Feb 2018 03:42:07 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 13 Feb 2018 03:42:07 +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 Tue Feb 13 04:42:03 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 1elRTg-00033o-I7 for ged-emacs-devel@m.gmane.org; Tue, 13 Feb 2018 04:41:56 +0100 Original-Received: from localhost ([::1]:34992 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elRVi-00059X-7I for ged-emacs-devel@m.gmane.org; Mon, 12 Feb 2018 22:44:02 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41064) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elRUv-00058Z-Fi for emacs-devel@gnu.org; Mon, 12 Feb 2018 22:43:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1elRUr-0004VQ-Ct for emacs-devel@gnu.org; Mon, 12 Feb 2018 22:43:13 -0500 Original-Received: from md5i.com ([75.151.244.229]:37974) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1elRUr-0004Uw-75 for emacs-devel@gnu.org; Mon, 12 Feb 2018 22:43:09 -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=eTlpL4/NfPLbzuylugEIowaNaiT8pn+i+DL0ipLfPgs=; b=fnj2hYpCgMFtJSRXJ/pQ0jRrz+ a6gNH1TwIquD22fJ/xK1URsS3kjnO8oeYiD785aRMSqMfErtr2fP2sb4lU+fKPQyldEhVWaiCoCE+ 0LcAUjt/Bpna7Bj0mnDFD7YzX; Original-Received: from md5i by md5i.com with local (Exim 4.90) (envelope-from ) id 1elRUq-0003BF-Gq for emacs-devel@gnu.org; Mon, 12 Feb 2018 22:43:08 -0500 In-Reply-To: <87sha6o5ij.fsf@mat.ucm.es> (Uwe Brauer's message of "Mon, 12 Feb 2018 11:40:20 +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:222701 Archived-At: Uwe Brauer writes: > > I hacked up the following, which is minimally tested, but may work f= or > > you. I tried to use public functions from quail, but the (null (cdr > > map)) is probably an implementation detail, and might break in a fut= ure > > version. There are almost certainly better ways to write this funct= ion. > > If presented with an ambiguity (like above), it will choose the last > > remembered variant (defaulting to 1). [...] > I tested it with latin-1-pre and it worked, but I tried also > greek-ibycus4 > > And it should translate > > a) to =E1=BC=80 > > But it does not. So I am puzzled. Right. A corner case I missed. Specifically, if the region ends on a key sequence that encodes a valid character, but could be a prefix of another character. (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))) (let* ((map (quail-lookup-key cand)) (def (and map (quail-map-definition map)))) (if def (insert (quail-get-current-str (length cand) def)) (insert cand)))))) --=20 Michael Welsh Duggan (md5i@md5i.com)