Giter Site home page Giter Site logo

emacs-yeis's Introduction

Overview

Yeis, pronounced yes, is a more advanced input method switcher for Emacs.

It pretends to:

  1. Translate text to and from non-CJK input methods;
  2. Auto translate and auto select input methods (yeis-mode).

Demo

Let’s see it in action, for the sake of clarity. I’ll be demonstrating it with the russian input method selected (ЙЦУКЕН).

Manual Translation

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

screenshots/screenshot_manual.gif

Yeis-mode

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.

screenshots/screenshot_yeismode.gif

Quickstart

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)

Input methods

At the moment the following input methods are supported:

  1. US qwerty <-> russian ЙЦУКЕН
  2. US dvorak <-> russian ЙЦУКЕН
  3. US workman <-> russian ЙЦУКЕН
  4. 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.

Roadmap

  • 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?)

Rant about input methods

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.

Thanks

John Lawler for this english wordlist.

vlarya2 for this russian wordlist.

Everyone at the Emacs (english) Telegram group.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.