Skip to content

takeokunn/nskk.el

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

200 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NSKK — Next-generation SKK for Emacs

https://github.com/takeokunn/nskk.el/actions/workflows/ci.yml/badge.svg https://img.shields.io/badge/License-GPL%20v3-blue.svg

Overview

NSKK is a modern, zero-dependency Japanese input method for Emacs built on SKK (Simple Kana to Kanji) principles. It delivers:

  • Clean architecture — 7-layer modular design with full lexical-binding
  • DDSKK compatibility — Familiar keybindings and behavior
  • Extensible — Embedded Prolog engine for customizable conversion logic

NSKK = Next-generation SKK = 次世代 SKK

Features

Zero Dependencies

Only Emacs 29.1+ built-in packages:

  • cl-lib (Emacs 24.3+)
  • subr-x (Emacs 24.4+)

No external ELPA packages required.

Modern Architecture

ComponentDescription
Lexical bindingAll 25 modules use lexical-binding: t
Prolog engineConversion rules as facts/queries
Layer separation7 strict layers, zero circular deps
Test coverage5,000+ unit/integration/E2E tests

DDSKK Compatibility

  • Same keybindings (C-j, SPC, x, q, l, etc.)
  • Same mode indicators (かな, カナ, SKK, 全英, aA)
  • Same dictionary format (SKK-JISYO)
  • Same conversion markers (▽ for preedit, ▼ for conversion)

Installation

use-package

