/usr/share/emacs/site-lisp/t-code/tc-mazegaki.el is in t-code 2:2.3.1-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 | ;;; tc-mazegaki.el --- mazegaki conversion in T-Code
;; Copyright (C) 1996--2003 Kaoru Maeda, Yasushi Saito and KITAJIMA Akira.
;; Author: Kaoru Maeda <maeda@src.ricoh.co.jp>
;; Yasushi Saito <yasushi@is.s.u-tokyo.ac.jp>
;; KITAJIMA Akira <kitajima@isc.osakac.ac.jp>
;; Maintainer: KITAJIMA Akira
;; Created: 30 Apr 1996
;; Version: $Id: tc-mazegaki.el,v 1.38 2003/05/18 08:46:08 kitajima Exp $
;; Keywords: wp, japanese, input method
;; This program 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 2 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, write to the Free Software
;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
;;; Code:
(require 'tc)
(defgroup mazegaki-conversion nil
"¸ò¤¼½ñ¤ÊÑ´¹"
:group 'tcode)
;;; ¥«¥¹¥¿¥Þ¥¤¥º¤Ç¤¤ëÊÑ¿ô
(defvar tcode-mazegaki-selected-candidate-register ?\[
"* ¸ò¤¼½ñ¤ÊÑ´¹¤ÇºÇ¸å¤Ë³ÎÄꤷ¤¿Ê¸»úÎó¤òÊݸ¤·¤Æ¤ª¤¯¥ì¥¸¥¹¥¿¡£
nil ¤Î¾ì¹ç¤Ë¤ÏÊݸ¤µ¤ì¤Ê¤¤¡£")
(defvar tcode-mazegaki-dictionary-name "mazegaki.dic"
"¸ò¤¼½ñ¤ÊÑ´¹¼½ñ¤Î¥Õ¥¡¥¤¥ë̾¡£")
(defconst tcode-mazegaki-buffer-name " *tcode: mazegaki dictionary*")
;; ¸ò¤¼½ñ¤¼½ñ¤Î¥Ð¥Ã¥Õ¥¡Ì¾
(unless (assq tcode-mazegaki-buffer-name tcode-dictionaries)
(setq tcode-dictionaries (cons (cons tcode-mazegaki-buffer-name
tcode-mazegaki-dictionary-name)
tcode-dictionaries)))
(defcustom tcode-mazegaki-yomi-max 10 "* ¸ò¤¼½ñ¤ÊÑ´¹¤ÎÆɤߤκÇÂçʸ»ú¿ô¡£"
:group 'mazegaki-conversion)
(defvar tcode-mazegaki-terminate-char-list
(mapcar (lambda (ch) (tcode-string-to-char ch))
'("¡¢" "¡£" "¡¤" "¡¥" "¡¦" "¡Ö" "¡×" "¡Ê" "¡Ë"))
"* ¸ò¤¼½ñ¤ÊÑ´¹¤ÎÆɤߤ˴ޤޤì¤Ê¤¤2¥Ð¥¤¥Èʸ»ú¤Î¥ê¥¹¥È¡£")
(defcustom tcode-mazegaki-init-hook nil
"* ºÇ½é¤Ë tc-mazegaki.el ¤ò¥í¡¼¥É¤¹¤ë¤È¤¤Ë¸Æ¤Ð¤ì¤ë hook¡£"
:type 'hook :group 'mazegaki-conversion)
(defvar tcode-mazegaki-command-summary-alist
'(("½Ì¤á¤ë" . tcode-mazegaki-relimit-left)
("¿¤Ð¤¹" . tcode-mazegaki-relimit-right)
("³ÎÄê" . tcode-mazegaki-finish)
("Ì᤹" . tcode-mazegaki-restore-yomi-and-quit)
("°ìÍ÷" . tcode-mazegaki-table-mode)
("¼¡É½¤Þ¤¿¤Ï½Ì¤á" . tcode-mazegaki-select-candidate-or-relimit)
("ÅÐÏ¿&³ÎÄê" . tcode-mazegaki-make-entry-and-finish))
"* `tcode-mazegaki-command-summary' ¤Çɽ¼¨¤µ¤ì¤ëµ¡Ç½¤Î alist¡£")
(defvar tcode-mazegaki-enable-inflection t
"* nil ¤Ç¤Ê¤¤¤È¤¡¢²ÄÊѸìÈøÊÑ´¹¤¬¤Ç¤¤ë¡£")
(defvar tcode-mazegaki-prefix-mark
(if (or (tcode-nemacs-p)
(tcode-mule-1-p)
(and (boundp 'window-system)
(not window-system)))
(if (fboundp 'make-glyph)
(make-glyph "¢¤")
"¢¤")
nil)
"* ¸ò¤¼½ñ¤ÊÑ´¹¤Î»ÏÅÀ¤òɽ¤¹¤·¤ë¤·¡£")
(defvar tcode-mazegaki-face
(if (or (tcode-nemacs-p)
(tcode-mule-1-p)
(and (boundp 'window-system)
(not window-system)))
nil
(prog1
(make-face 'mazegaki-conversion)
(set-face-underline-p 'mazegaki-conversion t)))
"* ¸ò¤¼½ñ¤ÊÑ´¹¤ÎÊÑ´¹Âоݤòɽ¤¹Ê¸»úÎó¤ËÍѤ¤¤ëface¡£
mule2 °Ê¾å¤Þ¤¿¤Ï XEmacs ¤Î¾ì¹ç¤Î¤ß͸ú¡£")
(defvar tcode-mazegaki-prefix-overlay nil)
(defvar tcode-mazegaki-stroke-priority-list
; ¥¡¼ÇÛÃÖ
; 0 1 2 3 4 5 6 7 8 9
; 10 11 12 13 14 15 16 17 18 19
; 20 21 22 23 24 25 26 27 28 29
; 30 31 32 33 34 35 36 37 38 39
'(22 23 21 24 20
12 13 11 14 10
27 26 28 25 29
17 16 18 15 19)
"* ¸õÊä¤òʤ٤ë¤È¤¤Î°ÌÃÖ¡£
¤³¤Î¥ê¥¹¥È¤Ë¤Ê¤¤¥¡¼¤Ï»ÈÍѤµ¤ì¤Ê¤¤¡£")
(defvar tcode-mazegaki-alternative-select-first-keys
'(22)
"* ¸õÊä¤òÆó¤Ä¤ÎÃ椫¤é°ì¤ÄÁª¤Ö¾ì¹ç¤Î¡¢º¸Â¦(Âè1¸õÊä)¤òÁª¤Ö¥¡¼¤Î¥ê¥¹¥È¡£")
(defvar tcode-mazegaki-alternative-select-second-keys
'(23)
"* ¸õÊä¤òÆó¤Ä¤ÎÃ椫¤é°ì¤ÄÁª¤Ö¾ì¹ç¤Î¡¢±¦Â¦(Âè2¸õÊä)¤òÁª¤Ö¥¡¼¤Î¥ê¥¹¥È¡£")
(defvar tcode-mazegaki-complete-max 10
"* Êä´°¤ÎºÝ¤Ë°·¤¦¸õÊä¤Î¿ô¤ÎºÇÂçÃÍ¡£
¸õÊ䤬¤³¤ÎÃͰʾå¤Ê¤éÊä´°¤Ï¹Ô¤ï¤Ê¤¤¡£")
(defconst tcode-mazegaki-inflection-mark "¡½"
"Æɤߤ¬³èÍѤ¹¤ë¾ì¹ç¤Ë¡¢³èÍѸìÈø¤òɽ¤¹¤¿¤á¤Ë¤Ä¤±¤ëʸ»úÎó¡£")
(defvar tcode-mazegaki-max-suffix-length 4
"* ÆɤߤÎÃæ¤Î³èÍѸìÈø¤ÎºÇÂçʸ»ú¿ô¡£")
(defcustom tcode-mazegaki-fixed-priority-count 4
"* ³Ø½¬¤¹¤ë¤È¤¤Ë¡¢³Ø½¬¤ÎÂоݳ°¤È¤Ê¤ë¸õÊä¤Î¿ô¡£
¸½ºß¤ÎÆɤߤˤĤ¤¤Æ¡¢ÁªÂò¤µ¤ì¤¿¸õÊä¤Î½çÈÖ¤¬¤³¤Î¿ô°Ê²¼¤Ê¤é¤Ð¡¢³Ø½¬¤µ¤ì¤Ê¤¤¡£"
:group 'mazegaki-conversion)
(defcustom tcode-mazegaki-inline-candidate-count 0
"* ¸õÊ䤬ʣ¿ô¤¢¤Ã¤Æ¤â¡¢Âè1¸õÊä¤ò¥¤¥ó¥é¥¤¥óɽ¼¨¤¹¤ë²ó¿ô"
:group 'mazegaki-conversion)
(defvar tcode-mazegaki-splitter "|"
"* ÅÐÏ¿¤ÎºÝ¤Î¡¢Æɤߤª¤è¤Ó´Á»ú¤Î¶èÀÚ¤ê¤òɽ¤¹Àµµ¬É½¸½")
;;; ¤½¤Î¾¤ÎÊÑ¿ô
(defvar tcode-mazegaki-yomi-list nil
"ÊÑ´¹³«»Ï»þÅÀ¤Ç¥«¡¼¥½¥ë¤è¤êÁ°¤Ë¤¢¤Ã¤¿Ê¸»ú¤Î¥ê¥¹¥È¡£
¥«¡¼¥½¥ë¤ÎľÁ°¤Îʸ»ú¤¬ car¡¢¤½¤ÎÁ°¤¬ cadr¡¢°Ê²¼Æ±ÍÍ¡£
ºÇÂç `tcode-mazegaki-yomi-max' ʸ»ú¤Þ¤Ç¡£")
(defvar tcode-mazegaki-current-yomi-length 0
"¸½ºßÊÑ´¹ÂоݤȤʤäƤ¤¤ëʸ»úÎó¤ÎŤµ¡£
\(length tcode-mazegaki-yomi-list\)°Ê²¼¤Ç¤¢¤ë¡£")
(defvar tcode-mazegaki-current-offset 0
"`tcode-mazegaki-yomi-list' ¤Î²¿ÈÖÌܤÎʸ»ú¤«¤éÆɤߤȤߤʤ¹¤«¡£")
(defvar tcode-mazegaki-current-yomi-point nil)
(defvar tcode-mazegaki-yomi-fixed nil
"²ÄÊÑĹÆɤßÊÑ´¹Ãæ¤Ê¤é¤Ð nil¡¢¤½¤¦¤Ç¤Ê¤¤¤Ê¤é t¡£
¤Ä¤Þ¤ê¡¢¡Öfj¡×¤òÁ°ÃÖ¤·¤ÆÆɤߤ¬ÆþÎϤµ¤ì¤¿¾ì¹ç¤Ë¤Ï¤³¤ÎÊÑ¿ô¤ÎÃÍ¤Ï t ¤Ç¤¢¤ê¡¢
¤½¤ì°Ê³°¤Î¾ì¹ç¤Ï nil ¤Ç¤¢¤ë¡£")
(defvar tcode-mazegaki-map nil "¸ò¤¼½ñ¤ÊÑ´¹Ãæ¤Î¥¡¼¥Þ¥Ã¥×¡£")
(defvar tcode-mazegaki-mode nil "¸ò¤¼½ñ¤ÊÑ´¹Ã椫¤É¤¦¤«¤òɽ¤¹ÊÑ¿ô¡£
¼ÂºÝ¤Ë¤Ï¡¢¸ò¤¼½ñ¤ÊÑ´¹ÂоݤÎÀèƬ¤Î¥Ý¥¤¥ó¥È¤òÊÝ»ý¤·¤Æ¤¤¤ë¡£")
(make-variable-buffer-local 'tcode-mazegaki-mode)
(defvar tcode-mazegaki-prefix nil)
(make-variable-buffer-local 'tcode-mazegaki-prefix)
(defvar tcode-mazegaki-suffix ""
"ÊÑ´¹¤ÎÂоݳ°¤È¤Ê¤ëÀÜÈø¸ì¡£")
(defvar tcode-mazegaki-conversion-overlay nil
"¸ò¤¼½ñ¤ÊÑ´¹¤ÎÊÑ´¹Âоݤòɽ¤¹ overlay¡£")
(make-variable-buffer-local 'tcode-mazegaki-conversion-overlay)
(defvar tcode-mazegaki-inflection-only nil
"³èÍÑÊÑ´¹Ã椫¤É¤¦¤«¡£")
(defvar tcode-mazegaki-with-inflection nil
"³èÍѤ¹¤ëÆɤߤòÊÑ´¹ÂоݤȤ·¤Æ¤¤¤ë¤«¤É¤¦¤«¡£")
(defvar tcode-mazegaki-candidate-state nil
"¸ò¤¼½ñ¤¸õÊäɽ¼¨¥¹¥Æ¡¼¥È¡£
'next ¼¡¸õÊäɽ¼¨¤Î¤¿¤á¤ÎÃæ´Ö¾õÂÖ
'one ¸õÊ䤬¤Ò¤È¤Ä¤·¤«¤Ê¤¯¥¤¥ó¥é¥¤¥óɽ¼¨Ãæ
'priority Ê£¿ô¸õÊä¤ÎºÇ½é¤ÎÊý¤ò¥¤¥ó¥é¥¤¥óɽ¼¨Ãæ
'table ɽ·Á¼°¤ÇÁªÂòÃæ
ÊÑ´¹³«»Ï(ÊÑ´¹Ä¾¸å¤Þ¤¿¤ÏÆɤߍµÊѹ¹Ä¾¸å)
¢ª ¸õÊä¿ô¤Ë¤è¤Ã¤Æone¤Þ¤¿¤Ïnext
next
candidate-index¤¬¸õÊä¿ô¤è¤ê¾®¤µ¤¯¤«¤Ä
inline-candidate-count¤è¤ê¾®¤µ¤¤
¢ª priority
else
¢ª table
one
SPCÆþÎÏ
¢ª ½Ì¤á
= ÆþÎÏ
¢ª one
priority
SPCÆþÎÏ
¢ª candidate-index++¤·¡¢next
= ÆþÎÏ
¢ª table
table
SPCÆþÎÏ
¢ª ¼¡¥Ú¡¼¥¸
")
(defvar tcode-mazegaki-candidate-index nil
"priority¥¹¥Æ¡¼¥È¤Ç¥¤¥ó¥é¥¤¥óɽ¼¨Ãæ¤Î¸õÊä¤Ï²¿ÈÖÌܤ«(0¥ª¥ê¥¸¥ó)¡£
See also variable `tcode-mazegaki-candidate-state'.")
(defvar tcode-mazegaki-start-marker nil)
(make-variable-buffer-local 'tcode-mazegaki-start-marker)
;;;; ¼½ñ¤Î¸¡º÷¤ÈÊÑ´¹
(cond ((or (tcode-nemacs-p) (tcode-mule-1-p))
(defun tcode-mazegaki-delete-conversion-face ()
(if tcode-mazegaki-prefix-overlay
(save-excursion
(goto-char tcode-mazegaki-prefix-overlay)
(if (looking-at (regexp-quote tcode-mazegaki-prefix-mark))
(delete-char 1))))
(setq tcode-mazegaki-prefix-overlay nil))
(defun tcode-mazegaki-put-conversion-face ()
(let ((point (or tcode-mazegaki-mode
tcode-mazegaki-prefix)))
(when point
(save-excursion
(goto-char point)
(tcode-mazegaki-delete-conversion-face)
(setq tcode-mazegaki-prefix-overlay (point))
(insert tcode-mazegaki-prefix-mark))))))
((tcode-xemacs-p)
(defun tcode-mazegaki-put-conversion-face ()
"ÊÑ´¹³«»Ï°ÌÃÖ¤«¤é point ¤Þ¤Ç¤ò»ØÄꤵ¤ì¤¿ face ¤Ë¤¹¤ë¡£
face ¤Î»ØÄê¤ÏÊÑ¿ô `tcode-mazegaki-prefix-mark' ¤òÀßÄꤹ¤ë¤³¤È¤Ë¤è¤ê¹Ô¤¦¡£"
(let ((point (or tcode-mazegaki-mode
tcode-mazegaki-prefix)))
(when point
(when tcode-mazegaki-prefix-mark
(setq tcode-mazegaki-prefix-overlay
(if (extentp tcode-mazegaki-prefix-overlay)
(set-extent-endpoints tcode-mazegaki-prefix-overlay
point
point)
(make-extent point point)))
(set-extent-begin-glyph tcode-mazegaki-prefix-overlay
tcode-mazegaki-prefix-mark))
(if (extentp tcode-mazegaki-conversion-overlay)
(set-extent-endpoints tcode-mazegaki-conversion-overlay
point
(point))
(setq tcode-mazegaki-conversion-overlay
(make-extent point (point)))
(set-extent-face tcode-mazegaki-conversion-overlay
tcode-mazegaki-face)))))
(defun tcode-mazegaki-delete-conversion-face ()
"¸ò¤¼½ñ¤ÊÑ´¹ÍѤΠface ¤È prefix ¤ò½ü¤¯¡£"
(if (extentp tcode-mazegaki-prefix-overlay)
(detach-extent tcode-mazegaki-prefix-overlay))
(if (extentp tcode-mazegaki-conversion-overlay)
(detach-extent tcode-mazegaki-conversion-overlay))))
(t
(unless (fboundp 'make-overlay)
(require 'overlay))
;; face ¤Ë¤è¤êÊÑ´¹ÂоÝÎΰè¤òɽ¼¨¤¹¤ë¤¿¤á¤Î´Ø¿ô¤ÎÄêµÁ
(defun tcode-mazegaki-put-conversion-face ()
"ÊÑ´¹³«»Ï°ÌÃÖ¤«¤é point ¤Þ¤Ç¤ò»ØÄꤵ¤ì¤¿ face ¤Ë¤¹¤ë¡£
face ¤Î»ØÄê¤ÏÊÑ¿ô `tcode-mazegaki-face' ¤òÀßÄꤹ¤ë¤³¤È¤Ë¤è¤ê¹Ô¤¦¡£
ÊÑ¿ô `tcode-mazegaki-prefix-mark' ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ì¤Ð¡¢¤½¤Îʸ»úÎó¤ò
ÀèƬ¤ËÃÖ¤¯¡£"
(let ((point (or tcode-mazegaki-mode
tcode-mazegaki-prefix)))
(when point
;; prefix ¤òÃÖ¤¯¡£
(when tcode-mazegaki-prefix-mark
(setq tcode-mazegaki-prefix-overlay
(if (overlayp tcode-mazegaki-prefix-overlay)
(move-overlay tcode-mazegaki-prefix-overlay
point
point)
(make-overlay point point)))
(overlay-put tcode-mazegaki-prefix-overlay
'before-string
tcode-mazegaki-prefix-mark))
;; face ¤òÀßÄꤹ¤ë¡£
(if (overlayp tcode-mazegaki-conversion-overlay)
(move-overlay tcode-mazegaki-conversion-overlay point (point))
(setq tcode-mazegaki-conversion-overlay
(make-overlay point (point)))
(overlay-put tcode-mazegaki-conversion-overlay
'face
tcode-mazegaki-face)))))
(defun tcode-mazegaki-delete-conversion-face ()
"¸ò¤¼½ñ¤ÊÑ´¹ÍѤΠface ¤È prefix ¤ò½ü¤¯¡£"
(if (overlayp tcode-mazegaki-prefix-overlay)
(delete-overlay tcode-mazegaki-prefix-overlay))
(if (overlayp tcode-mazegaki-conversion-overlay)
(delete-overlay tcode-mazegaki-conversion-overlay)))))
;;;###autoload
(defun tcode-mazegaki-switch-to-dictionary ()
"current-buffer ¤ò¸ò¤¼½ñ¤¼½ñ¤ËÀÚ¤êÂؤ¨¤ë¡£
¸ò¤¼½ñ¤¼½ñ¤¬¤Þ¤ÀÆɤ߹þ¤Þ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ë¤ÏÆɤ߹þ¤à¡£"
(interactive)
(let ((buffer (tcode-set-work-buffer tcode-mazegaki-buffer-name
tcode-mazegaki-dictionary-name)))
(if (interactive-p)
(switch-to-buffer buffer))))
(defun tcode-mazegaki-construct-yomi (len &optional offset inflection)
"`tcode-mazegaki-yomi-list' ¤«¤é¡¢Ä¹¤µ LEN ¤ÎÆɤߤòºî¤ë¡£
OFFSET ¤¬»ØÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ï¡¢OFFSET ʸ»ú¤Ï³èÍѸìÈø¤È¤·¡¢Æɤߤˤϴޤ᤺¡¢
INFLECTION ¤¬ nil ¤Ç¤Ê¤±¤ì¤Ð `tcode-mazegaki-inflection-mark' ¤ÇÃÖ¤´¹¤¨¤ë¡£"
(let ((list (mapcar 'cdr
(if offset
(nthcdr offset tcode-mazegaki-yomi-list)
tcode-mazegaki-yomi-list)))
(str ""))
(while (> len 0)
(setq str (concat (car list) str)
list (cdr list)
len (1- len)))
(if inflection
(concat str tcode-mazegaki-inflection-mark)
str)))
(defun tcode-mazegaki-list-to-string (list from len)
"ʸ»ú¤Î LIST ¤Î FROM ¤«¤é LEN ʸ»úʬ¤Îʸ»úÎó¤òºî¤ë¡£"
(let ((str ""))
(setq list (nthcdr from list))
(while (> len 0)
(setq str (concat (cdr (car list)) str)
list (cdr list)
len (1- len)))
str))
(defun tcode-mazegaki-get-reverse-yomi-list ()
"¸½ point ¤è¤ê¸åÊý¤Ë¤¢¤ëÆüËܸìÎó¤Þ¤¿¤Ï±Ññ¸ì°ì¤Ä¤Î¥ê¥¹¥È¤òÊÖ¤¹¡£
¥ê¥¹¥È¤ÎŤµ¤ÏºÇÂç `tcode-mazegaki-yomi-max' ʸ»ú¡£"
(setq tcode-mazegaki-suffix ""
tcode-mazegaki-yomi-fixed tcode-mazegaki-mode)
(save-excursion
(let (context reverse-list)
(catch 'finish
(while (and (< (length reverse-list)
tcode-mazegaki-yomi-max)
(setq context
(tcode-scan-backward
1 tcode-mazegaki-terminate-char-list)))
(let ((ch (cdr (car context)))
(point (car (car context))))
(if (and reverse-list
(or (= (point) point)
(>= (count-lines point (point)) (if (bolp) 2 3))))
(throw 'finish nil))
(if (and (null reverse-list)
(memq (tcode-string-to-char ch)
tcode-mazegaki-terminate-char-list))
;; `tcode-mazegaki-terminate-char-list' ¤Ë¤¢¤ëʸ»ú¤ò¤È¤Ð¤¹¡£
(setq tcode-mazegaki-suffix
(concat ch tcode-mazegaki-suffix))
;; Æɤߤò1»úÆÀ¤ë
(setq reverse-list (cons (car context) reverse-list))
(if (and tcode-mazegaki-prefix
(= point tcode-mazegaki-prefix))
(throw 'finish nil)))
(goto-char point))))
(nreverse reverse-list))))
(defun tcode-mazegaki-search-yomi (yomi)
"¸½ºß¤Î¥Ð¥Ã¥Õ¥¡¤«¤é YOMI ¤ò¸«¤Ä¤±¡¢ point ¤ò°ÜÆ°¤¹¤ë¡£
¸«¤Ä¤«¤é¤Ê¤¤¾ì¹ç¤Ï¡¢ point ¤Ï¤½¤Î YOMI ¤¬¤¢¤ë¤Ù¤¾ì½ê¤Ë°ÜÆ°¤¹¤ë¡£"
(let ((min (point-min))
(max (point-max))
str)
(catch 'found
(and (eobp)
(forward-line -1))
(while (< min max)
(beginning-of-line)
(cond ((string< (setq str (buffer-substring
(point)
(progn
(while (/= (tcode-following-char) ?/)
(tcode-forward-char 1))
(1- (point)))))
yomi)
;; ¤â¤Ã¤ÈÂ礤¤
(forward-line 1)
(goto-char (ash (+ (setq min (point)) max) -1)))
((string< yomi str)
;; ¤â¤Ã¤È¾®¤µ¤¤
(beginning-of-line)
(goto-char (ash (+ min (setq max (point))) -1)))
;; ¸«¤Ä¤±¤¿
(t
(beginning-of-line)
(throw 'found (point))))))))
(defun tcode-mazegaki-lookup (new)
"¸½ºß¤ÎÆɤߤè¤êû¤¤ºÇŤÎÆɤߤòõ¤¹¡£
NEW ¤¬ nil ¤Ç¤Ê¤±¤ì¤Ð¡¢¿·¤·¤¯Ãµ¤·»Ï¤á¤ë¡£
¸«¤Ä¤«¤ì¤Ð¤½¤ÎÆɤߤÎŤµ¤ª¤è¤Ó offset (¾ï¤Ë 0) ¤ò¡¢¤Ê¤±¤ì¤Ð nil ¤òÊÖ¤¹¡£
¸ò¤¼½ñ¤¼½ñ¤Î¥Ý¥¤¥ó¥È¤Ï¤½¤ÎÆɤߤΤȤ³¤í¤Ë°ÜÆ°¤¹¤ë¡£"
(save-excursion
(setq tcode-mazegaki-with-inflection nil)
(tcode-mazegaki-switch-to-dictionary)
(let* ((max (length tcode-mazegaki-yomi-list))
(min (if tcode-mazegaki-yomi-fixed (1- max) 0))
(i (if new max (1- tcode-mazegaki-current-yomi-length))))
(catch 'found
(while (> i min)
(when (tcode-mazegaki-search-yomi (tcode-mazegaki-construct-yomi i))
(setq tcode-mazegaki-current-yomi-point (point))
(throw 'found (cons (car (nth (1- i) tcode-mazegaki-yomi-list))
(cons i 0))))
(setq i (1- i)))))))
(defun tcode-mazegaki-lookup-with-inflection (new)
"¸½ºß¤ÎÆɤߤè¤êû¤¤¡¢³èÍѤ¹¤ëºÇŤÎÆɤߤòõ¤¹¡£
NEW ¤¬ nil ¤Ç¤Ê¤±¤ì¤Ð¡¢¿·¤·¤¯Ãµ¤·»Ï¤á¤ë¡£
¸«¤Ä¤«¤ì¤Ð¤½¤ÎÆɤߤÎŤµ¤ª¤è¤Ó offset ¤ò¡¢¤Ê¤±¤ì¤Ð nil ¤òÊÖ¤¹¡£
¸ò¤¼½ñ¤¼½ñ¤Î¥Ý¥¤¥ó¥È¤Ï¤½¤ÎÆɤߤΤȤ³¤í¤Ë°ÜÆ°¤¹¤ë¡£"
(save-excursion
(setq tcode-mazegaki-with-inflection t)
(tcode-mazegaki-switch-to-dictionary)
(let* ((max (length tcode-mazegaki-yomi-list))
(min 0)
(i (if new max tcode-mazegaki-current-yomi-length))
(offset (cond (new
(cond ((>= (+ i tcode-mazegaki-max-suffix-length)
max)
(- max i))
(tcode-mazegaki-yomi-fixed
-1)
(t
tcode-mazegaki-max-suffix-length)))
(tcode-mazegaki-yomi-fixed
-1)
(t
(1- tcode-mazegaki-current-offset)))))
(catch 'found
(while (> i min)
(while (>= offset 0)
(and (string-match "^[¤¡-¥ó]*$"
(tcode-mazegaki-construct-yomi offset))
(tcode-mazegaki-search-yomi
(tcode-mazegaki-construct-yomi i offset t))
(setq tcode-mazegaki-current-yomi-point (point))
(throw 'found (cons (car (nth (1- (+ i offset))
tcode-mazegaki-yomi-list))
(cons i offset))))
(setq offset (if tcode-mazegaki-yomi-fixed -1 (1- offset))))
(setq i (1- i)
offset (cond ((>= (+ i tcode-mazegaki-max-suffix-length)
max)
(- max i))
(tcode-mazegaki-yomi-fixed
-1)
(t
tcode-mazegaki-max-suffix-length))))))))
(defun tcode-mazegaki-lookup-reverse (new)
"¸½ºß¤ÎÆɤߤè¤ê¤âŤ¤ºÇû¤ÎÆɤߤò¸«¤Ä¤±¤ë¡£
¸«¤Ä¤«¤ì¤Ð¤½¤ÎÆɤߤÎŤµ¤ª¤è¤Ó offset (¾ï¤Ë 0) ¤ò¡¢¤Ê¤±¤ì¤Ð nil ¤òÊÖ¤¹¡£
¸ò¤¼½ñ¤¼½ñ¤Î¥Ý¥¤¥ó¥È¤Ï¤½¤ÎÆɤߤΤȤ³¤í¤Ë°ÜÆ°¤¹¤ë¡£"
(save-excursion
(setq tcode-mazegaki-with-inflection nil)
(tcode-mazegaki-switch-to-dictionary)
(let* ((max (length tcode-mazegaki-yomi-list))
(i (cond (new (if tcode-mazegaki-yomi-fixed max 1))
(tcode-mazegaki-yomi-fixed (1+ max))
(t (1+ tcode-mazegaki-current-yomi-length)))))
(catch 'found
(while (<= i max)
(when (tcode-mazegaki-search-yomi (tcode-mazegaki-construct-yomi i))
(setq tcode-mazegaki-current-yomi-point (point))
(throw 'found (cons (car (nth (1- i) tcode-mazegaki-yomi-list))
(cons i 0))))
(setq i (1+ i)))))))
(defun tcode-mazegaki-lookup-with-inflection-reverse (new)
"¸½ºß¤ÎÆɤߤè¤ê¤âŤ¤ºÇû¤Î³èÍѤ¹¤ëÆɤߤò¸«¤Ä¤±¤ë¡£
¸«¤Ä¤«¤ì¤Ð¤½¤ÎÆɤߤÎŤµ¤ª¤è¤Ó offset ¤ò¡¢¤Ê¤±¤ì¤Ð nil ¤òÊÖ¤¹¡£
¸ò¤¼½ñ¤¼½ñ¤Î¥Ý¥¤¥ó¥È¤Ï¤½¤ÎÆɤߤΤȤ³¤í¤Ë°ÜÆ°¤¹¤ë¡£"
(save-excursion
(setq tcode-mazegaki-with-inflection t)
(tcode-mazegaki-switch-to-dictionary)
(let* ((max (length tcode-mazegaki-yomi-list))
(i (if new 1 tcode-mazegaki-current-yomi-length))
(offset (cond (new (cond ((not tcode-mazegaki-yomi-fixed)
0)
((<= (- max i)
tcode-mazegaki-max-suffix-length)
(- max i))
(t
max)))
((or tcode-mazegaki-yomi-fixed
(>= tcode-mazegaki-current-offset
tcode-mazegaki-max-suffix-length))
max)
(t (1+ tcode-mazegaki-current-offset)))))
(catch 'found
(while (<= i max)
(while (<= (+ i offset) max)
(and (string-match "^[¤¡-¥ó]*$"
(tcode-mazegaki-construct-yomi offset))
(tcode-mazegaki-search-yomi
(tcode-mazegaki-construct-yomi i offset t))
(setq tcode-mazegaki-current-yomi-point (point))
(throw 'found (cons (car (nth (1- (+ i offset))
tcode-mazegaki-yomi-list))
(cons i offset))))
(setq offset (if (>= offset
tcode-mazegaki-max-suffix-length)
max
(1+ offset))))
(setq i (1+ i)
offset (cond ((not tcode-mazegaki-yomi-fixed)
0)
((<= (- max i)
tcode-mazegaki-max-suffix-length)
(- max i))
(t max))))))))
(defun tcode-mazegaki-erase-previous-candidate ()
"¸½ºß¥Ð¥Ã¥Õ¥¡¤Ëɽ¼¨¤µ¤ì¤Æ¤¤¤ëÊÑ´¹¸õÊä¤ò¾Ãµî¤¹¤ë¡£"
(if tcode-mazegaki-mode
(delete-region tcode-mazegaki-mode (point))))
;;;###autoload
(defun tcode-mazegaki-convert (arg &optional inflection)
"¸½ point ¤è¤ê¸åÊý¤Ë¤¢¤ëÆüËܸìÎó¤ò¡ÖÆɤߡפȤ·¤Æ¸ò¤¼½ñ¤ÊÑ´¹¤ò»î¤ë¡£
ARG ¤Ï¼¡¤ò°ÕÌ£¤¹¤ë¡£
* C-u ¤Î¤ß¤Þ¤¿¤Ï - ¤Î¤ß
³èÍѤ¹¤ë¸ì¤È¤·¤ÆÊÑ´¹(ÆɤߤÎŤµ¤ÏºÇĹ°ìÃ×)
* À°¿ô
¤½¤ÎÀäÂÐÃͤòÆɤߤÎŤµ¤È¤·¤ÆÊÑ´¹
¤¿¤À¤·¡¢ÊÑ´¹¤¹¤ë¤Î¤Ï¡¢Àµ¤Î¾ì¹ç¤Ï³èÍѤ·¤Ê¤¤¸ì¡¢
Éé¤Î¾ì¹ç¤Ï³èÍѤ¹¤ë¸ì¤È¤¹¤ë¡£
INFLECTION ¤¬ nil ¤Ç¤Ê¤±¤ì¤Ð¡¢ARG ¤ÎÃͤˤè¤é¤º¡¢³èÍѤ¹¤ë¸ì¤È¤·¤ÆÊÑ´¹¤ò¹Ô¤¦¡£"
(interactive "*P")
(tcode-mazegaki-candidate-select-init)
(setq tcode-mazegaki-inflection-only (or (eq arg '-)
(and (integerp arg)
(< arg 0))
(and arg
(listp arg))
inflection))
(let ((tcode-mazegaki-yomi-max (if (integerp arg)
(if (>= arg 0) arg (- arg))
tcode-mazegaki-yomi-max)))
(unless (setq tcode-mazegaki-yomi-list
(tcode-mazegaki-get-reverse-yomi-list))
(let (tcode-auto-help)
(tcode-mazegaki-finish)
(error "Æɤߤ¬¤¢¤ê¤Þ¤»¤ó¡£"))))
(and (integerp arg)
(or tcode-mazegaki-yomi-fixed
(= (length tcode-mazegaki-yomi-list)
(if (>= arg 0) arg (- arg)))
(error "Æɤߤ¬Ã»¤«¤¹¤®¤Þ¤¹¡£"))
(setq tcode-mazegaki-yomi-fixed t))
;; ¼½ñ¤ËÆɤߤ¬¤¢¤ë¤«Ä´¤Ù¡¢¤¢¤ì¤ÐÊÑ´¹¤¹¤ë¡£
(let ((with-inflection (and tcode-mazegaki-enable-inflection
(or inflection
(not (and (integerp arg)
(> arg 0)))))))
(let* ((tcode-mazegaki-enable-inflection with-inflection)
(yomi-info (or (and (not tcode-mazegaki-inflection-only)
(tcode-mazegaki-lookup t))
(and (or tcode-mazegaki-enable-inflection
tcode-mazegaki-inflection-only)
(tcode-mazegaki-lookup-with-inflection t)))))
(if yomi-info
;; ¸õÊ䤬¸«¤Ä¤«¤Ã¤¿¡£
(prog1
(setq tcode-mazegaki-current-yomi-length (car (cdr yomi-info))
tcode-mazegaki-current-offset (cdr (cdr yomi-info)))
;; i ʸ»ú¤Î¸õÊä¤ÎÀèƬ¤Ë°õ(¢¤)¤ò¤Ä¤±¤ë¡£
(save-excursion
(goto-char (car yomi-info))
(if tcode-mazegaki-mode
(if (/= tcode-mazegaki-mode (point))
(let (tcode-auto-help)
(tcode-mazegaki-finish)
(error "Æɤߤ¬Ä¹¤¹¤®¤Þ¤¹¡£")))
(setq tcode-mazegaki-mode (point))))
(condition-case nil
(let ((echo-keystrokes 0))
(tcode-mazegaki-put-conversion-face)
(tcode-mazegaki-select-candidate)
(while tcode-mazegaki-mode
(let* ((keyseq (read-char))
(command (lookup-key tcode-mazegaki-map
(char-to-string keyseq))))
(if (not (commandp command))
(progn
(tcode-mazegaki-finish)
(tcode-redo-command keyseq))
(setq prefix-arg current-prefix-arg
this-command command)
(command-execute command))))
(tcode-mazegaki-finish))
(quit
(ding)
(tcode-mazegaki-restore-yomi-and-quit))))
;; ¸õÊ䤬̵¤«¤Ã¤¿¡£
(setq this-command 'tcode-mazegaki-begin-conversion)
; ÅÐÏ¿¤ò¹Ô¤¦¤È¤¤ËÍѤ¤¤ëºÙ¹©
(ding)
(tcode-verbose-message
(tcode-substitute-command-keys
(concat "ŬÅö¤Ê´Á»ú¤Ï¤¢¤ê¤Þ¤»¤ó"
" (¡Ö\\[tcode-mazegaki-make-entry-and-finish]¡×¤ÇÅÐÏ¿)")))
nil))))
;;;###autoload
(defun tcode-mazegaki-begin-conversion (arg)
"¸ò¤¼½ñ¤ÊÑ´¹¤ò³«»Ï¤¹¤ë¡£"
(interactive "*P")
(undo-boundary)
(cond (tcode-mazegaki-mode
(if tcode-mazegaki-yomi-list
(tcode-mazegaki-get-reverse-yomi-list))
(tcode-mazegaki-convert arg))
(tcode-use-prefix-mazegaki
(tcode-mazegaki-put-prefix))
(t
(tcode-mazegaki-convert arg))))
;;;###autoload
(defun tcode-mazegaki-begin-alternate-conversion (arg)
"¸ò¤¼½ñ¤ÊÑ´¹¤ò³«»Ï¤¹¤ë¡£¤¿¤À¤·¡¢Á°ÃÖ·¿¡¦¸åÃÖ·¿¤¬µÕ¡£"
(interactive "*P")
(call-interactively (if tcode-use-prefix-mazegaki
'tcode-mazegaki-convert
'tcode-mazegaki-put-prefix)))
;;;###autoload
(defun tcode-mazegaki-lookup-with-prefix (char-list)
"CHAR-LIST¤¬ÆɤߤÎÀèƬ¤Ë¤Ê¤Ã¤Æ¤¤¤ë¸õÊä¤Î¥ê¥¹¥È¤òÊÖ¤¹¡£"
(let ((tcode-mazegaki-yomi-list
(mapcar (lambda (e)
(cons 0 (char-to-string e)))
(reverse char-list)))
(prefix (regexp-quote (mapconcat 'char-to-string char-list nil)))
candidate-list
result)
(save-excursion
(tcode-mazegaki-switch-to-dictionary)
(tcode-mazegaki-search-yomi prefix)
(while (looking-at prefix)
(setq tcode-mazegaki-current-yomi-point (point)
candidate-list (nconc candidate-list
(tcode-mazegaki-get-candidate-list)))
(forward-line 1))
;; ½ÅÊ£¤Îºï½ü
(while candidate-list
(let ((candidate (car candidate-list)))
(setq result (nconc result (list candidate))
candidate-list (delete candidate candidate-list)))))
result))
;;;; ¸õÊä¤ÎÁªÂò
(defun tcode-mazegaki-candidate-select-init ()
"¥¹¥Æ¡¼¥È¾ðÊó¤ò½é´üÃͤËÌ᤹¡£"
(setq tcode-mazegaki-candidate-state nil
tcode-mazegaki-candidate-index 0))
(defun tcode-mazegaki-find-kanji-entry ()
"¸½ºß¤ÎÆɤߤÎ(ºÇ½é¤Î)¥¨¥ó¥È¥ê¤Þ¤Ç¸ò¤¼½ñ¤¼½ñ¤Î point ¤ò°ÜÆ°¤¹¤ë¡£
Àµ³Î¤Ë¤Ï¡¢point ¤ÏºÇ½é¤Î¥¨¥ó¥È¥ê¤ÎÀèƬ¤Ë¤¢¤ë\"/\"¤Îľ¸å¤Ë°ÜÆ°¤¹¤ë¡£"
(tcode-mazegaki-switch-to-dictionary)
(goto-char tcode-mazegaki-current-yomi-point)
(beginning-of-line)
(search-forward " /" nil t))
(defun tcode-mazegaki-get-number-of-candidate ()
"¸½ºß¤ÎÆɤߤθõÊä¤Î¿ô¤òÆÀ¤ë¡£"
(save-excursion
(tcode-mazegaki-find-kanji-entry)
(let ((noc 0)
(p (point)))
(while (not (eolp))
(if (= (following-char) ?/)
(setq noc (1+ noc)))
(tcode-forward-char 1))
noc)))
(defun tcode-mazegaki-get-candidate-list ()
"¸½ºß¤ÎÆɤߤ«¤é¸õÊä¤Î¥ê¥¹¥È¤òºî¤ë¡£"
(save-excursion
(tcode-mazegaki-find-kanji-entry)
(let (list)
(while (not (eolp))
(setq list (nconc list
(list (buffer-substring
(point)
(prog2
(search-forward "/" nil t)
(1- (point))))))))
list)))
(defun tcode-mazegaki-make-candidate-table (candidate-list)
" CANDIDATE-LIST ¤«¤é¸õÊä¤Îɽ¤òºî¤ë¡£
¸õÊä¤Îɽ¤Ë¤ª¤±¤ë°ÌÃ֤ϡ¢ÊÑ¿ô `tcode-mazegaki-stroke-priority-list' ¤Ë½¾¤¦¡£"
(let ((plist tcode-mazegaki-stroke-priority-list)
(table (make-vector 40 nil)))
(while (and candidate-list plist)
(aset table (car plist) (car candidate-list))
(setq candidate-list (cdr candidate-list)
plist (cdr plist)))
table))
(defun tcode-mazegaki-select (candidate-table noc current-offset
&optional msg suffix)
"CANDIDATE-TABLE ¤«¤é¸õÊä¤òÁªÂò¤µ¤»¤ë¡£
NOC (¸õÊä¤Î¿ô)¤È CURRENT-OFFSET ¤«¤é¸½ºß²¿ÈÖÌܤÎɽ¤òɽ¼¨¤·¤Æ¤¤¤ë¤«·×»»¤¹¤ë¡£"
(let* ((plist-size (length tcode-mazegaki-stroke-priority-list))
(whole-page (/ (+ noc (1- plist-size)) plist-size))
(page (- (1+ whole-page)
(/ (+ (- noc current-offset) (1- plist-size)) plist-size)))
(whole-table (or (and (catch 'found
;; 3ÃÊÌܰʳ°¤ò»È¤¦¤³¤È¤ò³Î¤«¤á¤ë¡£
(mapcar (lambda (e) (if (or (< e 20)
(>= e 30))
(throw 'found t)))
tcode-mazegaki-stroke-priority-list)
nil)
(> whole-page 1))
;; 3ÃÊÌܰʳ°¤Ë¸õÊ䤬¤¢¤ë¤«Ä´¤Ù¤ë
(catch 'found
(let ((i 0))
(while (< i 40)
(and (aref candidate-table i)
(throw 'found t))
(setq i (if (= i 19) 30 (1+ i)))))))))
(if whole-table
(progn
(if suffix
(setq msg (concat msg " " suffix)))
(if (not (and (window-minibuffer-p (selected-window))
(null msg)))
(message (or msg "")))
(tcode-display-help-buffer
(tcode-draw-table candidate-table page whole-page) t))
(let ((candidate-list (mapcar (lambda (n)
(or (aref candidate-table n)
"-"))
'(20 21 22 23 24 25 26 27 28 29))))
(message
(concat msg
(if (= whole-page 1)
""
(format "(%d/%d) " page whole-page))
(apply 'format
(cons "[%s %s %s %s] %s %s [%s %s %s %s]"
candidate-list))
" "
suffix)))))
(let* ((echo-keystrokes 0)
(ch (read-char))
(key (tcode-char-to-key ch)))
(message "")
(if (< key 0)
ch
(or (aref candidate-table (mod key 40))
ch))))
(defun tcode-mazegaki-make-table-and-select (&optional
msg candidate-list inline)
"¸½ºß¤ÎÆɤߤ«¤é¸õÊä¤òÁªÂò¤µ¤»¡¢¤½¤Îʸ»úÎó¤Þ¤¿¤Ïʸ»ú(¥¡¼)¤òÊÖ¤¹¡£"
(or candidate-list
(setq candidate-list (tcode-mazegaki-get-candidate-list)))
(let* ((noc (length candidate-list))
(plist-size (length tcode-mazegaki-stroke-priority-list))
(suffix (and tcode-mazegaki-with-inflection
(concat (tcode-mazegaki-construct-yomi
tcode-mazegaki-current-yomi-length
tcode-mazegaki-current-offset)
"("
(if (zerop tcode-mazegaki-current-offset)
tcode-mazegaki-inflection-mark
(tcode-mazegaki-construct-yomi
tcode-mazegaki-current-offset))
")"))))
(if (<= noc 1)
(car candidate-list)
(if (and inline
(= noc 2)
tcode-mazegaki-alternative-select-first-keys
tcode-mazegaki-alternative-select-second-keys)
(let ((first-candidate (car candidate-list))
(second-candidate (car (cdr candidate-list))))
(tcode-mazegaki-erase-previous-candidate)
(insert "{" first-candidate "," second-candidate "}")
(if tcode-mazegaki-with-inflection
(insert (tcode-mazegaki-construct-yomi
tcode-mazegaki-current-offset)
tcode-mazegaki-suffix))
(tcode-mazegaki-put-conversion-face)
(let* ((c (read-char))
(key (tcode-char-to-key c)))
(tcode-mazegaki-restore-yomi-and-quit t)
(cond ((memq key tcode-mazegaki-alternative-select-first-keys)
first-candidate)
((memq key tcode-mazegaki-alternative-select-second-keys)
second-candidate)
(t
c))))
;; noc >(=) 2
(save-excursion
(let ((current-offset 0)
(candidate (tcode-mazegaki-select
(tcode-mazegaki-make-candidate-table candidate-list)
noc 0 msg suffix)))
(while (and (char-or-string-p candidate)
(not (stringp candidate))
(or (= candidate ? )
(= candidate ?\C-?)
(= candidate ?\C-h)))
(setq current-offset (if (= candidate ? )
(+ current-offset plist-size)
(- current-offset plist-size)))
(if (>= current-offset noc)
(setq current-offset 0))
(if (< current-offset 0)
(let ((v current-offset))
(while (< (setq v (+ v plist-size)) noc)
(setq current-offset v))))
(setq candidate
(tcode-mazegaki-select
(tcode-mazegaki-make-candidate-table
(nthcdr current-offset candidate-list))
noc current-offset msg suffix)))
(tcode-auto-remove-help t)
candidate))))))
(defun tcode-mazegaki-show-candidate-inline (candidate)
"¸õÊä¤ò¥¤¥ó¥é¥¤¥óɽ¼¨¤¹¤ë¡£"
(tcode-mazegaki-erase-previous-candidate)
(insert candidate
(tcode-mazegaki-list-to-string
tcode-mazegaki-yomi-list
0
tcode-mazegaki-current-offset)
tcode-mazegaki-suffix)
(tcode-mazegaki-put-conversion-face))
(defun tcode-mazegaki-select-candidate ()
"¸½ºß¤ÎÆɤߤ«¤é¸õÊä¤òÁªÂò¤¹¤ë¡£"
(let* ((candidate-list (tcode-mazegaki-get-candidate-list))
(noc (length candidate-list))
(msg (and (not (window-minibuffer-p (selected-window)))
(tcode-verbose-message "(? ¤Ç¥Ø¥ë¥×)"))))
(if (eq tcode-mazegaki-candidate-state 'priority)
(setq tcode-mazegaki-candidate-index
(1+ tcode-mazegaki-candidate-index)
tcode-mazegaki-candidate-state 'next))
(if (null tcode-mazegaki-candidate-state)
(setq tcode-mazegaki-candidate-state (if (= noc 1) 'one 'next)))
(if (eq tcode-mazegaki-candidate-state 'next)
(setq tcode-mazegaki-candidate-state
(if (and (< tcode-mazegaki-candidate-index noc)
(< tcode-mazegaki-candidate-index
tcode-mazegaki-inline-candidate-count))
'priority
'table)))
(cond ((eq tcode-mazegaki-candidate-state 'one)
(tcode-mazegaki-show-candidate-inline (car candidate-list))
(when (and tcode-mazegaki-yomi-fixed
(not tcode-mazegaki-enable-inflection))
(tcode-mazegaki-finish)
(setq msg nil))
(if msg
(message msg)))
((eq tcode-mazegaki-candidate-state 'priority)
(tcode-mazegaki-show-candidate-inline
(nth tcode-mazegaki-candidate-index candidate-list))
(if msg
(message msg)))
((eq tcode-mazegaki-candidate-state 'table)
(let ((selected-candidate (tcode-mazegaki-make-table-and-select
msg candidate-list t)))
(cond ((stringp selected-candidate)
(tcode-mazegaki-show-candidate-inline selected-candidate)
(tcode-mazegaki-finish))
((char-or-string-p selected-candidate)
(tcode-redo-command selected-candidate))))))))
(unless (memq 'tcode-mazegaki-select-candidate
tcode-no-wait-display-help-command-list)
(setq tcode-no-wait-display-help-command-list
(cons 'tcode-mazegaki-select-candidate
tcode-no-wait-display-help-command-list)))
(defun tcode-mazegaki-table-mode ()
"¸õÊä°ìÍ÷ɽ¼¨¤ËÀڤ괹¤¨¤ë¡£"
(interactive)
(cond ((eq tcode-mazegaki-candidate-state 'one)
;; nop
)
((eq tcode-mazegaki-candidate-state 'priority)
(setq tcode-mazegaki-candidate-state 'table
tcode-mazegaki-candidate-index
(tcode-mazegaki-get-number-of-candidate))
(tcode-mazegaki-select-candidate))
(t
;; nop
)))
(defun tcode-mazegaki-select-candidate-from-table ()
"¸½ºß¤ÎÆɤߤ«¤é¸õÊä°ìÍ÷ɽ¤òºîÀ®¤·¡¢¤½¤³¤«¤é¸õÊä¤òÁªÂò¤¹¤ë¡£"
(interactive "*")
(let ((selected-candidate (tcode-mazegaki-make-table-and-select
(and (not (window-minibuffer-p (selected-window)))
(tcode-verbose-message "(? ¤Ç¥Ø¥ë¥×)"))
nil t))
(noc (tcode-mazegaki-get-number-of-candidate)))
(cond ((stringp selected-candidate)
(tcode-mazegaki-show-candidate-inline selected-candidate)
(unless (and (= noc 1)
(or tcode-mazegaki-enable-inflection
(not tcode-mazegaki-yomi-fixed)))
(tcode-mazegaki-finish)))
((char-or-string-p selected-candidate)
(tcode-redo-command selected-candidate)))))
;;;; ÆɤߤζèÀÚ¤êľ¤·¡¦¸õÊä¤Î³ÎÄê
(defun tcode-mazegaki-restore-yomi-and-quit (&optional not-quit)
"ÆɤߤξõÂÖ¤ËÌᤷ¤Æ¡¢¸ò¤¼½ñ¤ÊÑ´¹¤ò½ªÎ»¤¹¤ë¡£
NOT-QUIT ¤¬ nil ¤Ç¤Ê¤¤¤È¤¤Ï¡¢ÆɤߤξõÂÖ¤ËÌ᤹¤À¤±¤Ç¡¢½ªÎ»¤Ï¤·¤Ê¤¤¡£"
(interactive "P")
(tcode-mazegaki-erase-previous-candidate)
(tcode-mazegaki-candidate-select-init) ; Ç°¤Î¤¿¤á
(insert (tcode-mazegaki-list-to-string
tcode-mazegaki-yomi-list 0
(+ tcode-mazegaki-current-yomi-length
tcode-mazegaki-current-offset))
tcode-mazegaki-suffix)
(tcode-mazegaki-put-conversion-face)
(unless not-quit
(tcode-mazegaki-delete-conversion-face)
(unless (window-minibuffer-p (selected-window))
(message ""))
(tcode-do-auto-fill)
(setq tcode-mazegaki-mode nil
tcode-mazegaki-prefix nil)
(while tcode-mazegaki-start-marker
(goto-char (car tcode-mazegaki-start-marker))
(setq tcode-mazegaki-start-marker (cdr tcode-mazegaki-start-marker)))))
(defun tcode-mazegaki-relimit (length offset)
"¸½ºß¤ÎÆɤߤò¶èÀÚ¤êľ¤·¡¢¸õÊä¤òÁªÂò¤µ¤»¤ë¡£
¶èÀÚ¤êľ¤¹Æɤߤϡ¢Ä¹¤µ LENGTH ¤È OFFSET ¤È¤Çɽ¤µ¤ì¤ë¡£"
(tcode-mazegaki-candidate-select-init)
(save-excursion
(goto-char tcode-mazegaki-mode)
(let ((old-yomi-total (+ tcode-mazegaki-current-yomi-length
tcode-mazegaki-current-offset))
(new-yomi-total (+ length offset)))
(if (<= old-yomi-total new-yomi-total)
;; ¥Þ¡¼¥¯¤ÎÁ°¤ÎÆɤߤò¾Ã¤¹
(delete-region
(car (nth (- new-yomi-total old-yomi-total)
(nthcdr (1- old-yomi-total) tcode-mazegaki-yomi-list)))
(point))
;; ¥Þ¡¼¥¯¤ÎÁ°¤ËÆɤߤòÆþ¤ì¤ë
(insert (tcode-mazegaki-list-to-string
tcode-mazegaki-yomi-list
new-yomi-total
(- old-yomi-total new-yomi-total)))))
(setq tcode-mazegaki-mode (point)))
(tcode-mazegaki-put-conversion-face)
(setq tcode-mazegaki-current-yomi-length length
tcode-mazegaki-current-offset offset)
(tcode-mazegaki-restore-yomi-and-quit t)
(tcode-mazegaki-select-candidate))
(defun tcode-mazegaki-relimit-right ()
"Æɤߤò½Ì¤á¤ë¡£"
(interactive)
(let ((p (save-excursion
(tcode-mazegaki-switch-to-dictionary)
(point)))
(orig-with-inflection tcode-mazegaki-with-inflection)
(yomi-info (or (and (not tcode-mazegaki-inflection-only)
(not tcode-mazegaki-with-inflection)
(tcode-mazegaki-lookup nil))
(and (or tcode-mazegaki-enable-inflection
tcode-mazegaki-inflection-only)
(tcode-mazegaki-lookup-with-inflection
(not tcode-mazegaki-with-inflection))))))
(if yomi-info
(tcode-mazegaki-relimit (car (cdr yomi-info)) (cdr (cdr yomi-info)))
(save-excursion
(tcode-mazegaki-switch-to-dictionary)
(goto-char p))
(setq tcode-mazegaki-with-inflection orig-with-inflection)
(ding)
(tcode-verbose-message "¤³¤ì°Ê¾åÆɤߤϽ̤á¤é¤ì¤Þ¤»¤ó¡£"))))
(defun tcode-mazegaki-relimit-left ()
"Æɤߤò¿¤Ð¤¹¡£"
(interactive)
(let ((p (save-excursion
(tcode-mazegaki-switch-to-dictionary)
(point)))
(orig-with-inflection tcode-mazegaki-with-inflection)
(yomi-info (or (and (or tcode-mazegaki-enable-inflection
tcode-mazegaki-inflection-only)
tcode-mazegaki-with-inflection
(tcode-mazegaki-lookup-with-inflection-reverse
nil))
(and (not tcode-mazegaki-inflection-only)
(tcode-mazegaki-lookup-reverse
tcode-mazegaki-with-inflection)))))
(if yomi-info
(tcode-mazegaki-relimit (car (cdr yomi-info)) (cdr (cdr yomi-info)))
(save-excursion
(tcode-mazegaki-switch-to-dictionary)
(goto-char p))
(setq tcode-mazegaki-with-inflection orig-with-inflection)
(ding)
(tcode-verbose-message "¤³¤ì°Ê¾åÆɤߤϿ¤Ð¤»¤Þ¤»¤ó¡£"))))
(defun tcode-mazegaki-select-candidate-or-relimit ()
"Æɤߤò½Ì¤á¤ë¤«¡¢´Á»ú¤Î°ìÍ÷¤«¤é¸õÊä¤òÁªÂò¤¹¤ë¡£
Æɤߤò½Ì¤á¤ë¤Î¤Ï¡¢¸½ºß¤Î¸õÊä¤Î¿ô¤¬°ì¤Ä¤Î¾ì¹ç¤Î¤ß¡£"
(interactive)
(if (/= (tcode-mazegaki-get-number-of-candidate) 1)
(tcode-mazegaki-select-candidate)
(cancel-undo-boundary)
(tcode-mazegaki-relimit-right)))
(defun tcode-mazegaki-prioritize (candidate)
"¸½ºß¤ÎÆɤߤΠCANDIDATE ¤ò³Ø½¬¤¹¤ë¡£
¤¿¤À¤·¡¢³Ø½¬¤¹¤ë¸õÊä¤Ï¡¢ÊÑ¿ô `tcode-mazegaki-fixed-priority-count' ¤Ç
»ØÄꤷ¤¿¿ô¤è¤ê¤â½ç½ø¤¬¸å¤Î¤â¤Î¤Î¤ß¡£"
(save-excursion
(tcode-mazegaki-find-kanji-entry)
(if tcode-mazegaki-with-inflection
(setq candidate
(substring candidate
0
(- (length (tcode-mazegaki-construct-yomi
tcode-mazegaki-current-offset))))))
(let ((eol (save-excursion (end-of-line) (point)))
(latest-point (point))
(i 1)
(beg (point)))
(catch 'done
(while (search-forward "/" eol t)
(when (equal (buffer-substring beg (1- (point)))
candidate)
(if (<= i tcode-mazegaki-fixed-priority-count)
(throw 'done nil)
(delete-region beg (point))
(goto-char latest-point)
(insert candidate "/")
(throw 'done t)))
(if (= i tcode-mazegaki-fixed-priority-count)
(setq latest-point (point)))
(setq beg (point)
i (1+ i)))))))
(defun tcode-mazegaki-finish ()
"¸ò¤¼½ñ¤ÊÑ´¹¤ò³ÎÄꤷ¤Æ¡¢¸ò¤¼½ñ¤ÊÑ´¹¥â¡¼¥É¤òÈ´¤±¤ë¡£"
(interactive)
(tcode-mazegaki-candidate-select-init)
(when tcode-mazegaki-prefix
(setq tcode-mazegaki-prefix nil)
(tcode-mazegaki-delete-conversion-face))
(if tcode-mazegaki-mode
(let* ((beg (if (and (stringp tcode-mazegaki-prefix-mark)
(save-excursion
(goto-char tcode-mazegaki-mode)
(looking-at
(regexp-quote tcode-mazegaki-prefix-mark))))
(match-end 0)
tcode-mazegaki-mode))
(end (point))
(kakutei (prog1
(buffer-substring beg end)
(and tcode-mazegaki-selected-candidate-register
(copy-to-register
tcode-mazegaki-selected-candidate-register
beg end)))))
(if overwrite-mode
(delete-text-in-column nil (+ (current-column)
(string-width kakutei)))
(tcode-do-auto-fill))
(and (boundp 'self-insert-after-hook)
self-insert-after-hook
(funcall self-insert-after-hook tcode-mazegaki-mode (point)))
(run-hooks 'input-method-after-insert-chunk-hook)
(tcode-mazegaki-prioritize kakutei)
(and tcode-record-file-name
(setq tcode-mazegaki-occurrence
(+ (chars-in-string kakutei) tcode-mazegaki-occurrence)))
(setq tcode-mazegaki-mode nil
tcode-mazegaki-prefix nil)
(tcode-mazegaki-delete-conversion-face)
(when tcode-mazegaki-start-marker
;; recursive conversion
(goto-char (car tcode-mazegaki-start-marker))
(setq tcode-mazegaki-start-marker (cdr tcode-mazegaki-start-marker))
(tcode-mazegaki-convert nil))
(unless (window-minibuffer-p (selected-window))
(message ""))
(unless (string= kakutei "")
(setq tcode-help-char
(let ((kakutei-chars (string-to-list kakutei)))
(while (cdr kakutei-chars)
(setq kakutei-chars (cdr kakutei-chars)))
(char-to-string (car kakutei-chars)))))
(and tcode-auto-help
kakutei
(not (string= kakutei ""))
(tcode-display-direct-stroke
(substring kakutei
0
(and (not (string= tcode-mazegaki-suffix ""))
(- (length tcode-mazegaki-suffix))))
(tcode-mazegaki-construct-yomi
(+ tcode-mazegaki-current-yomi-length
tcode-mazegaki-current-offset)))
(tcode-auto-remove-help-char)))))
(add-hook 'tcode-clear-hook 'tcode-mazegaki-finish)
(defun tcode-mazegaki-recursive-convert-backward ()
(interactive)
(let ((marker (make-marker))
(beg tcode-mazegaki-mode))
(let (tcode-mazegaki-start-marker) ; protect
(tcode-mazegaki-restore-yomi-and-quit))
(setq tcode-mazegaki-start-marker
(cons (set-marker marker (point))
tcode-mazegaki-start-marker))
(goto-char beg)
(tcode-mazegaki-convert nil)))
(defun tcode-mazegaki-cancel-previous-recursive-convert ()
(interactive)
(when tcode-mazegaki-start-marker
(let (tcode-mazegaki-start-marker) ; protect
(tcode-mazegaki-restore-yomi-and-quit))
(goto-char (car tcode-mazegaki-start-marker))
(setq tcode-mazegaki-start-marker (cdr tcode-mazegaki-start-marker))
(tcode-mazegaki-convert nil)))
;;;; ÅÐÏ¿¤Èºï½ü
(defun tcode-mazegaki-get-yomi-and-kanji (prompt &optional str)
"¸ò¤¼½ñ¤ÅÐÏ¿»þ¤Î¡ÖÆɤߡפȡִÁ»ú¡×¤òŬÅö¤ËÆÀ¤ë¡£"
(let* ((minibuffer-setup-hook
;; avoid referencing undefined variables in NEmacs.
(and (boundp 'minibuffer-setup-hook)
(cons 'toggle-input-method minibuffer-setup-hook)))
(yomi (if tcode-mazegaki-mode
(buffer-substring tcode-mazegaki-mode (point))
(read-from-minibuffer (concat prompt "ÆÉ¤ß ")
(if (and str
(or (tcode-mule-2-p)
(tcode-mule-3-p)
(tcode-mule-4-p)))
(cons str 1)
str))))
(kanji (read-from-minibuffer
(format "%s´Á»ú(Æɤß=%s) " prompt yomi))))
(list (mapconcat 'char-to-string
(delq ?\n (string-to-list yomi))
nil)
(mapconcat 'char-to-string
(delq ?\n (string-to-list kanji))
nil))))
(defun tcode-split-string-by-regexp (string splitter)
"ʸ»úÎó STRING ¤ò¡¢Àµµ¬É½¸½ SPLITTER ¤ò¶èÀÚ¤ê¤È¤·¤Æʬ³ä¤¹¤ë¡£"
(let (l)
(while (string-match splitter string)
(setq l (nconc l (list (substring string 0 (match-beginning 0))))
string (substring string (match-end 0))))
(nconc l (list string))))
(defun tcode-mazegaki-yomi-combination (yomi-list kanji-list)
"ÆɤߤȴÁ»ú¤È¤Î¼è¤êÆÀ¤ëÁȤ߹ç¤ï¤»¤ò¤¹¤Ù¤ÆÎóµó¤¹¤ë¡£"
(if (<= (length yomi-list) 1)
(append kanji-list yomi-list)
(let ((yomi-car (car yomi-list))
(yomi-cdr (cdr yomi-list))
(kanji-car (car kanji-list))
(kanji-cdr (cdr kanji-list)))
(if (string= yomi-car kanji-car)
(mapcar (lambda (a) (concat kanji-car a))
(tcode-mazegaki-yomi-combination yomi-cdr kanji-cdr))
(nconc
(mapcar (lambda (a) (concat kanji-car a))
(tcode-mazegaki-yomi-combination yomi-cdr kanji-cdr))
(mapcar (lambda (a) (concat yomi-car a))
(tcode-mazegaki-yomi-combination yomi-cdr kanji-cdr)))))))
;;;###autoload
(defun tcode-mazegaki-make-entry (yomi kanji)
"ÆÉ¤ß YOMI¡¢´Á»ú KANJI ¤Ç¡¢¿·¤¿¤Ê¥¨¥ó¥È¥ê¤ò¸ò¤¼½ñ¤¼½ñ¤ËÅÐÏ¿¤¹¤ë¡£
Àµ¤·¤¯ÅÐÏ¿¤µ¤ì¤ì¤Ð t¡¢¤½¤¦¤Ç¤Ê¤±¤ì¤Ð nil ¤òÊÖ¤¹¡£
Æɤߤª¤è¤Ó´Á»ú¤¬ `tcode-mazegaki-splitter' ¤Ç¶èÀڤäƤ¢¤ë¾ì¹ç¤Ë¤Ï¡¢
¤½¤ì¤é¤òÁȤ߹ç¤ï¤»¤¿Æɤߤ¹¤Ù¤Æ¤Ë¤Ä¤¤¤ÆÅÐÏ¿¤¹¤ë¡£"
(interactive (tcode-mazegaki-get-yomi-and-kanji "ÅÐÏ¿¢£"))
(and (interactive-p)
(> (string-width yomi) tcode-mazegaki-yomi-max)
(message (concat "ÆɤߡÖ%s¡×¤ÎŤµ(%d)¤Ï `tcode-mazegaki-yomi-max' "
"¤ÎÃͤòĶ¤¨¤Æ¤¤¤Þ¤¹¡£")
yomi (string-width yomi))
(setq tcode-mazegaki-yomi-max (string-width yomi)))
(let ((yomi-list (tcode-split-string-by-regexp yomi
tcode-mazegaki-splitter)))
(if (> (length yomi-list) 1)
;; multi pattern
(let ((kanji-list
(tcode-split-string-by-regexp kanji
tcode-mazegaki-splitter)))
(unless (= (length yomi-list) (length kanji-list))
(error "¶èÀÚ¤êÊý¤¬´Ö°ã¤Ã¤Æ¤¤¤Þ¤¹¡£"))
(setq yomi-list (tcode-mazegaki-yomi-combination
yomi-list kanji-list)
kanji (car yomi-list)
yomi-list (cdr yomi-list))
(mapcar (lambda (yomi)
(tcode-mazegaki-make-entry yomi kanji))
yomi-list))
(save-excursion
(tcode-mazegaki-switch-to-dictionary)
(tcode-mazegaki-search-yomi yomi)
(setq tcode-mazegaki-current-yomi-point (point))
;; ´û¤ËÆɤߤ¬ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ì¤Ð¡¢¤½¤³¤ËÄɲä·¡¢
;; ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢¿·¤¿¤Ë¥¨¥ó¥È¥ê¤òºî¤ë¡£
(cond ((not (looking-at (concat yomi " /")))
(insert yomi " /" kanji "/\n")
t)
((re-search-forward (concat "/" kanji "/")
(save-excursion (end-of-line) (point))
t)
(and (interactive-p)
(progn
(ding)
(message "¡Ö%s¡×¤Ï¤¹¤Ç¤ËÅÐÏ¿¤µ¤ì¤Æ¤¤¤Þ¤¹¡£" kanji)))
nil)
(t
(tcode-mazegaki-find-kanji-entry)
(insert kanji "/")))))))
(defun tcode-mazegaki-inflection-p (yomi)
"Æɤߤ¬³èÍѤ¹¤ë¤â¤Î¤«¤É¤¦¤«¤òɽ¤¹½Ò¸ì¡£"
(let ((length (length tcode-mazegaki-inflection-mark)))
(and (stringp yomi)
(> (length yomi) length)
(string= (substring yomi (- length))
tcode-mazegaki-inflection-mark))))
;;;###autoload
(defun tcode-mazegaki-make-entry-and-finish ()
"¿·¤¿¤Ê¥¨¥ó¥È¥ê¤ò¸ò¤¼½ñ¤¼½ñ¤ËÅÐÏ¿¤·¡¢³ÎÄꤹ¤ë¡£
Æɤߤϡ¢¸ò¤¼½ñ¤ÊÑ´¹Ã椢¤ë¤¤¤ÏľÁ°¤ËÊÑ´¹¤Ë¼ºÇÔ¤·¤Æ¤¤¤¿¾ì¹ç¤Ï¡¢¤½¤³¤«¤éÆÀ¤ë¡£
¤½¤·¤Æ¡¢ÅÐÏ¿¸å¤ËÅÐÏ¿¤·¤¿´Á»ú¤ò³ÎÄꤹ¤ë¡£
¸ò¤¼½ñ¤ÊÑ´¹Ã椢¤ë¤¤¤ÏÊÑ´¹¤Ë¼ºÇÔ¤·¤¿Ä¾¸å°Ê³°¤Î¾ì¹ç¤Ï¡¢³ÎÄê¤Ï¹Ô¤ï¤Ê¤¤¡£"
(interactive)
(let ((yomi-exists (or tcode-mazegaki-mode
(eq last-command 'tcode-mazegaki-begin-conversion))))
(if tcode-mazegaki-mode
(tcode-mazegaki-restore-yomi-and-quit))
(let* ((yomi-kanji (tcode-mazegaki-get-yomi-and-kanji
"ÅÐÏ¿¢£" (if yomi-exists
(tcode-mazegaki-list-to-string
tcode-mazegaki-yomi-list 0
(length tcode-mazegaki-yomi-list))
nil)))
(yomi (car yomi-kanji)))
(tcode-mazegaki-make-entry yomi (car (cdr yomi-kanji)))
(if yomi-exists
;; ³ÎÄꤹ¤ë
(let* ((split-yomi
(tcode-split-string-by-regexp yomi
tcode-mazegaki-splitter))
(real-yomi (let (s)
(while split-yomi
(setq s (concat s (car split-yomi))
split-yomi (cdr split-yomi)))
s)))
(tcode-mazegaki-convert
(let ((yomi-list (string-to-list real-yomi)))
(if (<= (car yomi-list) 255)
1 ; alphabet
(length yomi-list)))
(tcode-mazegaki-inflection-p real-yomi)))))))
;;;###autoload
(defun tcode-mazegaki-delete-entry (yomi kanji)
"ÆÉ¤ß YOMI¡¢´Á»ú KANJI ¤Î¥¨¥ó¥È¥ê¤ò¸ò¤¼½ñ¤¼½ñ¤«¤éºï½ü¤¹¤ë¡£"
(interactive
(let* ((minibuffer-setup-hook
;; avoid referencing undefined variables in NEmacs.
(and (boundp 'minibuffer-setup-hook)
(cons 'toggle-input-method minibuffer-setup-hook)))
(yomi (if tcode-mazegaki-mode
(buffer-substring tcode-mazegaki-mode (point))
(read-from-minibuffer "ºï½ü¢£ÆÉ¤ß ")))
(found (save-excursion
(tcode-mazegaki-switch-to-dictionary)
(tcode-mazegaki-search-yomi yomi)))
(candidate (and found
(tcode-mazegaki-make-table-and-select
(format "ºï½ü¢£ÆÉ¤ß %s " yomi))))
(yes (and (stringp candidate)
(y-or-n-p
(format
"ÆɤߡÖ%s¡×´Á»ú¡Ö%s¡×¤òºï½ü¤·¤Þ¤¹¤«? "
yomi candidate))))
(kanji (cond (yes
candidate)
((not found)
(error "ÆɤߡÖ%s¡×¤ÏÅÐÏ¿¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£" yomi))
((error "ºï½üÃæ»ß")))))
(list yomi kanji)))
(save-excursion
(tcode-mazegaki-switch-to-dictionary)
(if (and (tcode-mazegaki-search-yomi yomi)
(setq tcode-mazegaki-current-yomi-point (point))
(re-search-forward (concat "\\(/" kanji "\\)/")
(save-excursion (end-of-line) (point))
t))
(prog2 ; 1¹ÔÁ´ÂΤòºï½ü¤·¤¿¤È¤ t ¤½¤ì
; °Ê³°¤Ï nil ¤òÊÖ¤¹
(progn
(delete-region (match-beginning 1) (match-end 1))
(tcode-mazegaki-find-kanji-entry))
(and (looking-at "$")
(prog1 t ; 1¹ÔÁ´ÂΤòºï½ü
(beginning-of-line)
(delete-region (point) (progn (forward-line 1) (point)))))
(and (interactive-p)
(message "ÆɤߡÖ%s¡×´Á»ú¡Ö%s¡×¤òºï½ü¤·¤Þ¤·¤¿¡£" yomi kanji)))
(when (interactive-p)
(ding)
(message "ÆɤߡÖ%s¡×´Á»ú¡Ö%s¡×¤ÏÅÐÏ¿¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£"
yomi kanji)))))
(defun tcode-mazegaki-apply-entries-region (beg end func msg)
"¥ê¡¼¥¸¥ç¥óÃæ¤Î¼½ñ¤Î¹àÌܤ½¤ì¤¾¤ì¤ËÂФ·¤Æ FUNC ¤òŬÍѤ¹¤ë¡£
FUNC ¤Ø¤Ï¡¢Âè1°ú¿ô¤ËÆɤߡ¢Âè2°ú¿ô¤Ë´Á»ú¤¬½ç¼¡ÅϤµ¤ì¤ë¡£
¼½ñ¤Î¹àÌܤÏ1¹Ô¤º¤Ä»ØÄꤹ¤ë¡£³Æ¹Ô¤Î½ñ¼°¤Ï
ÆÉ¤ß /´Á»ú/[´Á»ú/]*\\n"
(interactive "r")
(save-excursion
(save-restriction
(message "°ì³ç%sÃæ..." msg)
(narrow-to-region beg end)
(goto-char (point-min))
(let ((line 1))
(condition-case nil
(while (not (eobp))
(let* ((eol (save-excursion (end-of-line) (point)))
(bol (point))
(yomi (buffer-substring (point)
(progn
(search-forward " /" eol)
(goto-char (- (point) 2))
(point)))))
(re-search-forward "/$" eol)
(goto-char (1- (point)))
(while (re-search-backward "/\\(.+\\)" bol t)
(funcall func yomi (buffer-substring
(match-beginning 1)
(match-end 1))))
(setq line (1+ line))
(forward-line 1)))
(error
(ding)
(message "%d ¹ÔÌܤǼ½ñ¤Î½ñ¼°¤¬´Ö°ã¤Ã¤Æ¤¤¤Þ¤¹¡£" line)))
(message "°ì³ç%sÃæ...´°Î»" msg))
(widen))))
;;;###autoload
(defun tcode-mazegaki-make-entries-region (beg end)
"¥ê¡¼¥¸¥ç¥óÃæ¤Î¼½ñ¤Î¹àÌܤò°ì³ç¤·¤ÆÅÐÏ¿¤¹¤ë¡£
¼½ñ¤Î½ñ¼°¤Ï´Ø¿ô `tcode-mazegaki-apply-entries-region' ¤ò»²¾È¡£"
(interactive "r")
(tcode-mazegaki-apply-entries-region
beg end 'tcode-mazegaki-make-entry "ÅÐÏ¿"))
;;;###autoload
(defun tcode-mazegaki-make-entries-buffer (&optional buffer)
"¥Ð¥Ã¥Õ¥¡Ãæ¤Î¼½ñ¤Î¹àÌܤò°ì³ç¤·¤ÆÅÐÏ¿¤¹¤ë¡£
¥³¥Þ¥ó¥É `tcode-mazegaki-make-entries-region' »²¾È¡£"
(interactive)
(save-excursion
(if buffer
(set-buffer buffer))
(tcode-mazegaki-make-entries-region (point-min) (point-max))))
;;;###autoload
(defun tcode-mazegaki-delete-entries-region (beg end)
"¥ê¡¼¥¸¥ç¥óÃæ¤Î¼½ñ¤Î¹àÌܤò°ì³ç¤·¤Æºï½ü¤¹¤ë¡£
¼½ñ¤Î½ñ¼°¤Ï´Ø¿ô `tcode-mazegaki-apply-entries-region' ¤ò»²¾È¡£"
(interactive "r")
(tcode-mazegaki-apply-entries-region
beg end 'tcode-mazegaki-delete-entry "ºï½ü"))
;;;###autoload
(defun tcode-mazegaki-delete-entries-buffer (&optional buffer)
"¥Ð¥Ã¥Õ¥¡Ãæ¤Î¼½ñ¤Î¹àÌܤò°ì³ç¤·¤Æºï½ü¤¹¤ë¡£
¥³¥Þ¥ó¥É `tcode-mazegaki-delete-entries-region' »²¾È¡£"
(interactive)
(save-excursion
(if buffer
(set-buffer buffer))
(tcode-mazegaki-delete-entries-region (point-min) (point-max))))
;;;###autoload
(defun tcode-mazegaki-delete-entry-by-last-yomi (arg)
"ºÇ¸å¤ËÆþÎϤ·¤¿Æɤߤ«¤é´Á»ú¤òÁªÂò¤·¡¢¤½¤ì¤òºï½ü¤¹¤ë¡£
°ú¿ô ARG ¤¬ nil ¤Ç¤Ê¤¤¤È¤¤Ï¡¢Æɤߤ⿷¤¿¤ËÆþÎϤ¹¤ë¡£"
(interactive "P")
(if (or (null tcode-mazegaki-yomi-list)
arg)
(call-interactively 'tcode-mazegaki-delete-entry)
(let* ((yomi (save-excursion
(tcode-mazegaki-switch-to-dictionary)
(beginning-of-line)
(looking-at "\\([^/]+\\) /")
(buffer-substring (match-beginning 1) (match-end 1))))
(kanji (tcode-mazegaki-make-table-and-select
(format "ºï½ü¢£ÆɤߡÖ%s¡×´Á»ú¤Ï? " yomi))))
(if (not (stringp kanji))
(message "ºï½üÃæ»ß")
(if (y-or-n-p (format "ÆɤߡÖ%s¡×´Á»ú¡Ö%s¡×¤òºï½ü¤·¤Þ¤¹¤« "
yomi kanji))
(tcode-mazegaki-delete-entry yomi kanji))))))
;;;; Æɤߤ«¤é¤ÎÊä´°
(defun tcode-mazegaki-make-completion-prompt (yomi comp-list)
"Êä´°¸õÊ䤬ʣ¿ô¤¢¤ë¾ì¹ç¤Î¡¢ÁªÂò¤Î¤¿¤á¤Î¥×¥í¥ó¥×¥È¤Îʸ»úÎó¤òºî¤ë¡£"
(let* ((prompt (concat yomi "{"
(substring (car comp-list) (length yomi) nil)))
(max-len (- (frame-width) 12)) ; 12 is for suffix
(yomi-len (length yomi))
(diff (substring (car (setq comp-list (cdr comp-list)))
yomi-len nil))
(new-prompt (concat prompt ", " diff)))
(concat
(catch 'overflow
(while comp-list
(or (< (string-width new-prompt) max-len)
(throw 'overflow prompt))
(setq prompt new-prompt
comp-list (cdr comp-list)
diff (and comp-list
(substring (car comp-list) yomi-len nil))
new-prompt (concat prompt ", " diff)))
prompt)
(if comp-list
(format ", ¡Ä (+%d)" (length comp-list))
"}"))))
;;;###autoload
(defun tcode-mazegaki-complete (&optional conversion)
"¸ò¤¼½ñ¤¼½ñ¤ÎÆɤߤ«¤éÊä´°¤ò¹Ô¤¦¡£
¸õÊ䤬ʣ¿ô¤¢¤ë¤È¤¤Î¥¡¼³ä¤êÅö¤Æ¤Ï¼¡¤Î¤È¤ª¤ê¡£
SPC ¼¡¤Î¸õÊä¤òÀèƬ¤Ë¤¹¤ë
DEL ºÇ¸å¤Î¸õÊä¤òÀèƬ¤Ë¤¹¤ë
TAB ÀèƬ¤Î¸õÊä¤òÊä´°¤·½ªÎ»¤¹¤ë
LFD ÀèƬ¤Î¸õÊä¤òÊä´°¤·½ªÎ»¡¦¤½¤Î¸åÊÑ´¹¤¹¤ë
RET ÁªÂò¤»¤º¤ËÊä´°¤ò½ªÎ»¤¹¤ë
CONVERSION ¤¬ nil ¤Ç¤Ê¤¤¤È¤¡¢Êä´°¸å(Êä´°¤ò¹Ô¤Ã¤¿¾ì¹ç¤Î¤ß)ÊÑ´¹¤ò¹Ô¤¦¡£"
(interactive "*P")
(setq tcode-mazegaki-yomi-list (tcode-mazegaki-get-reverse-yomi-list))
(unless tcode-mazegaki-yomi-list
(error "Êä´°¤Ç¤¤Þ¤»¤ó¡£"))
(let* ((yomi-len (length tcode-mazegaki-yomi-list))
(yomi-prefix
(catch 'found
(while (> yomi-len 0)
(let ((yomi (regexp-quote
(tcode-mazegaki-construct-yomi yomi-len))))
(save-excursion
(tcode-mazegaki-switch-to-dictionary)
(tcode-mazegaki-search-yomi yomi)
(and (looking-at yomi)
(or (not (looking-at (concat yomi " /")))
(save-excursion
(forward-line 1)
(looking-at yomi)))
(throw 'found yomi))))
(and tcode-mazegaki-mode
tcode-mazegaki-yomi-fixed
(throw 'found nil))
(setq yomi-len (1- yomi-len)))))
(completion-list
(and yomi-prefix
(save-excursion
(tcode-mazegaki-switch-to-dictionary)
(let (list
yomi
(i 0)
(yomi-len (length yomi-prefix)))
(while (string= yomi-prefix
(buffer-substring (point)
(+ (point) yomi-len)))
(setq yomi (buffer-substring (point)
(save-excursion
(search-forward " /")
(- (point) 2)))
i (1+ i))
(if (> i tcode-mazegaki-complete-max)
(error "¡Ö%s¡×¤Ï¸õÊä¤Î¿ô¤¬Â¿¤¹¤®¤Þ¤¹¡£"
yomi-prefix))
(unless (string= yomi yomi-prefix)
(setq list (nconc list (list (cons yomi nil)))))
(forward-line 1))
list))))
(most (and completion-list
(try-completion yomi-prefix completion-list)))
comp)
(or completion-list
(error "Êä´°¤Ç¤¤Þ¤»¤ó¡£"))
;; for NEmacs
(and (stringp most)
(let ((last-char (aref most (1- (length most)))))
(and (= (mod (string-width most) 2) 1)
(> last-char 127)
(<= last-char 255)
(setq most (substring most 0 -1))
(string= yomi-prefix most)
(setq most nil))))
;; Êä´°¤Ç¤¤ëÉôʬ¤òÊä´°
(when most
(delete-region (car (nth (1- yomi-len) tcode-mazegaki-yomi-list))
(point))
(insert (if (stringp most)
most
yomi-prefix))
(tcode-do-auto-fill))
(if (stringp most)
(setq yomi-prefix most))
(setq comp (and completion-list
(all-completions yomi-prefix completion-list)))
(when (> (length comp) 1)
;; ÁªÂò¥â¡¼¥É
(catch 'quit
(while t
(message (tcode-mazegaki-make-completion-prompt yomi-prefix comp))
(let ((ch (read-char)))
(cond ((= ch ? )
;; ¼¡¤Î¸õÊä¤òÀèƬ¤Ø
(setq comp (nconc (cdr comp) (list (car comp)))))
((= ch ?\C-?)
;; ºÇ¸å¤Î¸õÊä¤òÀèƬ¤Ø
(let ((list comp))
(while (and (cdr list)
(cdr (cdr list)))
(setq list (cdr list)))
(setq comp (append (cdr list) comp))
(rplacd list nil)))
((or (= ch ?\t)
(= ch last-command-char))
;; ÀèƬ¤Î¸õÊä¤òÁªÂò¤·¤Æ½ªÎ»
(insert (substring (car comp)
(length yomi-prefix) nil))
(tcode-do-auto-fill)
(throw 'quit t))
((= ch ?\n)
;; ÀèƬ¤Î¸õÊä¤òÁªÂò¤·¤Æ½ªÎ»¡¦½ªÎ»¸å¤ËÊÑ´¹
(insert (substring (car comp)
(length yomi-prefix) nil))
(tcode-do-auto-fill)
(setq conversion t)
(throw 'quit t))
((= ch ?\r)
;; ¸õÊä¤òÁªÂò¤»¤º½ªÎ»
(setq conversion nil)
(throw 'quit t))
(t
;; ½ªÎ»¤·¡¢¤½¤Î¥³¥Þ¥ó¥É¤ò¼Â¹Ô
(tcode-redo-command ch)
(setq conversion nil)
(throw 'quit t))))))
(unless (window-minibuffer-p (selected-window))
(message "")))
(if conversion
(tcode-mazegaki-convert nil))))
;;;###autoload
(defun tcode-mazegaki-complete-and-convert ()
"¸ò¤¼½ñ¤¼½ñ¤ÎÆɤߤ«¤éÊä´°¤ò¹Ô¤¤¡¢¤½¤Î¸åÊÑ´¹¤¹¤ë¡£
¾ÜºÙ¤Ï¥³¥Þ¥ó¥É `tcode-mazegaki-complete' »²¾È¡£"
(interactive "*")
(tcode-mazegaki-complete t))
;;;; ¤½¤Î¾(¥¡¼³ä¤êÅö¤Æ¤ä¼½ñ¤ÎÊݸ¤Ê¤É)
(defun tcode-mazegaki-backward-delete-char (arg)
"¥³¥Þ¥ó¥É `backward-delete-char' ¤ÈƱ¤¸¤«¡¢¹¹¤Ë¸ò¤¼½ñ¤ÊÑ´¹¤ò½ªÎ»¤¹¤ë¡£
¸ò¤¼½ñ¤ÊÑ´¹¤ò½ªÎ»¤¹¤ë¤Î¤Ï¡¢³«»ÏÅÀ¤ò¾Ã¤·¤¿¤È¤¡£"
(interactive "*p")
(if (<= (point) tcode-mazegaki-mode)
(tcode-mazegaki-finish)
(backward-delete-char arg)))
(defun tcode-mazegaki-command-summary ()
"¸ò¤¼½ñ¤ÊÑ´¹»þ¤Î¥¡¼¤Î³ä¤êÅö¤Æ°ìÍ÷¤òɽ¼¨¤¹¤ë¡£
ɽ¼¨¤¹¤ëÆâÍƤϡ¢ÊÑ¿ô `tcode-mazegaki-command-summary-alist' ¤Ç»ØÄꤹ¤ë¡£"
(interactive)
(message
(mapconcat
(lambda (elm)
(let* ((key (where-is-internal (cdr elm) tcode-mazegaki-map t))
(key-str (if (null key)
(error
(concat "`tcode-mazegaki-command-summary-alist' "
"¤Î´Ø¿ô̾¤Ë´Ö°ã¤¤¤¬¤¢¤ê¤Þ¤¹¡£"))
(key-description key))))
(format "%s=%s" key-str (car elm))))
tcode-mazegaki-command-summary-alist " "))
(sit-for 5))
;;;###autoload
(defun tcode-mazegaki-put-prefix ()
"Á°ÃÖ·¿¸ò¤¼½ñ¤ÊÑ´¹¤Î³«»ÏÃÏÅÀ¤Î°õ¤òÉÕ¤±¤ë¡£"
(interactive)
(setq tcode-mazegaki-prefix (point))
(add-hook 'post-command-hook 'tcode-mazegaki-put-conversion-face))
;;;###autoload
(defun tcode-mazegaki-add-prefix (char)
"Á°ÃÖ·¿¸ò¤¼½ñ¤ÊÑ´¹¤ò»Ï¤á¤ë¤¿¤á¤Î¥Õ¥£¥ë¥¿¡£"
(tcode-mazegaki-put-prefix)
char)
(defun tcode-mazegaki-self-insert-or-convert (arg)
"¥³¥Þ¥ó¥É `self-insert-command' ¤ÈƱ¤¸¤«¡¢¸ò¤¼½ñ¤ÊÑ´¹¤ò¹Ô¤¦¡£
¸ò¤¼½ñ¤ÊÑ´¹¤ò¹Ô¤¦¤Î¤Ï¡¢¡ÖÆɤߡפ¬ÆþÎϤµ¤ì¤Æ¤¤¤ë¾ì¹ç¤Î¤ß¡£
ÊÑ´¹¤ò¹Ô¤¨¤Ð t¡¢¹Ô¤ï¤Ê¤±¤ì¤Ð nil ¤òÊÖ¤¹¡£"
(interactive "*P")
(if (not tcode-mazegaki-prefix)
(self-insert-command (prefix-numeric-value arg))
; `self-insert-command' ¤Ï nil ¤òÊÖ¤¹¡£
(setq tcode-mazegaki-yomi-list (tcode-mazegaki-get-reverse-yomi-list))
(tcode-mazegaki-convert (length tcode-mazegaki-yomi-list)
current-prefix-arg)
t)) ; ÊÑ´¹¤·¤¿¤È¤ t ¤òÊÖ¤¹¡£
(unless (featurep 'tc-mazegaki)
(setq tcode-mazegaki-map (make-keymap))
(tcode-set-key " " 'tcode-mazegaki-self-insert-or-convert)
(mapcar
(lambda (elm)
(define-key tcode-mazegaki-map (car elm) (cdr elm)))
'((" " . tcode-mazegaki-select-candidate-or-relimit)
("\C-u" . tcode-mazegaki-restore-yomi-and-quit)
("\C-m" . tcode-mazegaki-finish)
("<" . tcode-mazegaki-relimit-left)
(">" . tcode-mazegaki-relimit-right)
("|" . tcode-mazegaki-make-entry-and-finish)
("\C-\?" . tcode-mazegaki-backward-delete-char)
("=" . tcode-mazegaki-table-mode)
("\C-l" . recenter)
("\C-b" . tcode-mazegaki-recursive-convert-backward)
("\C-f" . tcode-mazegaki-cancel-previous-recursive-convert)
("?" . tcode-mazegaki-command-summary)))
(run-hooks 'tcode-mazegaki-init-hook))
(provide 'tc-mazegaki)
;;; tc-mazegaki.el ends here
|