X-Git-Url: https://git.hcoop.net/bpt/emacs.git/blobdiff_plain/e3fe4da0475674efad25a8a62e90879360ed2601..7497ef13c916f39e297a83193d9163fb37a3b799:/lisp/international/ja-dic-cnv.el diff --git a/lisp/international/ja-dic-cnv.el b/lisp/international/ja-dic-cnv.el index 10db14ed8e..c0fcf19d84 100644 --- a/lisp/international/ja-dic-cnv.el +++ b/lisp/international/ja-dic-cnv.el @@ -1,18 +1,18 @@ ;;; ja-dic-cnv.el --- convert a Japanese dictionary (SKK-JISYO.L) to Emacs Lisp ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, -;; 2005, 2006, 2007, 2008 +;; 2005, 2006, 2007, 2008, 2009, 2010, 2011 ;; National Institute of Advanced Industrial Science and Technology (AIST) ;; Registration Number H14PRO021 -;; Keywords: mule, multilingual, Japanese +;; Keywords: i18n, mule, multilingual, Japanese ;; This file is part of GNU Emacs. -;; GNU Emacs is free software; you can redistribute it and/or modify +;; GNU Emacs 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, or (at your option) -;; any later version. +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -20,9 +20,7 @@ ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. +;; along with GNU Emacs. If not, see . ;;; Commentary: @@ -47,43 +45,30 @@ ;; Name of a file to generate from SKK dictionary. (defvar ja-dic-filename "ja-dic.el") -;; To make a generated ja-dic.el smaller. -(make-coding-system - 'iso-2022-7bit-short - 2 ?J - "Like `iso-2022-7bit' but no ASCII designation before SPC." - '(ascii nil nil nil t t nil t) - '((safe-charsets . t))) - (defun skkdic-convert-okuri-ari (skkbuf buf) (message "Processing OKURI-ARI entries ...") (goto-char (point-min)) - (save-excursion - (set-buffer buf) + (with-current-buffer buf (insert ";; Setting okuri-ari entries.\n" "(skkdic-set-okuri-ari\n")) (while (not (eobp)) - (let ((from (point)) - to) - (end-of-line) - (setq to (point)) - - (save-excursion - (set-buffer buf) - (insert-buffer-substring skkbuf from to) - (beginning-of-line) - (insert "\"") - (search-forward " ") - (delete-char 1) ; delete the first '/' - (let ((p (point))) - (end-of-line) - (delete-char -1) ; delete the last '/' - (subst-char-in-region p (point) ?/ ? 'noundo)) - (insert "\"\n")) - - (forward-line 1))) - (save-excursion - (set-buffer buf) + (if (/= (following-char) ?>) + (let ((from (point)) + (to (line-end-position))) + (with-current-buffer buf + (insert-buffer-substring skkbuf from to) + (beginning-of-line) + (insert "\"") + (search-forward " ") + (delete-char 1) ; delete the first '/' + (let ((p (point))) + (end-of-line) + (delete-char -1) ; delete the last '/' + (subst-char-in-region p (point) ?/ ? 'noundo)) + (insert "\"\n")))) + + (forward-line 1)) + (with-current-buffer buf (insert ")\n\n"))) (defconst skkdic-postfix-list '(skkdic-postfix-list)) @@ -112,15 +97,13 @@ (defun skkdic-convert-postfix (skkbuf buf) (message "Processing POSTFIX entries ...") (goto-char (point-min)) - (save-excursion - (set-buffer buf) + (with-current-buffer buf (insert ";; Setting postfix entries.\n" "(skkdic-set-postfix\n")) ;; Initialize SKKDIC-POSTFIX-LIST by predefined data ;; SKKDIC-POSTFIX-DATA. - (save-excursion - (set-buffer buf) + (with-current-buffer buf (let ((l skkdic-postfix-data) kana candidates entry) (while l @@ -147,8 +130,7 @@ (if (not (member str candidates)) (setq candidates (cons str candidates))) (goto-char (match-end 1))) - (save-excursion - (set-buffer buf) + (with-current-buffer buf (insert "\"" kana) (while candidates (insert " " (car candidates)) @@ -161,8 +143,7 @@ skkdic-postfix-list))) (setq candidates (cdr candidates))) (insert "\"\n")))) - (save-excursion - (set-buffer buf) + (with-current-buffer buf (insert ")\n\n"))) (defconst skkdic-prefix-list '(skkdic-prefix-list)) @@ -170,8 +151,7 @@ (defun skkdic-convert-prefix (skkbuf buf) (message "Processing PREFIX entries ...") (goto-char (point-min)) - (save-excursion - (set-buffer buf) + (with-current-buffer buf (insert ";; Setting prefix entries.\n" "(skkdic-set-prefix\n")) (save-excursion @@ -183,16 +163,14 @@ (if (not (member str candidates)) (setq candidates (cons str candidates))) (goto-char (match-end 1))) - (save-excursion - (set-buffer buf) + (with-current-buffer buf (insert "\"" kana) (while candidates (insert " " (car candidates)) (set-nested-alist (car candidates) kana skkdic-prefix-list) (setq candidates (cdr candidates))) (insert "\"\n"))))) - (save-excursion - (set-buffer buf) + (with-current-buffer buf (insert ")\n\n"))) ;; FROM and TO point the head and tail of "/J../J../.../". @@ -316,8 +294,7 @@ (defun skkdic-convert-okuri-nasi (skkbuf buf) (message "Processing OKURI-NASI entries ...") - (save-excursion - (set-buffer buf) + (with-current-buffer buf (insert ";; Setting okuri-nasi entries.\n" "(skkdic-set-okuri-nasi\n") (let ((l (nreverse skkdic-okuri-nasi-entries)) @@ -355,13 +332,12 @@ The name of generated file is specified by the variable `ja-dic-filename'." (let* ((coding-system-for-read 'euc-japan) (skkbuf(find-file-noselect (expand-file-name filename))) (buf (get-buffer-create "*skkdic-work*"))) - (save-excursion - ;; Setup and generate the header part of working buffer. - (set-buffer buf) + ;; 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" - " -*-coding: iso-2022-jp; byte-compile-disable-print-circle:t; -*-\n" + " -*-coding: euc-japan; -*-\n" ";;\tGenerated by the command `skkdic-convert'\n" ";;\tDate: " (current-time-string) "\n" ";;\tOriginal SKK dictionary file: " @@ -416,15 +392,14 @@ The name of generated file is specified by the variable `ja-dic-filename'." (skkdic-convert-okuri-nasi skkbuf buf) ;; Postfix - (save-excursion - (set-buffer buf) + (with-current-buffer buf (goto-char (point-max)) (insert ";;\n(provide 'ja-dic)\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 'iso-2022-7bit-short) + (set-buffer-file-coding-system 'euc-japan) (save-buffer 0)) (kill-buffer skkbuf) (switch-to-buffer buf))) @@ -478,7 +453,7 @@ To get complete usage, invoke: (- ch) ; represented by a negative code. (if (= ch ?ー) ; `ー' is represented by 0. 0 - (- (nth 2 (split-char ch)) 32)))) + (- (logand (encode-char ch 'japanese-jisx0208) #xFF) 32)))) (setq i (1+ i))) vec)) @@ -558,7 +533,7 @@ To get complete usage, invoke: (while l (setq count (1+ count)) (if (= (% count 10000) 0) - (message (format "%d entries" count))) + (message "%d entries" count)) (setq entry (skkdic-extract-conversion-data (car l))) (set-nested-alist (car entry) (cdr entry) map) (setq l (cdr l))) @@ -570,5 +545,4 @@ To get complete usage, invoke: ;; coding: iso-2022-7bit ;; End: -;;; arch-tag: dec06fb0-8118-45b1-80d7-dc360b6fd3b2 ;;; ja-dic-cnv.el ends here