;; Put properties 'katakana, 'hiragana, and 'jix0201 to each Japanese
;; kana characters for conversion among them.
-(let ((l japanese-kana-table)
- slot hiragana katakana jisx0201)
- (while l
- (setq slot (car l)
- hiragana (car slot) katakana (nth 1 slot) jisx0201 (nth 2 slot)
- l (cdr l))
- (if hiragana
- (if (stringp hiragana)
- (if (> (length hiragana) 1)
- (let ((hira (aref hiragana 0)))
- (put-char-code-property
- hira 'kana-composition
- (cons (cons (aref hiragana 1) katakana)
- (get-char-code-property hira 'kana-composition)))))
- (put-char-code-property hiragana 'katakana katakana)
- (put-char-code-property hiragana 'jisx0201 jisx0201)))
- (when (integerp katakana)
- (put-char-code-property katakana 'hiragana hiragana)
- (put-char-code-property katakana 'jisx0201 jisx0201))
- (if jisx0201
- (if (stringp jisx0201)
- (if (> (length jisx0201) 1)
- (let ((kana (aref jisx0201 0)))
- (put-char-code-property
- kana 'kana-composition
- (cons (cons (aref jisx0201 1) katakana)
- (get-char-code-property kana 'kana-composition)))))
- (put-char-code-property jisx0201 'hiragana hiragana)
- (put-char-code-property jisx0201 'katakana katakana)
- (put-char-code-property jisx0201 'jisx0208 katakana)))))
+(pcase-dolist (`(,hiragana ,katakana ,jisx0201) japanese-kana-table)
+ (if hiragana
+ (if (stringp hiragana)
+ (if (length> hiragana 1)
+ (let ((hira (aref hiragana 0)))
+ (put-char-code-property
+ hira 'kana-composition
+ (cons (cons (aref hiragana 1) katakana)
+ (get-char-code-property hira 'kana-composition)))))
+ (put-char-code-property hiragana 'katakana katakana)
+ (put-char-code-property hiragana 'jisx0201 jisx0201)))
+ (put-char-code-property katakana 'hiragana hiragana)
+ (put-char-code-property katakana 'jisx0201 jisx0201)
+ (if jisx0201
+ (if (stringp jisx0201)
+ (if (length> jisx0201 1)
+ (let ((kana (aref jisx0201 0)))
+ (put-char-code-property
+ kana 'kana-composition
+ (cons (cons (aref jisx0201 1) katakana)
+ (get-char-code-property kana 'kana-composition)))))
+ (put-char-code-property jisx0201 'hiragana hiragana)
+ (put-char-code-property jisx0201 'katakana katakana)
+ (put-char-code-property jisx0201 'jisx0208 katakana))))
(defconst japanese-symbol-table
'((?\ ?\ ) (?, ?,) (?. ?.) (?、 nil ?、) (?。 nil ?。) (?・ nil ?・)
;; Put properties 'jisx0208, 'jisx0201, and 'ascii to each Japanese
;; symbol and ASCII characters for conversion among them.
-(let ((l japanese-symbol-table)
- slot jisx0208 ascii jisx0201)
- (while l
- (setq slot (car l)
- jisx0208 (car slot) ascii (nth 1 slot) jisx0201 (nth 2 slot)
- l (cdr l))
- (if ascii
- (progn
- (put-char-code-property jisx0208 'ascii ascii)
- (if (encode-char jisx0208 'japanese-jisx0208)
- (put-char-code-property ascii 'jisx0208 jisx0208))))
- (if jisx0201
- (progn
- (put-char-code-property jisx0208 'jisx0201 jisx0201)
- (if (encode-char jisx0208 'japanese-jisx0208)
- (put-char-code-property jisx0201 'jisx0208 jisx0208))))))
+(pcase-dolist (`(,jisx0208 ,ascii ,jisx0201) japanese-symbol-table)
+ (when ascii
+ (put-char-code-property jisx0208 'ascii ascii)
+ (if (encode-char jisx0208 'japanese-jisx0208)
+ (put-char-code-property ascii 'jisx0208 jisx0208)))
+ (when jisx0201
+ (put-char-code-property jisx0208 'jisx0201 jisx0201)
+ (if (encode-char jisx0208 'japanese-jisx0208)
+ (put-char-code-property jisx0201 'jisx0208 jisx0208))))
(defconst japanese-alpha-numeric-table
'((?0 . ?0) (?1 . ?1) (?2 . ?2) (?3 . ?3) (?4 . ?4)
;; Put properties 'jisx0208 and 'ascii to each Japanese alpha numeric
;; and ASCII characters for conversion between them.
-(let ((l japanese-alpha-numeric-table)
- slot jisx0208 ascii)
- (while l
- (setq slot (car l)
- jisx0208 (car slot) ascii (cdr slot)
- l (cdr l))
- (put-char-code-property jisx0208 'ascii ascii)
- (put-char-code-property ascii 'jisx0208 jisx0208)))
+(pcase-dolist (`(,jisx0208 . ,ascii) japanese-alpha-numeric-table)
+ (put-char-code-property jisx0208 'ascii ascii)
+ (put-char-code-property ascii 'jisx0208 jisx0208))
;; Convert string STR by FUNC and return a resulting string.
(defun japanese-string-conversion (str func &rest args)
(with-current-buffer buf
(erase-buffer)
(insert str)
- (apply func 1 (point) args)
+ (apply func (point-min) (point) args)
(buffer-string))))
;;;###autoload
(if (stringp string)
string
(string string))
- 0))
+ 0))
;;;###autoload
(defun japanese-katakana-region (from to &optional hankaku)