Lazy timer based display of things to learn. Ability to recall and translate with presistance across sessions.

lazy-lang-learn.el periodic display of new snippet to translate

Defines a new minor-mode lazy-lang-learn-mode which calls out to lazy-lang-learn--function for a new snippet and displays it with lazy-lang-learn--display-function. Stores it in lazy-lang-learn--history which can be browsed and translated via lazy-lang-learn--translate-from-history. Newly displayed snippets can be immediately translated using lazy-lang-learn-translate.

Screencast

A short video of lazy-lang-learn hosted on YouTube demonstrating it's usage. The first few seconds are blurred. No idea why but the rest is ok…

ffmpeg -video_size 1920x1080 -framerate 25 -f x11grab -i :0.0+0,0 output.mp4

Screenshots

A new snippet pops after lazy-lang-learn--period

img

translate it with lazy-lang-learn-translate

img

translate older snippets with lazy-lang-learn-translate-from-history

img

requirements

google-translate

This whole thing is based around using google-translate, a package that allows you to translate strings using Google Translate service directly from GNU Emacs. I have some customisations to this which can be found under my own emacs configuration in rgr/google.el

alert

The default lazy-lang-learn--display-function is set to 'alert. See alert.

fortunes-de

Debian comes with fortunes-de which is the default snippet generator used by lazy-lang-learn--function default function lazy-lang-learn--german-fortune.

sudo apt install fortunes-de

usage

C-u lazy-lang-learn-translate will translate a random snippet from the history.

(use-package lazy-lang-learn
  :straight (lazy-lang-learn :local-repo "~/development/projects/emacs/lazy-lang-learn" :type git :host github :repo "rileyrg/lazy-lang-learn" )
  :bind
  ("C-c L" . lazy-lang-learn-mode)
  ("<f12>" . lazy-lang-learn-translate) ;; C-u f12 to translate a random history element.
  ("C-S-<f12>" . lazy-lang-learn-translate-random) ;; same as C-u lazy-lang-learn-translate
  ("S-<f12>" . lazy-lang-learn-translate-from-history))

key functions

  • lazy-lang-learn-new

    display a new snippet

  • lazy-lang-learn-translate

    translate last snippet displayed or translated. Prefix (C-u) to pick a random one from history.

  • lazy-lang-learn-translate-random

    translates a random element from history - calls lazy-lang-learn-translate

  • lazy-lang-learn-translate-from-history

    interactively select from history and translate

customisation

Customisation group lazy-lang-learn

lazy-lang-learn--period

Idle time in seconds before it fetches a new snippet to display

lazy-lang-learn--function

Holds the name of a function to return snippets to store and later translate. Currently defaults to lazy-lang-learn--german-fortune which simply calls out to the shell to get a unix fortune snippet…

(defun lazy-lang-learn--german-fortune()
  "Return a german fortune string."
  (shell-command-to-string "fortune de"))

lazy-lang-learn--display-function

Holds the name of a function to display new snippets to browse. Defaults to alert.

lazy-lang-learn--history-length

How many snippets to keep and save in lazy-lang-learn--history-file

lazy-lang-learn--history-file

The file used to store language snippets.

lazy-lang-learn--lighter

The minor mode indicator in the mode line.

TODO

have the minor mode timer pop up existing ones from the history if so configured.

hot key to remove immediately last snippet

delete from history

migrate the history format to an org file maybe so add things like view count etc etc

DONE random translate from history :ARCHIVE: