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 NO-REDUCTION)
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).
If NO-REDUCTION is non-nil, do not reduce the dictionary vocabulary.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/international/ja-dic-cnv.el.gz
(defun skkdic-convert (filename &optional dirname no-reduction)
"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).
If NO-REDUCTION is non-nil, do not reduce the dictionary vocabulary."
(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 "/" t t)))
;; Setup and generate the header part of working buffer.
(with-current-buffer buf
(erase-buffer)
(buffer-disable-undo)
(generate-lisp-file-heading ja-dic-filename 'skkdic-convert :code nil)
(insert (format ";; Generated with small ja-dic option: %s\n\n"
(if no-reduction "no" "yes")))
(insert ";; Original SKK dictionary file: "
(file-relative-name (expand-file-name filename) dirname)
"\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 no-reduction)
;; Postfix
(with-current-buffer buf
(goto-char (point-max))
(generate-lisp-file-trailer ja-dic-filename :compile t)))
;; 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)))