I am trying to learn the Japanese language. I want to able to read some Gundam novels and what not, I'm using SRS to do that, and this stuff helps out.
Emacs functions for studying Japanese
jisho-this
aka cce/jisho-at-point
will open up Jisho with the word under point
searched.
SPC SPC jisho RET
will open the kanji
at point in Jisho.
require 'thingatpt)
(require 'org-collector)
(
'jisho-this 'cce/jisho-at-point)
(defalias
defun cce/jisho-at-point ()
(
(interactive)let ((chr (thing-at-point 'word)))
(format "https://jisho.org/search/%s" chr))))
(browse-url (
Configure Emacs to use the IPAex fonts instead of Unifont:
defun cce/enable-ipaex-font (&optional size)
(
(interactive)dolist (charset '(kana han cjk-misc bopomofo))
(nil 'font) charset
(set-fontset-font (frame-parameter "IPAexGothic" :size (or size 36)))))
(font-spec :family
provide 'cce/japanese-study) (
Using jisho-api to populate SRS cards
{ pkgs, ... }:
{
fonts.fonts = [ pkgs.ipaexfont ];
environment.systemPackages = [ pkgs.jisho-api ];
}
jisho search kanji 実
to make a new card, start with a second-level heading with only the
character at point * 田
. The first level
is usually something to capture tags since org-fc will inherit
tree tags, but not FILETAGS.
invoking cce/template-kanji-card
at
that character's point will populate a card with Kunyomi and Onyomi readings,
optionally with cloze format. Finish them up, and then make sure to
initialize the cards. It's a lot quicker than doing this all by
hand.
defun cce/template-kanji-card--extract-readings (buf)
(
(with-current-buffer buf
(goto-char (point-min))"[Kun: " (group (one-or-more (not "]"))) "]"
(search-forward-regexp (rx " | [On: " (group (one-or-more (not "]"))) "]"))
list (s-split ", " (match-string 1))
(", " (match-string 2)))))
(s-split
defun cce/template-kanji-card--insert-readings (readings type-id)
("*** [[id:" type-id "][" type-id "]] readings\n")
(insert if (= (length readings) 1)
(first readings) "\n")
(insert (dolist (cloze (--map-indexed
("- {{" it "}@" (number-to-string it-index) "}" "\n")
(concat
readings))
(insert cloze))))
defun cce/template-kanji-card ()
(
(interactive)
(save-excursionlet* ((char (thing-at-point 'word t))
(format "jisho search kanji %s" char))
(cmd (" *jisho-card*")
(buf
(ret (shell-command cmd buf)))
(pcase-let ((`(,kuns ,ons) (cce/template-kanji-card--extract-readings buf)))1)
(evil-open-below
(mark)"kunyomi")
(cce/template-kanji-card--insert-readings kuns "onyomi")
(cce/template-kanji-card--insert-readings ons
(pop-mark) (evil-normal-state)))))
Show Hiragana and Katakana as eldoc
This is a fun little hack: show the name of hiragana and katakana when I point over them. Eldoc is enabled in my Basic Emacs Coding Config and here I am using it outside of code!
'org
(with-eval-after-load defun cce/eldoc-jhk (&rest args)
(when (looking-at "[ぁ-ヿ]")
('char)) 'name)))
(get-char-code-property (string-to-char (thing-at-point
defun cce/eldoc-jhk-setup ()
('eldoc-documentation-functions
(add-hook #'cce/eldoc-jhk nil t))
'org-mode-hook #'cce/eldoc-jhk-setup)) (add-hook
jisho-api
Python nixpkgs
{ pkgs ? import <nixpkgs> {},
python ? pkgs.python39 }:
{
python.pkgs.buildPythonPackage name = "jisho-api";
version = pkgs.lib.pkgVersions.jisho-api.version;
format = "pyproject";
inherit python;
src = pkgs.callPackage pkgs.lib.pkgVersions.jisho-api.src {};
postPatch = ''
substituteInPlace pyproject.toml \
--replace 'rich = "^10.11.0"' 'rich = ">12.0.0"' \
--replace 'bs4 = "^0.0.1"' 'beautifulsoup4 = "^4.11.1"'
'';
propagatedBuildInputs = with python.pkgs; [
poetry-core
click pydantic requests rich beautifulsoup4];
}