Function: skkdic-convert
skkdic-convert is an interactive and byte-compiled function defined in
ja-dic-cnv.el.gz.
Signature
(skkdic-convert FILENAME &optional DIRNAME)
Documentation
Generate Emacs Lisp file from Japanese dictionary file FILENAME.
The format of the dictionary file should be the same as SKK dictionaries.
Saves the output as ja-dic-filename, in directory DIRNAME (if specified).
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/international/ja-dic-cnv.el.gz
(defun skkdic-convert (filename &optional dirname)
"Generate Emacs Lisp file from Japanese dictionary file FILENAME.
The format of the dictionary file should be the same as SKK dictionaries.
Saves the output as `ja-dic-filename', in directory DIRNAME (if specified)."
(interactive "FSKK dictionary file: ")
(let* ((skkbuf (get-buffer-create " *skkdic-unannotated*"))
(buf (get-buffer-create "*skkdic-work*")))
;; Set skkbuf to an unannotated copy of the dictionary.
(with-current-buffer skkbuf
(let ((coding-system-for-read 'euc-japan))
(insert-file-contents (expand-file-name filename)))
(re-search-forward "^[^;]")
(while (re-search-forward ";[^\n/]*/" nil t)
(replace-match "/")))
;; Setup and generate the header part of working buffer.
(with-current-buffer buf
(erase-buffer)
(buffer-disable-undo)
(insert ";;; ja-dic.el --- dictionary for Japanese input method"
" -*- lexical-binding:t -*-\n"
";;\tGenerated by the command `skkdic-convert'\n"
";;\tOriginal SKK dictionary file: "
(file-relative-name (expand-file-name filename) dirname)
"\n\n"
";; This file is part of GNU Emacs.\n\n"
";;; Start of the header of the original SKK dictionary.\n\n")
(set-buffer skkbuf)
(goto-char 1)
(let (pos)
(search-forward ";; okuri-ari")
(forward-line 1)
(setq pos (point))
(set-buffer buf)
(insert-buffer-substring skkbuf 1 pos))
(insert "\n"
";;; Code:\n\n(eval-when-compile (require 'ja-dic-cnv))\n\n")
;; Generate the body part of working buffer.
(set-buffer skkbuf)
(let ((from (point))
to)
;; Convert okuri-ari entries.
(search-forward ";; okuri-nasi")
(beginning-of-line)
(setq to (point))
(narrow-to-region from to)
(skkdic-convert-okuri-ari skkbuf buf)
(widen)
;; Convert okuri-nasi postfix entries.
(goto-char to)
(forward-line 1)
(setq from (point))
(re-search-forward "^\\cH")
(setq to (match-beginning 0))
(narrow-to-region from to)
(skkdic-convert-postfix skkbuf buf)
(widen)
;; Convert okuri-nasi prefix entries.
(goto-char to)
(skkdic-convert-prefix skkbuf buf)
;;
(skkdic-collect-okuri-nasi)
;; Convert okuri-nasi general entries.
(skkdic-convert-okuri-nasi skkbuf buf)
;; Postfix
(with-current-buffer buf
(goto-char (point-max))
(insert ";;\n(provide 'ja-dic)\n\n"
";; Local Variables:\n"
";; version-control: never\n"
";; no-update-autoloads: t\n"
";; coding: utf-8\n"
";; End:\n\n"
";;; ja-dic.el ends here\n")))
;; Save the working buffer.
(set-buffer buf)
(set-visited-file-name (expand-file-name ja-dic-filename dirname) t)
(set-buffer-file-coding-system 'utf-8)
(save-buffer 0))
(kill-buffer skkbuf)
(switch-to-buffer buf)))