unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Filipp Gunbin <fgunbin@fastmail.fm>
To: "André A. Gomes" <andremegafone@gmail.com>
Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org, perry@piermont.com
Subject: Re: How do you write input methods?
Date: Wed, 01 Sep 2021 20:50:04 +0300	[thread overview]
Message-ID: <m2wno0b2yb.fsf@fastmail.fm> (raw)
In-Reply-To: <87fsuqofoo.fsf@gmail.com> ("André A. Gomes"'s message of "Mon, 30 Aug 2021 23:12:07 +0300")

FWIW, I use this (hack?) to employ available input methods for
transliteration.

Filipp

--8<---------------cut here---------------start------------->8---
(defun fg-dotemacs-translit (str input-method)
  (with-temp-buffer
    (let ((input-method-verbose-flag nil)
          res)
      (activate-input-method input-method)
      (discard-input)
      (setq unread-command-events
            ;; add newline so input method doesn't wait for more input
            ;; in case of multiple translation possibilities
            (listify-key-sequence (concat str "\n")))
      (while (input-pending-p)
        (push (read-char nil t) res))
      (concat (reverse
               ;; don't forget to remove newline
               (cdr res))))))


(ert-deftest fg-dotemacs-translit-test()
  (should (equal "русский" (fg-dotemacs-translit "russkij" "cyrillic-translit")))
  ;; `u' / `sh' may have different completions
  (should (equal "гу" (fg-dotemacs-translit "gu" "cyrillic-translit")))
  (should (equal "ш" (fg-dotemacs-translit "sh" "cyrillic-translit"))))
--8<---------------cut here---------------end--------------->8---



  parent reply	other threads:[~2021-09-01 17:50 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-30  1:10 How do you write input methods? Perry E. Metzger
2021-08-30 11:15 ` Stephen Berman
2021-08-30 11:24   ` Joost Kremers
2021-08-30 11:48     ` Stephen Berman
2021-08-30 16:23       ` Perry E. Metzger
2021-08-30 20:26         ` Stephen Berman
2021-08-30 11:46 ` Eli Zaretskii
2021-08-30 13:40   ` Perry E. Metzger
2021-08-30 14:00     ` Eli Zaretskii
2021-08-30 14:22       ` Perry E. Metzger
2021-08-30 15:43         ` Eli Zaretskii
2021-08-30 16:24           ` Perry E. Metzger
2021-08-30 14:29 ` André A. Gomes
2021-08-30 15:54   ` Eli Zaretskii
2021-08-30 20:12     ` André A. Gomes
2021-08-31 12:02       ` Eli Zaretskii
2021-09-01 17:50       ` Filipp Gunbin [this message]
2021-09-01 17:57         ` Eli Zaretskii
2021-09-01 20:33           ` Filipp Gunbin
2021-09-02  6:23             ` Eli Zaretskii
2021-09-02  6:34               ` tomas
2021-09-03  0:59                 ` Michael Welsh Duggan
2021-09-03  6:10                   ` tomas
2021-09-02 10:47               ` Filipp Gunbin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2wno0b2yb.fsf@fastmail.fm \
    --to=fgunbin@fastmail.fm \
    --cc=andremegafone@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=perry@piermont.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).