[Top][All Lists]

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

Re: [conversion fails]

From: Uwe Brauer
Subject: Re: [conversion fails]
Date: Tue, 13 Feb 2018 09:43:56 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

    > 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.

    > (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


reply via email to

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