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: Sun, 11 Feb 2018 22:53:24 -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:
>
>    > 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  ἀ

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 ʧ, tʃ, or t⁀ʃ.
>
> I tried that out, but I obtain  ʧ 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 
    (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)))
      (insert cand))))

-- 
Michael Welsh Duggan
(address@hidden)



reply via email to

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