Add 2011 to FSF/AIST copyright years.
[bpt/emacs.git] / lisp / language / japan-util.el
index ac6f5f9..5df3564 100644 (file)
@@ -1,9 +1,9 @@
 ;;; japan-util.el --- utilities for Japanese -*- coding: iso-2022-7bit; -*-
 
-;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   Free Software Foundation, Inc.
 ;; 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
 
 
 ;; 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
@@ -22,9 +22,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 <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -37,7 +35,7 @@
   (if (memq system-type '(windows-nt ms-dos cygwin))
       (prefer-coding-system 'japanese-shift-jis)
     (prefer-coding-system 'japanese-iso-8bit))
-  (use-cjk-char-width-table))
+  (use-cjk-char-width-table 'ja_JP))
 
 (defconst japanese-kana-table
   '((?\e$B$"\e(B ?\e$B%"\e(B ?\e(I1\e(B) (?\e$B$$\e(B ?\e$B%$\e(B ?\e(I2\e(B) (?\e$B$&\e(B ?\e$B%&\e(B ?\e(I3\e(B) (?\e$B$(\e(B ?\e$B%(\e(B ?\e(I4\e(B) (?\e$B$*\e(B ?\e$B%*\e(B ?\e(I5\e(B)
@@ -108,11 +106,13 @@ HANKAKU-KATAKANA belongs to `japanese-jisx0201-kana'.")
     (?\e$B!R\e(B ?<) (?\e$B!S\e(B ?>) (?\\e$B!V\e(B nil ?\\e(I"\e(B) (?\\e$B!W\e(B nil ?\\e(I#\e(B) 
     (?\e$B!\\e(B ?+) (?\e$B!]\e(B ?-) (?\e$B!a\e(B ?=) (?\e$B!c\e(B ?<) (?\e$B!d\e(B ?>)
     (?\e$B!l\e(B ?') (?\e$B!m\e(B ?\") (?\e$B!o\e(B ?\\) (?\e$B!p\e(B ?$) (?\e$B!s\e(B ?%) (?\e$B!t\e(B ?#) (?\e$B!u\e(B ?&) (?\e$B!v\e(B ?*)
-    (?\e$B!w\e(B ?@))
-  "Japanese JISX0208 symbol character table.
+    (?\e$B!w\e(B ?@)
+    ;; cp932-2-byte
+    (#x2015 ?-) (#xFF5E ?~) (#xFF0D ?-))
+  "Japanese JISX0208 and CP932 symbol character table.
   Each element is of the form (SYMBOL ASCII HANKAKU), where SYMBOL
-belongs to `japanese-jisx0208', ASCII belongs to `ascii', and HANKAKU
-belongs to `japanese-jisx0201-kana'.")
+belongs to `japanese-jisx0208' or `cp932', ASCII belongs to `ascii',
+and HANKAKU belongs to `japanese-jisx0201-kana'.")
 
 ;; Put properties 'jisx0208, 'jisx0201, and 'ascii to each Japanese
 ;; symbol and ASCII characters for conversion among them.
@@ -125,11 +125,13 @@ belongs to `japanese-jisx0201-kana'.")
     (if ascii
        (progn
          (put-char-code-property jisx0208 'ascii ascii)
-         (put-char-code-property ascii 'jisx0208 jisx0208)))
+         (if (encode-char jisx0208 'japanese-jisx0208)
+             (put-char-code-property ascii 'jisx0208 jisx0208))))
     (if jisx0201
        (progn
          (put-char-code-property jisx0208 'jisx0201 jisx0201)
-         (put-char-code-property jisx0201 'jisx0208 jisx0208)))))
+         (if (encode-char jisx0208 'japanese-jisx0208)
+             (put-char-code-property jisx0201 'jisx0208 jisx0208))))))
 
 (defconst japanese-alpha-numeric-table
   '((?\e$B#0\e(B . ?0) (?\e$B#1\e(B . ?1) (?\e$B#2\e(B . ?2) (?\e$B#3\e(B . ?3) (?\e$B#4\e(B . ?4)
@@ -162,8 +164,7 @@ belongs to `japanese-jisx0208', ASCII belongs to `ascii'.")
 ;; Convert string STR by FUNC and return a resulting string.
 (defun japanese-string-conversion (str func &rest args)
   (let ((buf (get-buffer-create " *Japanese work*")))
-    (save-excursion
-      (set-buffer buf)
+    (with-current-buffer buf
       (erase-buffer)
       (insert str)
       (apply func 1 (point) args)