emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [conversion fails]


From: Michael Welsh Duggan
Subject: Re: [conversion fails]
Date: Tue, 13 Feb 2018 15:58:35 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Uwe Brauer <address@hidden> writes:

>    > Uwe Brauer <address@hidden> 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.
>
> I cried victory to earlier, there seems more corner cases.
>
> Take the following examples
>
> 1 )En a)rxh=| h)=n o( lo'gos, kai` o( lo'gos h)=n pro`s to`n qeo'n,
> kai` qeo`s h)=n o( lo'gos.
>
> Should be translated to 
> 1 Ἐν ἀρχῇ ἦν ὁ λόγος, καὶ ὁ λόγος ἦν πρὸς τὸν θεόν, καὶ θεὸς ἦν ὁ
> λόγος.

Yup.  This version seems to do the trick, though:

(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 "") map def)
      (while (< idx size)
        (let* ((candx (concat cand (list (aref data idx))))
               (mapx (quail-lookup-key candx))
               (defx (and mapx (quail-map-definition mapx))))
          (if (null mapx)
              (if def
                  (progn
                    (insert (quail-get-current-str (length cand) def))
                    (setq cand "" map nil def nil)
                    (decf idx))
                (insert candx)
                (setq cand "" map nil def nil))
            (if (and defx (null (cdr mapx)))
                (progn
                  (insert (quail-get-current-str (length candx) defx))
                  (setq cand "" map nil def nil))
              (setq cand candx map mapx def defx)))
          (incf idx)))
      (if def
          (insert (quail-get-current-str (length cand) def))
        (insert cand)))))

I'll work on the inverse function in a bit.

-- 
Michael Welsh Duggan
(address@hidden)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]