Yeis, pronounced yes, is a more advanced input method switcher for Emacs.
It pretends to:
- Translate text to and from non-CJK input methods;
- Auto translate and auto select input methods (yeis-mode).
Let’s see it in action, for the sake of clarity. I’ll be demonstrating it with the russian input method selected (ЙЦУКЕН).
Translate the current word, to one to the left of the cursor, by calling
yeis-translate-current-word
. You can either call it with M-x or you can set bind it
to a key, such as C-| (see instructions below).
When you pass a prefix argument n, it translates the last n words.
The following commands are equivalent ways to translating 3 words that come before the cursor.
- M-3 C-|
- C-u 3 C-|
Notice that you can always toggle your input method by calling
toggle-input-method
(C-\).
By activating yeis-mode, you’ll get auto translation and auto input method selection. It follows a DWIM (do-what-I-mean) philosophy.
Note that this is still under development, therefore unwanted behavior will
certainly happen. You can always call translate-current-word
to make the
necessary corrections.
git clone https://github.com/aadcg/emacs-yeis.git
Add the following to your init.el:
;; yeis main file
(load-file "/fullpath/to/yeis.el")
;; input methods' definitions
(load-file "/fullpath/to/robin-packages.el")
;; loads the defined input methods
(load-file "/fullpath/to/x-leim-list.el")
;; activate the desired input method, for instance robin-russian
(setq default-input-method "robin-russian")
(setq-default robin-current-package-name "robin-russian")
;; this is necessary if you want to use yeis minor mode
(setq yeis-path-plain-word-list "/fullpath/to/wordlist/of/this/repo")
;; since C-\ is bind to `toggle-input-method', this seems a good choice
(global-set-key (kbd "C-|") 'yeis-translate-current-word)
At the moment the following input methods are supported:
- US qwerty <-> russian ЙЦУКЕН
- US dvorak <-> russian ЙЦУКЕН
- US workman <-> russian ЙЦУКЕН
- US querty <-> Greek
It’s trivial to add more. Let me know about your needs or, better yet, send me a patch.
Please note that I have only tested yeis-mode for the first one on the above list.
- Add support for more input methods out of the box (trivial task);
- Improve yeis-mode (namely it should take into account that users can make typos);
- Write unit tests (following a property-based philosophy);
- Write integration tests with the most common words;
- Better integration with GNU Aspell (can it check if a certain prefix exists in a given dictionary?)
If your way of life is to live inside of Emacs, then you know how annoying it is when you select a non QWERTY input method in your OS. Say you have the russian input method active. Then you go to Emacs, you hit C-g and the minibuffer greets you with:
C-п is undefined
Emacs wants us to have a QWERTY input method enabled. When in need of another
one, we should make use of its multilingual features (M-x set-input-method
).
That way, keybindings will still work since keypresses prefixed by Meta or
Control are escaped (i.e. not translated). On the other hand, it is a fact that
we can’t (yet) do everything in Emacs. So, until that day of plenitude comes, we
shall need to change the input method in the operating system we’re running (say
you want to write in Russian in your browser). A possible solution is to use
IBus (the default input method framework for GNOME). Out of the box, you get
input methods selected per application. Sweet! Some people have totally
different approaches - take a look at reverse-im and fix-input. I shall not even
go in there.
Let’s now talk about input methods within Emacs. It supports insertion of multilingual text through Quail (have a look at quail.el) - indeed, a beautiful piece of software, but it inherits unnecessary complexity when the users don’t use a CJK input method. I found out is that there’s a lighter alternative to Quail - Robin. The latter, provides translation to and from any (non-CJK) input method out of the box!
What Yeis wants to achieve within Emacs might be comparable to what xneur achieves for GNU/Linux.
John Lawler for this english wordlist.
vlarya2 for this russian wordlist.
Everyone at the Emacs (english) Telegram group.