1;;; skk-num.el --- �����Ѵ��Τ���Υץ���� 2;; Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3;; 1998, 1999, 2000 4;; Masahiko Sato <masahiko@kuis.kyoto-u.ac.jp> 5 6;; Author: Masahiko Sato <masahiko@kuis.kyoto-u.ac.jp> 7;; Maintainer: Mikio Nakajima <minakaji@osaka.email.ne.jp> 8;; Version: $Id: skk-num.el,v 1.2 2002/12/06 14:58:57 tatari Exp $ 9;; Keywords: japanese 10;; Last Modified: $Date: 2002/12/06 14:58:57 $ 11 12;; This file is part of SKK. 13 14;; SKK is free software; you can redistribute it and/or modify 15;; it under the terms of the GNU General Public License as published by 16;; the Free Software Foundation; either versions 2, or (at your option) 17;; any later version. 18 19;; SKK is distributed in the hope that it will be useful 20;; but WITHOUT ANY WARRANTY; without even the implied warranty of 21;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22;; GNU General Public License for more details. 23 24;; You should have received a copy of the GNU General Public License 25;; along with SKK, see the file COPYING. If not, write to the Free 26;; Software Foundation Inc., 59 Temple Place - Suite 330, Boston, 27;; MA 02111-1307, USA. 28 29;;; Commentary: 30 31;;; Code: 32;(eval-when-compile (require 'skk) (require 'cl)) 33(require 'skk-foreword) 34 35;;;###autoload 36(defgroup skk-num nil "SKK number conversion related customization." 37 :prefix "skk-num-" 38 :group 'skk) 39 40;; user variables. 41(defcustom skk-num-type-alist 42 '((0 . identity) 43 (1 . skk-num-jisx0208-latin) 44 (2 . skk-num-type2-kanji) 45 (3 . skk-num-type3-kanji) 46 (4 . skk-num-recompute) 47 (5 . skk-num-type5-kanji) 48 (9 . skk-num-shogi)) 49 "*���ͤ��Ѵ��Τ���Ρ�����ǥ������Ѵ��˻��Ѥ���ؿ��ȤΥ����ꥹ�ȡ� 50�����Ǥϡ�`\(����ǥ��� . �ؿ�̾\)' �Ȥ��������ˤʤäƤ��롣 51����ǥ����ˤϡ��㤨�и��Ф��줬 \"ʿ��#1ǯ\" �ΤȤ���`#' �����ľ���ɽ������� 52integer `1' ���������롣 53 54����ǥ����ȴؿ��δط� \(�ǥ��ե������\) �ϲ������̤ꡣ 55 0 -> ̵�Ѵ� 56 1 -> ���ѿ������Ѵ� 57 2 -> ���������Ѵ� \(�̼��ʤ�\) 58 3 -> ���������Ѵ� \(�̼���\) 59 4 -> ���ο������Τ�Τ��ˤ��Ƽ����Ƹ��� 60 5 -> ������ (����ʤɤǻ��Ѥ���ʸ�������) ���Ѵ� (�̼���) 61 9 -> �����ǻ��Ѥ������ \(\"����\" �ʤ�\) ���Ѵ�" 62 :type '(repeat (cons (choice :tag "Index" 63 (integer 0) (integer 1) (integer 2) (integer 3) 64 (integer 4) (integer 5) (integer 9)) 65 (function :tag "Function"))) 66 :group 'skk-num) 67 68(defcustom skk-num-convert-float nil 69 "*Non-nil �Ǥ���С���ư����������Ȥä����Ф�����б������Ѵ���Ԥʤ��� 70�����ͤ� non-nil �ˤ��뤳�Ȥǡ�\"#.# /#1��#1/#0��#0��/\" �ʤɤμ��Ф������� 71�Ǥ��ʤ��ʤ�Τǡ���ա�" 72 :type 'boolean 73 :group 'skk-num) 74 75(defcustom skk-num-uniq (or (assq 4 skk-num-type-alist) 76 (and (assq 2 skk-num-type-alist) 77 (assq 3 skk-num-type-alist))) 78 "*Non-nil �Ǥ���С��ۤʤ����ɽ���Ǥ��Ѵ���̤�Ʊ�����ͤ��ʣ���ƽ��Ϥ��ʤ���" 79 :type 'boolean 80 :group 'skk-num) 81 82(defcustom skk-num-load-hook nil 83 "*skk-num.el ����ɤ�����˥����뤵���եå���" 84 :type 'hook 85 :group 'skk-num) 86 87;; internal constants and variables 88(defconst skk-num-alist-type1 89 '((?0 . "��") (?1 . "��") (?2 . "��") (?3 . "��") 90 (?4 . "��") (?5 . "��") (?6 . "��") (?7 . "��") 91 (?8 . "��") (?9 . "��") 92 (?. . "��") ; ��������(?. . ".") �������ɤ��ͤ⤤�뤫��...�� 93 (? . "")) 94 "ascii ������ char type �����ѿ����� string type ��Ϣ�ۥꥹ�ȡ� 95\"1995\" -> \"��������\" �Τ褦��ʸ������Ѵ���Ԥ��ݤ����Ѥ��롣") 96 97(defconst skk-num-alist-type2 98 '((?0 . "��") (?1 . "��") (?2 . "��") (?3 . "��") 99 (?4 . "��") (?5 . "��") (?6 . "ϻ") (?7 . "��") 100 (?8 . "Ȭ") (?9 . "��") (? . "")) 101 "ascii ������ char type �ȴ������� string type ��Ϣ�ۥꥹ�ȡ� 102\"1995\" -> \"�����\" �Τ褦��ʸ������Ѵ���Ԥ��ݤ����Ѥ��롣") 103 104(defconst skk-num-alist-type5 105 '((?1 . "��") (?2 . "��") (?3 . "��") 106 (?4 . "��") (?5 . "��") (?6 . "ϻ") (?7 . "��") 107 (?8 . "Ȭ") (?9 . "��") (? . "")) 108 "ascii ������ char type �ȴ������� string type ��Ϣ�ۥꥹ�ȡ� 109\"1995\" -> \"������ɴ�彦��\" �Τ褦��ʸ������Ѵ���Ԥ��ݤ����Ѥ��롣") 110 111(skk-deflocalvar skk-num-list nil 112 "skk-henkan-key ����˴ޤޤ�������ɽ��ʸ����Υꥹ�ȡ� 113�㤨�С�\"���ؤ�����7�ͤ�10����\" ���Ѵ���Ԥ��Ȥ���skk-henkan-key �� 114\"�ؤ�����7�ͤ�10����\" �Ǥ��ꡢskk-num-list �� \(\"7\" \"10\"\) �Ȥʤ롣") 115 116(defvar skk-num-recompute-key nil 117 "#4 �����פΥ����ˤ����ͤκƷ���Ԥʤä��Ȥ��θ���������") 118 119(defun skk-num-compute-henkan-key (key) 120 ;; KEY �����Ϣ³��������魯ʸ����� "#" ���֤�������ʸ������֤���"12" 121 ;; �� "����" �ʤ�Ϣ³��������� 1 �Ĥ� "#" ���֤������뤳�Ȥ���ա� 122 ;; �֤������������� skk-num-list ����˥ꥹ�Ȥη�����¸���롣 123 ;; �㤨�С�KEY �� "�ؤ�����7ǯ12����" �Ǥ���С�"�ؤ�����#�ͤ�#����" 124 ;; ���Ѵ�����skk-num-list �� ("7" "12") �Ȥ����ꥹ�Ȥ��������롣 125 ;; ����θ��Ф���θ����˻��Ѥ��롣 126 (let ((numexp (if skk-num-convert-float 127 "[.0-9]+" "[0-9]+"))) 128 ;;(setq skk-noconv-henkan-key key) 129 (save-match-data 130 ;; �̼��� "," �����롣 131 (while (string-match "," key) 132 (setq key (concat (substring key 0 (match-beginning 0)) 133 (substring key (match-end 0))))) 134 ;; ���ѿ����� ascii �������Ѵ����롣 135 (while (string-match "[��-��]" key) 136 (let ((zen-num (match-string 0 key))) 137 (setq key (concat (substring key 0 (match-beginning 0)) 138 (skk-jisx0208-to-ascii zen-num) 139 (substring key (match-end 0)))))) 140 ;; ascii ������ "#" ���֤����������ο����� skk-num-list �������¸�� 141 (while (string-match numexp key) 142 (setq skk-num-list (nconc skk-num-list (list (match-string 0 key))) 143 key (concat (substring key 0 (match-beginning 0)) 144 "#" 145 (substring key (match-end 0))))))) 146 key) 147 148(defun skk-num-convert (key) 149 ;; skk-henkan-list �� skk-henkan-count ���ؤ��Ƥ�������Ѵ������� 150 ;; ������Ѵ�����skk-henkan-list �� 151 ;; ("#2" ...) -> (("#2" ."��") ...) 152 ;; �Τ褦���ѷ����롣 153 (if (not key) 154 nil 155 (let ((numexp (if skk-num-convert-float 156 "#[.0-9]+" "#[0-9]+")) 157 (n 0) 158 (workkey key) 159 num convnum string convlist current) 160 (save-match-data 161 (while (and (setq num (nth n skk-num-list)) 162 (string-match numexp workkey)) 163 (setq convnum (save-match-data 164 (skk-num-exp num (string-to-number 165 (substring workkey 166 (1+ (match-beginning 0)) 167 (match-end 0))))) 168 string (substring workkey 0 (match-beginning 0)) 169 workkey (substring workkey (match-end 0)) 170 n (1+ n)) 171 (if (not (and (stringp convnum) (string= convnum "") 172 (string= string ""))) 173 (setq convlist (nconc convlist (list string convnum))))) 174 (setq convlist (nconc convlist (list workkey))) 175 (cond ((null convlist) nil) 176 ((and (null (cdr convlist)) (stringp (car convlist))) 177 (setq current (car convlist))) 178 ;; CONV-LIST �������Ǥ�ʸ���� 179 ((null (memq t (mapcar 'listp convlist))) 180 (setq current (mapconcat 'identity convlist "")) 181 (if (and (> skk-henkan-count -1) 182 (nth skk-henkan-count skk-henkan-list)) 183 ;; ("A" "#2" "C") -> ("A" ("#2" ."��") "C") 184 (setcar (nthcdr skk-henkan-count skk-henkan-list) (cons key current)) 185; (setf (nth skk-henkan-count skk-henkan-list) 186; (cons key current)) 187 (setq skk-henkan-list 188 (nconc skk-henkan-list (list (cons key current)))))) 189 ;; #4 190 (t (let ((l (mapcar (function (lambda (e) (cons key e))) 191 (skk-num-flatten-list (delete "" convlist))))) 192 (setq current (cdr (car l))) 193 (if (and (> skk-henkan-count -1) 194 (nth skk-henkan-count skk-henkan-list)) 195 (progn 196 (setcar (nthcdr skk-henkan-count skk-henkan-list) (car l)) 197; (setf (nth skk-henkan-count skk-henkan-list) (car l)) 198 (setq skk-henkan-list (skk-splice-in 199 skk-henkan-list 200 (1+ skk-henkan-count) 201 (cdr l)))) 202 (setq skk-henkan-list (nconc skk-henkan-list l)))))) 203 current)))) 204 205(defun skk-num-convert*7 () 206 (let ((skk-henkan-count skk-henkan-count) 207 (n 7)) 208 (while (and (> n 0) (nth skk-henkan-count skk-henkan-list)) 209 (skk-num-convert (skk-get-current-candidate)) 210 (setq skk-henkan-count (1+ skk-henkan-count) 211 n (1- n))) 212 (and skk-num-recompute-key (skk-num-uniq)))) 213 214(defun skk-num-rawnum-exp (string) 215 (setq string (skk-num-rawnum-exp-1 216 string "[��-��][�������ͼ���Ȭϻ]" "#9" 0)) 217 (setq string (skk-num-rawnum-exp-1 218 string "\\(^\\|[^#0-9]\\)\\([0-9]+\\)" "#0" 2)) 219 (setq string (skk-num-rawnum-exp-1 220 string "[��-��]+" "#1" 0)) 221 (setq string (skk-num-rawnum-exp-1 222 string "\\([�������ͼ���Ȭϻ��][��ɴ����������]\\)+" "#3" 0)) 223 ;; (mapcar 'char-to-string 224 ;; (sort 225 ;; '(?�� ?�� ?�� ?�� ?�� ?ϻ ?�� ?Ȭ ?�� ?��) '<)) 226 ;; --> ("��" "��" "��" "��" "��" "��" "��" "��" "Ȭ" "ϻ") 227 ;; 228 ;; [��-��] �Ȥ�������ɽ�����Ȥ��ʤ��Τǡ����ΤޤޤĤä���Ǥ����� 229 (skk-num-rawnum-exp-1 string "[�������ͼ���Ȭϻ]+" "#2" 0)) 230 231(defun skk-num-rawnum-exp-1 (string key type place) 232 (save-match-data 233 (while (string-match key string) 234 (setq string (concat (substring string 0 (match-beginning place)) 235 type 236 (substring string (match-end place))))) 237 string)) 238 239(defun skk-num-flatten-list (list) 240 ;; Ϳ����줿�ꥹ�Ȥγ����Ǥ����Ȥ߹礻��ǽ��ʸ�����Ϣ�ܤ��ꡢ�ꥹ�Ȥ��� 241 ;; ���� 242 ;; (("A" "B") "1" ("X" "Y")) -> ("A1X" "A1Y" "B1X" "B1Y") 243 (let ((dst (car list)) 244 (src (cdr list)) 245 elt) 246 (while src 247 (setq elt (car src)) 248 (if (consp elt) 249 (setq dst (apply (function nconc) 250 (mapcar 251 (lambda (str0) 252 (mapcar 253 (lambda (str1) 254 (concat str0 str1)) 255 elt)) 256 dst))) 257 (setq dst (mapcar 258 (lambda (str0) 259 (concat str0 elt)) 260 dst))) 261 (setq src (cdr src))) 262 dst)) 263 264(defun skk-num-exp (num type) 265 ;; ascii ������ NUM �� TYPE �˽����Ѵ������Ѵ����ʸ������֤��� 266 ;; TYPE �ϲ������̤ꡣ 267 ;; 0 -> ̵�Ѵ� 268 ;; 1 -> ���ѿ������Ѵ� 269 ;; 2 -> ���������Ѵ� (�̼��ʤ�) 270 ;; 3 -> ���������Ѵ� (�̼���) 271 ;; 4 -> ���ο������Τ�Τ��ˤ��Ƽ����Ƹ��� 272 ;; 5 -> ������ (����ʤɤǻ��Ѥ���ʸ�������) ���Ѵ� (�̼���) 273 ;; 9 -> �����ǻ��Ѥ������ ("����" �ʤ�) ���Ѵ� 274 (let ((fun (cdr (assq type skk-num-type-alist)))) 275 (if fun (funcall fun num)))) 276 277(defun skk-num-jisx0208-latin (num) 278 ;; ascii ������ NUM �����ѿ�����ʸ������Ѵ������Ѵ����ʸ������֤��� 279 ;; �㤨�� "45" �� "����" ���Ѵ����롣 280 (let ((candidate 281 (mapconcat (function (lambda (c) (cdr (assq c skk-num-alist-type1)))) 282 num ""))) 283 (if (not (string= candidate "")) 284 candidate))) 285 286(defun skk-num-type2-kanji (num) 287 ;; ascii ���� NUM ���������ʸ������Ѵ������Ѵ����ʸ������֤��� 288 ;; �㤨�С�"45" �� "��" ���Ѵ����롣 289 (save-match-data 290 (if (not (string-match "\\.[0-9]" num)) 291 (let ((candidate 292 (mapconcat (function (lambda (c) 293 (cdr (assq c skk-num-alist-type2)))) 294 num ""))) 295 (if (not (string= candidate "")) 296 candidate))))) 297 298(defun skk-num-type3-kanji (num) 299 ;; ascii ���� NUM ���������ʸ������Ѵ��� (�̼���)���Ѵ����ʸ����� 300 ;; �֤����㤨�� "1021" �� "����" ���Ѵ����롣 301 (save-match-data 302 (if (not (string-match "\\.[0-9]" num)) 303 ;; ��������ޤޤʤ��� 304 (let ((str (skk-num-type3-kanji-1 num))) 305 (if (string= "" str) "��" str))))) 306 307(defun skk-num-type3-kanji-1 (num) 308 ;; skk-num-type3-kanji �Υ��֥롼���� 309 (let ((len (length num)) 310 (i 0) 311 char v num1 v1) 312 ;; ������פޤǤϽ��Ϥ��롣 313 (when (> len 20) (skk-error "�̤��礭�����ޤ���" "Too big number!")) 314 (setq num (append num nil)) 315 (cond 316 ((<= len 4) 317 (while (setq char (car num)) 318 ;; ��: �� �� ɴ �� 319 ;; len: 1 2 3 4 320 (if (= len 1) 321 ;; �̤�ɽ�魯�������ʳ��δ������� 322 (unless (eq char ?0) 323 ;; ��ΰ̤� 0 �Ǥʤ����� 324 (setq v (concat v (cdr (assq char skk-num-alist-type2))))) 325 ;; �̤�ɽ�魯�������ʳ��δ������� 326 (unless (memq char '(?0 ?1)) 327 ;; ���ΰ̰ʾ�ǡ����� 0, 1 �ʳ��ο����� 328 (setq v (concat v (cdr (assq char skk-num-alist-type2))))) 329 ;; �̤�ɽ�魯�������� 330 (when (and (not (eq char ?0)) (memq len '(2 3 4))) 331 (setq v 332 (concat 333 v 334 (cdr (assq len '((2 . "��") (3 . "ɴ") (4 . "��")))))))) 335 (setq len (1- len) num (cdr num)))) 336 (t 337 (setq num (nreverse num)) 338 (while num 339 (setq num1 nil) 340 (while (and (< (length num1) 4) num) 341 (setq num1 (cons (car num) num1) 342 num (cdr num))) 343 (when num1 344 (setq v1 (skk-num-type3-kanji-1 num1)) 345 (when (and (eq i 1) (equal v1 "��")) 346 ;; ���ܸ�Ǥϡ��鲯�פȤ���ɽ���ϤȤ��˻Ȥ��뤬���������פȤ���ɽ 347 ;; ���Ϥޤ��Ȥ��ʤ��Τǡ��ְ������פ�ľ���� 348 (setq v1 (concat "��" v1))) 349 (setq 350 v 351 (concat 352 v1 353 (when v1 354 (cdr 355 (assq 356 i '((0 . "") (1 . "��") (2 . "��") (3 . "��") (4 . "��"))))) 357 v))) 358 (setq i (1+ i))))) 359 v)) 360 361(defun skk-num-type5-kanji (num) 362 ;; ascii ���� NUM ���������ʸ������Ѵ��� (�̼���)���Ѵ����ʸ����� 363 ;; �֤����㤨�� "1021" �� "����������" ���Ѵ����롣 364 (save-match-data 365 (if (not (string-match "\\.[0-9]" num)) 366 ;; ��������ޤޤʤ��� 367 (let ((str (skk-num-type5-kanji-1 num))) 368 (if (string= "" str) "��" str))))) 369 370(defun skk-num-type5-kanji-1 (num) 371 ;; skk-num-type5-kanji �Υ��֥롼���� 372 (let ((len (length num)) 373 (i 0) 374 char v num1 v1) 375 ;; ������פޤǤϽ��Ϥ��롣 376 (when (> len 20) (skk-error "�̤��礭�����ޤ���" "Too big number!")) 377 (setq num (append num nil)) 378 (cond 379 ((<= len 4) 380 (while (setq char (car num)) 381 (if (= len 1) 382 (unless (eq char ?0) 383 (setq v (concat v (cdr (assq char skk-num-alist-type5))))) 384 ;; �̤�ɽ�魯�������ʳ��δ������� 385 (setq v (concat v (cdr (assq char skk-num-alist-type5)))) 386 ;; �̤�ɽ�魯�������� 387 (when (and (not (eq char ?0)) (memq len '(2 3 4))) 388 (setq v 389 (concat 390 v 391 (cdr (assq len '((2 . "��") (3 . "ɴ") (4 . "��")))))))) 392 (setq len (1- len) num (cdr num)))) 393 (t 394 (setq num (nreverse num)) 395 (while num 396 (setq num1 nil) 397 (while (and (< (length num1) 4) num) 398 (setq num1 (cons (car num) num1) 399 num (cdr num))) 400 (when num1 401 (setq v1 (skk-num-type5-kanji-1 num1)) 402 (setq 403 v 404 (concat 405 v1 406 (when v1 407 (cdr 408 (assq 409 i '((0 . "") (1 . "��") (2 . "��") (3 . "��") (4 . "��"))))) 410 v))) 411 (setq i (1+ i))))) 412 v)) 413 414(defun skk-num-shogi (num) 415 ;; ascii ������ NUM ���ǻ��Ѥ�������ɽ�����Ѵ����롣 416 ;; �㤨�� "34" �� "����" ���Ѵ����롣 417 (save-match-data 418 (if (and (= (length num) 2) 419 (not (string-match "\\.[0-9]" num))) 420 (let ((candidate 421 (concat (cdr (assq (aref num 0) skk-num-alist-type1)) 422 (cdr (assq (aref num 1) skk-num-alist-type2))))) 423 (if (not (string= candidate "")) 424 candidate))))) 425 426(defun skk-num-recompute (num) 427 ;; #4 �θ��Ф����Ф���skk-henkan-key ���������줿�������Τ�Τ���ٸ������롣 428 (let (result) 429 (setq skk-num-recompute-key num) 430 (with-temp-buffer 431 ;; �����ȥХåե��ΥХåե��������ѿ��˱ƶ���ڤܤ��ʤ��褦����� 432 ;; �Хåե��ذ�öƨ���� 433 (let ((skk-current-search-prog-list skk-search-prog-list) 434 (skk-henkan-key num) 435 ;; �����Ȥ��Ѵ�������ʤ� (skk-henkan-okurigana �� skk-okuri-char �� 436 ;; ������� nil) �������̥Хåե� (work �Хåե�) �����äƤ���Τǡ�ǰ 437 ;; �Τ��ᡢnil ������Ƥ����� 438 skk-henkan-okurigana skk-okuri-char skk-use-numeric-conversion) 439 (while skk-current-search-prog-list 440 (setq result (skk-nunion result (skk-search)))))) 441 ;; ������ temp-buffer ��Ф��Ѵ���ԤʤäƤ��륫���ȥХåե������ 442 ;; (�Хåե��������ͤǤ��� skk-henkan-list ������������)�� 443 (if result 444 (if (null (cdr result));;(= (length result) 1) 445 (car result) 446 result) 447 ;; �Ѵ��Ǥ��ʤ��ä��鸵�ο����Τޤ��֤��Ƥ����� 448 num))) 449 450;;;###autoload 451(defun skk-num-uniq () 452 (if (or (not skk-num-uniq) (null skk-henkan-list)) 453 nil 454 (save-match-data 455 (let ((n1 -1) n2 e1 e2 e3 456 ;; 1 �ĤǤ� 2 ��ʾ�ο���������С�#2 �� #3 �Ǥ� uniq ���ʤ��� 457 (type2and3 (> 2 (apply 'max (mapcar 'length skk-num-list)))) 458 type2 type3 index2 index3 head2 head3 tail2 tail3 459 case-fold-search) 460 (while (setq n1 (1+ n1) e1 (nth n1 skk-henkan-list)) 461 ;; cons cell �Ǥʤ���� skk-nunion �ǽ����ѤߤʤΤǡ���ʣ�Ϥʤ��� 462 (if (consp e1) 463 ;; (car e1) �� equal �Τ�Τ��ä���Τ����� e1 ���Ȥ��ä��뤳 464 ;; �ȤϤʤ��� 465 (setq skk-henkan-list (delete (car e1) skk-henkan-list) 466 skk-henkan-list (delete (cdr e1) skk-henkan-list))) 467 (if (not (and skk-num-recompute-key (consp e1))) 468 nil 469 ;; ("#4" . "xxx") ��ޤ���䤬 skk-henkan-list ����ˤ��롣 470 (setq n2 -1) 471 (while (setq n2 (1+ n2) e2 (nth n2 skk-henkan-list)) 472 (if (and (not (= n1 n2)) (consp e2) 473 ;; �㤨�� ("#4" . "��") �� ("#2" . "��") ����¸���Ƥ� 474 ;; ���硣 475 (string= (cdr e1) (cdr e2))) 476 (setq skk-henkan-list (delq e2 skk-henkan-list))))) 477 (if (not type2and3) 478 nil 479 ;; 1 ��ο������Ѵ�����ݤˡ�skk-henkan-list �� #2 ����ȥ�� #3 480 ;; ����ȥ꤬����С�#2 �⤷���� #3 ����ȥ�Τ������������ˤ��� 481 ;; ��Τ�ä��� 482 (setq e3 (if (consp e1) (car e1) e1)) 483 ;; e3 �� "#2" �Τ褦�˿����Ѵ���ʸ����ΤߤȤϸ¤�ʤ��Τǡ� 484 ;; member �ϻȤ��ʤ��� 485 (cond ((string-match "#2" e3) 486 (setq type2 e1 487 index2 n1 488 head2 (substring e3 0 (match-beginning 0)) 489 tail2 (substring e3 (match-end 0)))) 490 ((string-match "#3" e3) 491 (setq type3 e1 492 index3 n1 493 head3 (substring e3 0 (match-beginning 0)) 494 tail3 (substring e3 (match-end 0))))))) 495 (if (and type2and3 type2 type3 496 ;; �����Ѵ���ʸ���� "#[23]" �������ʸ�����Ʊ��Τ� 497 ;; ���Τ� uniq ��Ԥʤ��� 498 (string= head2 head3) (string= tail2 tail3)) 499 (if (> index2 index3) 500 ;; "#3" ���������ˤ��롣 501 (setq skk-henkan-list (delq type2 skk-henkan-list)) 502 ;; �ѿ� type[23] ���ͤϡ�skk-henkan-list ����ľ����Ф����� 503 ;; �Τ����� delete �Ǥʤ���delq �ǽ�ʬ�� 504 (setq skk-henkan-list (delq type3 skk-henkan-list)))))))) 505 506;;;###autoload 507(defun skk-num-process-user-minibuf-input (key) 508 (save-match-data 509 (let (numexp orglen val) 510 (if (or (and (string-match "#[012349]" key) 511 (setq numexp key)) 512 (and (setq numexp (skk-num-rawnum-exp key)) 513 (not (string= key numexp)))) 514 (progn 515 (setq orglen (length skk-henkan-list) 516 ;; skk-henkan-list ��Ĵ���ϡ�skk-num-convert ����ǹԤʤ� 517 ;; �Ƥ���롣 518 val (skk-num-convert numexp)) 519 (if (= (length skk-henkan-list) (1+ orglen)) 520 ;; #4 ��ʣ���θ�����Ѵ��Ǥ������ϳ��ꤷ�ʤ��� 521 (setq skk-kakutei-flag t))) 522 (setq skk-henkan-list (nconc skk-henkan-list (list key)) 523 skk-kakutei-flag t 524 val key)) 525 val))) 526 527;;;###autoload 528(defun skk-num-initialize () 529 ;; skk-use-numeric-convert ��Ϣ���ѿ����������롣 530 (setq skk-last-henkan-data 531 (put-alist 'num-list skk-num-list skk-last-henkan-data) 532 skk-num-list nil 533 skk-num-recompute-key nil)) 534 535;;;###autoload 536(defun skk-num-henkan-key () 537 ;; type4 �ο��ͺ��Ѵ����Ԥʤ�줿�Ȥ��ϡ����ͼ��Ȥ��֤�������ʳ��ο����Ѵ� 538 ;; �Ǥϡ�skk-henkan-key ���֤��� 539 (or skk-num-recompute-key skk-henkan-key)) 540 541;;;###autoload 542(defun skk-num-update-jisyo (noconvword word &optional purge) 543 ;; �������ȤФ���Ȥ��Ƽ���Υ��åץǡ��Ȥ�Ԥʤ��� 544 (if (and skk-num-recompute-key 545 (save-match-data (string-match "#4" noconvword))) 546 (with-current-buffer (skk-get-jisyo-buffer skk-jisyo 'nomsg) 547 (let ((skk-henkan-key skk-num-recompute-key) 548 skk-use-numeric-conversion) 549 (skk-update-jisyo word purge))))) 550 551;;;###autoload 552(defun skk-num (str) 553 ;; ������ skk-number-style ���ͤ˽����Ѵ����롣 554 ;; skk-current-date �Υ��֥롼���� 555 (mapconcat (function 556 (lambda (c) 557 (cond ((or (not skk-number-style) 558 (and (numberp skk-number-style) 559 (= skk-number-style 0))) 560 (char-to-string c)) 561 ((or (eq skk-number-style t) 562 (and (numberp skk-number-style) 563 (= skk-number-style 1))) 564 (cdr (assq c skk-num-alist-type1))) 565 (t (cdr (assq c skk-num-alist-type2)))))) 566 str "")) 567 568(run-hooks 'skk-num-load-hook) 569 570(provide 'skk-num) 571;;; Local Variables: 572;;; End: 573;;; skk-num.el ends here 574