From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Uwe Brauer Newsgroups: gmane.emacs.devel Subject: Re: [conversion fails] Date: Tue, 13 Feb 2018 09:43:56 +0100 Message-ID: <87r2ppl1o3.fsf@mat.ucm.es> 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> <87lgfxo8qb.fsf@md5i.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1518511429 2545 195.159.176.226 (13 Feb 2018 08:43:49 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 13 Feb 2018 08:43:49 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.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 09:43: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 1elWBJ-0007C9-AP for ged-emacs-devel@m.gmane.org; Tue, 13 Feb 2018 09:43:17 +0100 Original-Received: from localhost ([::1]:56686 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elWDK-0008BF-Vv for ged-emacs-devel@m.gmane.org; Tue, 13 Feb 2018 03:45:23 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43798) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elWCU-0008Ah-2k for emacs-devel@gnu.org; Tue, 13 Feb 2018 03:44:31 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1elWCQ-0004Ea-RC for emacs-devel@gnu.org; Tue, 13 Feb 2018 03:44:30 -0500 Original-Received: from [195.159.176.226] (port=59906 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1elWCQ-0004Bp-Ij for emacs-devel@gnu.org; Tue, 13 Feb 2018 03:44:26 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1elWAG-0003EJ-4w for emacs-devel@gnu.org; Tue, 13 Feb 2018 09:42:12 +0100 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: emacs-devel@gnu.org Original-Lines: 54 Original-X-Complaints-To: usenet@blaine.gmane.org Mail-Copies-To: never Cancel-Lock: sha1:93S3eU+05qzpkz6oP1Zi6R7e2oY= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 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:222706 Archived-At: > Uwe Brauer writes: > [...] > 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 > (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 "")) > (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)))))) Great, that looks very very promising. I will run various test cases and come back when I finished. Maybe that code should make it, perhaps with a different name, into quail.el? I have to admit that this code is beyond me, while I more or less understood the original iso-accentuate code, which worked with tables. A last question then, for the sake of completion: you said the inverse function would be trivial. In the case of the original iso-accentuate it was. Would it be here as well? But as I said in my earlier mail I am very happy with the accentuate version. Thanks a zillon Uwe