(use-package nskk
  :vc (:url "https://github.com/takeokunn/nskk.el" :rev :newest
       :lisp-dir "src")
  :custom
  (nskk-dict-system-dictionary-files
   '("/usr/share/skk/SKK-JISYO.L"))
  :config
  (nskk-global-mode 1))

Quick Start

Minimal Configuration

(require 'nskk)
(nskk-global-mode 1)

;; NSKK uses Emacs's built-in ja-dic by default when available.
;; You can still override it with `nskk-dict-system-dictionary-files'.

;; After nskk-global-mode is enabled:
;; C-j       → switch to hiragana input (from ascii mode)
;; C-x C-j   → toggle nskk-mode on/off in current buffer

With System Dictionary

;; Debian/Ubuntu: apt install skktools
;; macOS: brew install skk-jisyo
;; NixOS: environment.systemPackages = [ skk-jisyo ];

(setopt nskk-dict-system-dictionary-files
        '("/usr/share/skk/SKK-JISYO.L"
          "/usr/share/skk/SKK-JISYO.jinmei"
          "/usr/share/skk/SKK-JISYO.geo"))
(nskk-global-mode 1)

Recommended Configuration

(use-package nskk
  :vc (:url "https://github.com/takeokunn/nskk.el" :rev :newest
       :lisp-dir "src")
  :custom
  ;; Start in hiragana mode (optional, default is ascii)
  (nskk-state-default-mode 'hiragana)

  ;; System dictionaries
  (nskk-dict-system-dictionary-files
   '("/usr/share/skk/SKK-JISYO.L"))

  ;; User dictionary location
  (nskk-dict-user-dictionary-file "~/.nskk/jisyo")

  ;; Show candidate list after 2nd SPC (default: 5)
  (nskk-henkan-show-candidates-nth 2)

  ;; Enable dictionary caching
  (nskk-dict-cache-enabled t)

  ;; AZIK romaji style (optional)
  ;; (nskk-converter-romaji-style 'azik)

  :config
  (nskk-global-mode 1))

Usage

Mode Switching

FromKeyToIndicator
AnyC-x C-jToggle on/off
asciiC-jhiraganaかな
hiraganaqkatakanaカナ
hiraganalasciiSKK
hiraganaLfull-width全英
hiragana/abbrevaA

Conversion Flow

stateDiagram-v2
    [*] --> ASCII: nskk-global-mode (default)

    ASCII --> Hiragana: C-j
    Hiragana --> ASCII: l
    Hiragana --> Katakana: q
    Hiragana --> FullWidth: L
    Hiragana --> Abbrev: slash
    Abbrev --> Conversion: SPC
    Abbrev --> Hiragana: C-j / C-g

    Katakana --> Hiragana: q
    Katakana --> Hiragana: C-j
    Katakana --> ASCII: l

    FullWidth --> Hiragana: C-j

    Hiragana --> Preedit: Uppercase
    Katakana --> Preedit: Uppercase
    Preedit --> Conversion: SPC
    Preedit --> Hiragana: C-g (returns to kana mode)

    Conversion --> Hiragana: C-j (commit, returns to kana mode)
    Conversion --> Conversion: SPC (next)
    Conversion --> Conversion: x (prev)
    Conversion --> Preedit: C-g (rollback)
Loading

Key Bindings

Mode Control

KeyCommandDescription
C-x C-jnskk-toggle-modeToggle NSKK in current buffer
C-jnskk-kakuteiCommit (hiragana) / enter hiragana (ascii) / newline
qnskk-handle-qToggle hiragana ↔ katakana
lnskk-handle-lSwitch to ASCII mode
Lnskk-handle-upper-lSwitch to full-width latin (JIS X 0208)
/nskk-handle-slashEnter abbrev mode

Conversion (Henkan)

KeyCommandDescription
SPCnskk-handle-spaceStart conversion / next candidate
xnskk-handle-xPrevious candidate
Xnskk-handle-upper-xPurge candidate from user dictionary
RETnskk-handle-returnCommit candidate + newline
C-gnskk-handle-cancelCancel conversion or preedit
a=–=ldirect selectSelect candidate in list mode
C-nnskk-handle-ctrl-nNext candidate OR next line
C-pnskk-handle-ctrl-pPrev candidate OR previous line
C-/nskk-undo-kakuteiUndo last kakutei (revert commit)

Cursor Movement (in Conversion Mode)

KeyBehavior
↑ / C-pCommit candidate + move to previous line
↓ / C-nCommit candidate + move to next line
← / C-bCommit candidate + move backward
→ / C-fCommit candidate + move forward

Line Navigation

KeyBehavior
C-a / <home>Commit candidate (if converting) / go to beginning of line
C-e / <end>Commit candidate (if converting) / go to end of line

Other Keys

KeyCommandDescription
DELnskk-handle-backspaceDelete last preedit char / cancel conversion
TABnskk-handle-tabDynamic completion (preedit) / indent-for-tab-command

Input Modes

ModeIndicatorDescription
asciiSKKDirect ASCII input (pass-through)
hiraganaかなHiragana input
katakanaカナKatakana input
jisx0208-latin全英Full-width latin (JIS X 0208)
abbrevaAAbbreviation expansion

Configuration

Common Options

;; Set initial input mode
(setopt nskk-state-default-mode 'hiragana)

;; System dictionary files
(setopt nskk-dict-system-dictionary-files
        '("/usr/share/skk/SKK-JISYO.L"))

;; User dictionary location
(setopt nskk-dict-user-dictionary-file "~/.nskk/jisyo")

;; Candidate display
(setopt nskk-henkan-show-candidates-nth 2)
(setopt nskk-henkan-number-to-display-candidates 7)

SKK Server (skkserv)

;; Connect to a running skkserv for extended dictionary lookup
(setopt nskk-server-enable t)
(setopt nskk-server-host "localhost")
(setopt nskk-server-portnum 1178)

Hooks

;; Run when NSKK is disabled
(add-hook 'nskk-mode-off-hook
          (lambda () (message "NSKK deactivated")))

AZIK Extended Romaji

;; Enable AZIK for more efficient romaji input
(setopt nskk-converter-romaji-style 'azik)

;; Keyboard layout (us101 or jp106, default: us101)
(setopt nskk-azik-keyboard-type 'jp106)

AZIK replaces standard romaji with efficiency shortcuts:

  • f → ん hatsuon (e.g. kf → かん)
  • j → ん hatsuon (e.g. sj → さん)
  • Double consonant suffixes → double vowels (e.g. kk → きん, sh → すう)

Optional Features

All optional features are auto-loaded when NSKK starts if their modules are present.

FeatureModuleEnable with
Annotation displaynskk-annotation(setopt nskk-show-annotation t)
Inline mode displaynskk-show-mode(setopt nskk-show-mode-show t)
Dynamic dcomp multinskk-inline(setopt nskk-dcomp-multiple-activate t)
Context auto-modenskk-context(nskk-context-global-mode 1)
Isearch integrationnskk-isearch(setopt nskk-isearch-enable t)
Region operationsnskk-regionAvailable as M-x nskk-region-* commands

Customization Group

M-x customize-group RET nskk RET

Development

Setup

git clone https://github.com/takeokunn/nskk.el.git
cd nskk.el

# Using Nix (recommended)
nix develop

# Or without Nix (requires Emacs 29.1+)
make compile
make test

The project includes flake.nix for reproducible development environments. nix develop provides Emacs 29.1+ with all necessary dependencies preconfigured.

Commands

CommandDescription
make compileByte-compile all modules
make testRun all tests
make test-unitRun unit tests only
make test-integrationRun integration tests only
make test-e2eRun end-to-end tests only
make lintRun checkdoc
make cleanRemove *.elc files

Changelog

See CHANGELOG.md.

Contributing

  1. Fork and create a feature branch
  2. Add tests and ensure they pass (make test)
  3. Commit and create a pull request

Code Style

  • nskk- prefix for public symbols
  • nskk-- prefix for internal symbols
  • All files must have lexical-binding: t

License

GPL-3.0-or-later

Copyright (C) 2026 NSKK Contributors

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Acknowledgments

  • DDSKK — A long-standing and widely used SKK implementation for Emacs
  • All SKK dictionary contributors

About

A next-generation SKK (Simple Kana to Kanji) Japanese input method for Emacs 29.1+

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages