| 1 |
;;; skk-nicola.el --- SKK $B$K?F;X%7%U%HF~NO%$%s%?%U%'%$%9$rDs6!(B -*- coding: iso-2022-jp -*- |
| 2 |
|
| 3 |
;; Copyright (C) 1996, 1997, 1998, 1999, 2000 |
| 4 |
;; Itsushi Minoura <[email protected]> |
| 5 |
|
| 6 |
;; Author: Itsushi Minoura <[email protected]> |
| 7 |
;; Tetsuo Tsukamoto <[email protected]> |
| 8 |
;; Keywords: hardware, japanese, mule, input method |
| 9 |
|
| 10 |
;; This file is part of Daredevil SKK. |
| 11 |
|
| 12 |
;; This program is free software: you can redistribute it and/or |
| 13 |
;; modify it under the terms of the GNU General Public License as |
| 14 |
;; published by the Free Software Foundation, either version 3 of |
| 15 |
;; the License, or (at your option) any later version. |
| 16 |
|
| 17 |
;; This program is distributed in the hope that it will be |
| 18 |
;; useful, but WITHOUT ANY WARRANTY; without even the implied |
| 19 |
;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 20 |
;; PURPOSE. See the GNU General Public License for more details. |
| 21 |
|
| 22 |
;; You should have received a copy of the GNU General Public License |
| 23 |
;; along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 24 |
|
| 25 |
;;; Commentary: |
| 26 |
|
| 27 |
;; $B$3$N%W%m%0%i%`$OL'1:0o;K$5$s:n$N(B NICOLA-SKK 0.39 $B$r4p$K!"(B Daredevil SKK $B$K(B |
| 28 |
;; $BBP1~$5$;$?$b$N$G$9!#86:n$N%"%$%G%"$K4p$$$F<BAu$7$F$$$/M=Dj$G$9!#(B |
| 29 |
|
| 30 |
;; $B%-!<G[Ns$N%k!<%k$OJL%U%!%$%k$K:YJ,2=$7$F$$$^$9!#$3$l$i$O!"F1$8$/L'1:$5$s:n(B |
| 31 |
;; $B$N(B omelet ($B$?$^$4MQ$N?F;X%7%U%HF~NO%$%s%?!<%U%'%$%9(B) $B$*$h$SF1;a$N(B web site |
| 32 |
;; $B$NJ8>O$r4p$K$D$/$j$^$7$?!#(B |
| 33 |
|
| 34 |
;; $BF1;a$N%"%$%G%"$H?F;X%7%U%HF~NO$K4X$9$k$4?TNO$K7I0U$rI=$7!"$^$?46<U$$$?$7$^(B |
| 35 |
;; $B$9!#(B |
| 36 |
|
| 37 |
;; $B>\:Y$K$D$$$F$O!"F1:-$N(B README.NICOLA.md $B$r$4Mw2<$5$$!#(B |
| 38 |
|
| 39 |
;;; Code: |
| 40 |
|
| 41 |
(eval-when-compile |
| 42 |
(require 'cl-lib) |
| 43 |
(require 'skk-kanagaki-util) |
| 44 |
(require 'skk-macs) |
| 45 |
(require 'skk-vars) |
| 46 |
(require 'skk-emacs)) |
| 47 |
|
| 48 |
(eval-and-compile |
| 49 |
(require 'skk-kanagaki)) |
| 50 |
|
| 51 |
(eval-and-compile |
| 52 |
(autoload 'skk-dcomp-marked-p "skk-dcomp") |
| 53 |
(autoload 'skk-dcomp-face-off "skk-dcomp") |
| 54 |
(autoload 'skk-dcomp-face-on "skk-dcomp")) |
| 55 |
|
| 56 |
;; Variables. |
| 57 |
|
| 58 |
(defcustom skk-nicola-interval 0.1 |
| 59 |
"*$B$3$N;~4V0JFb$KBG80$5$l$?$b$N$rF1;~BG80$HH=Dj$9$k!#(B |
| 60 |
$BC10L$OIC!#%G%U%)%k%H$O(B 0.1 $BIC!#(B" |
| 61 |
:type 'number |
| 62 |
:group 'skk-nicola) |
| 63 |
|
| 64 |
(defcustom skk-nicola-latin-interval 0.1 |
| 65 |
"*$B$3$N;~4V0JFb$KBG80$5$l$?$b$N$rF1;~BG80$HH=Dj$9$k!#(B |
| 66 |
$BC10L$OIC!#%G%U%)%k%H$O(B 0.1 $BIC!#(B" |
| 67 |
:type 'number |
| 68 |
:group 'skk-nicola) |
| 69 |
|
| 70 |
(defcustom skk-nicola-lshift-keys |
| 71 |
(list (cond |
| 72 |
((eq system-type 'windows-nt) |
| 73 |
[noconvert]) |
| 74 |
(t |
| 75 |
[muhenkan]))) |
| 76 |
"*$B:8?F;X%-!<$H$7$F;H$&%-!<!#(B" |
| 77 |
:type (if (get 'key-sequence 'widget-type) |
| 78 |
'(repeat key-sequence) |
| 79 |
'(repeat sexp)) |
| 80 |
:group 'skk-nicola) |
| 81 |
|
| 82 |
(defcustom skk-nicola-rshift-keys |
| 83 |
(append '(" ") |
| 84 |
(list (cond |
| 85 |
((eq system-type 'windows-nt) |
| 86 |
[convert]) |
| 87 |
(t |
| 88 |
[henkan])))) |
| 89 |
"*$B1&?F;X%-!<$H$7$F;H$&%-!<!#(B" |
| 90 |
:type (if (get 'key-sequence 'widget-type) |
| 91 |
'(repeat key-sequence) |
| 92 |
'(repeat sexp)) |
| 93 |
:group 'skk-nicola) |
| 94 |
|
| 95 |
(defcustom skk-nicola-use-lshift-as-space nil |
| 96 |
"*Non-nil $B$G$"$l$P:8?F;X%-!<$b%9%Z!<%9%-!<$H$7$FMxMQ$9$k!#(B" |
| 97 |
:type 'boolean |
| 98 |
:group 'skk-nicola) |
| 99 |
|
| 100 |
(defcustom skk-nicola-lshift-function nil |
| 101 |
"*Non-nil $B$G$"$l$P:8?F;X%-!<$r2!$7$?$H$-$K$3$N4X?t$r<B9T$9$k!#(B" |
| 102 |
:type 'function |
| 103 |
:group 'skk-nicola) |
| 104 |
|
| 105 |
(defcustom skk-nicola-set-henkan-point-chars |
| 106 |
(cond ((memq skk-kanagaki-keyboard-type '(nicola-dvorak omelet-dvorak)) |
| 107 |
'(?u ?h)) |
| 108 |
((memq skk-kanagaki-keyboard-type '(nicola-colemak omelet-colemak)) |
| 109 |
'(?t ?n)) |
| 110 |
(t |
| 111 |
'(?f ?j))) |
| 112 |
"*$BJQ493+;O0LCV$b$7$/$OAw$j3+;O0LCV$N;XDj$r$9$kJ8;z!#(B |
| 113 |
$B$3$l$i$NJ8;z$KEv$?$k%-!<$NF1;~BG80$r8!=P$9$k$H!"(B $B<B9T$5$l$k!#(B" |
| 114 |
:type '(repeat character) |
| 115 |
:group 'skk-nicola) |
| 116 |
|
| 117 |
(defcustom skk-nicola-toggle-kana-chars |
| 118 |
(cond ((memq skk-kanagaki-keyboard-type '(nicola-dvorak omelet-dvorak)) |
| 119 |
'(?e ?t)) |
| 120 |
((memq skk-kanagaki-keyboard-type '(nicola-colemak omelet-colemak)) |
| 121 |
'(?s ?e)) |
| 122 |
(t |
| 123 |
'(?d ?k))) |
| 124 |
"*$B%+%JJQ49$^$?$O(B $B%+%J(B $B"N(B $B$+$J(B $B@Z$jBX$($r$9$kJ8;z!#(B |
| 125 |
$B$3$l$i$NJ8;z$KEv$?$k%-!<$NF1;~BG80$r8!=P$9$k$H!"(B $B<B9T$5$l$k!#(B" |
| 126 |
:type '(repeat character) |
| 127 |
:group 'skk-nicola) |
| 128 |
|
| 129 |
(defcustom skk-nicola-use-koyubi-functions |
| 130 |
(cond ((eq skk-kanagaki-keyboard-type 'oasys) |
| 131 |
t) |
| 132 |
(t |
| 133 |
nil)) |
| 134 |
"*Non-nil $B$J$i(B OASYS $BIw$N(B BS $B%-!<$H<h$j>C$7%-!<$rMQ0U$9$k!#(B |
| 135 |
$B$3$l$O!"(BJIS $B%-!<%\!<%I$G$O(B \":\" $B$H(B \"]\" $B$N0LCV$KAjEv$9$k!#(B" |
| 136 |
:type 'boolean |
| 137 |
:group 'skk-nicola) |
| 138 |
|
| 139 |
(defcustom skk-nicola-prefix-suffix-abbrev-chars |
| 140 |
(cond ((memq skk-kanagaki-keyboard-type '(nicola-dvorak omelet-dvorak)) |
| 141 |
'(?i ?d)) |
| 142 |
((memq skk-kanagaki-keyboard-type '(nicola-colemak omelet-colemak)) |
| 143 |
'(?d ?h)) |
| 144 |
(t |
| 145 |
'(?g ?h))) |
| 146 |
"*$B@\F,!&@\Hx8lF~NO$r$7$?$j!"(B abbrev $B%b!<%I$KF~$kJ8;z!#(B |
| 147 |
$B$3$l$i$NJ8;z$KEv$?$k%-!<$NF1;~BG80$r8!=P$9$k$H!"(B $B<B9T$5$l$k!#(B" |
| 148 |
:type '(repeat character) |
| 149 |
:group 'skk-nicola) |
| 150 |
|
| 151 |
(defcustom skk-nicola-prefix-suffix-chars |
| 152 |
(cond ((memq skk-kanagaki-keyboard-type '(nicola-dvorak omelet-dvorak)) |
| 153 |
'(?o ?n)) |
| 154 |
((memq skk-kanagaki-keyboard-type '(nicola-colemak omelet-colemak)) |
| 155 |
'(?r ?i)) |
| 156 |
(t |
| 157 |
'(?s ?l))) |
| 158 |
"*$B@\F,!&@\Hx8lF~NO$r$9$k!#(B |
| 159 |
$B$3$l$i$NJ8;z$KEv$?$k%-!<$NF1;~BG80$r8!=P$9$k$H!"(B $B<B9T$5$l$k!#(B |
| 160 |
abbrev $B$HF1$8%-!<$K$9$k>l9g$O(B skk-nicola-prefix-suffix-abbrev-chars $B$r;H$&!#(B" |
| 161 |
:type '(repeat character) |
| 162 |
:group 'skk-nicola) |
| 163 |
|
| 164 |
(defcustom skk-nicola-abbrev-chars |
| 165 |
(cond ((memq skk-kanagaki-keyboard-type '(nicola-dvorak omelet-dvorak)) |
| 166 |
'(?i ?d)) |
| 167 |
((memq skk-kanagaki-keyboard-type '(nicola-colemak omelet-colemak)) |
| 168 |
'(?d ?h)) |
| 169 |
(t |
| 170 |
'(?g ?h))) |
| 171 |
"abbrev $B%b!<%I$KF~$kJ8;z!#(B |
| 172 |
$B$3$l$i$NJ8;z$KEv$?$k%-!<$NF1;~BG80$r8!=P$9$k$H!"(B $B<B9T$5$l$k!#(B |
| 173 |
$B@\F,!&@\Hx8lF~NO$HF1$8%-!<$K$9$k>l9g$O(B skk-nicola-prefix-suffix-abbrev-chars $B$r;H$&!#(B" |
| 174 |
:type '(repeat character) |
| 175 |
:group 'skk-nicola) |
| 176 |
|
| 177 |
(defcustom skk-nicola-okuri-style 'nicola-skk |
| 178 |
"*$BAw$j2>L>$N%9%?%$%k!#(B |
| 179 |
`nicola-skk' $B$rA*$V$H!"!V"&$7(B*$B$C(B $B"M(B $B"'CN$C!W$N$h$&$KJQ49$9$k!#(B |
| 180 |
`skk' $B$rA*$V$H!"!V"&$7(B*$B$C$F(B $B"M(B $B"'CN$C$F!W$N$h$&$KJQ49$9$k!#(B" |
| 181 |
:type '(choice (const nicola-skk) |
| 182 |
(const skk)) |
| 183 |
:group 'skk-nicola) |
| 184 |
|
| 185 |
(defcustom skk-nicola-help-key "2" |
| 186 |
"* \\[help] $B$K$*$$$F%X%k%W$rI=<($9$k%-!<!#(B" |
| 187 |
:type (if (get 'key-sequence 'widget-type) |
| 188 |
'key-sequence |
| 189 |
'sexp) |
| 190 |
:group 'skk-nicola) |
| 191 |
|
| 192 |
(defcustom skk-nicola-2nd-help-key "3" |
| 193 |
"* \\[help] $B$K$*$$$F$b$&$R$H$D$N%X%k%W$rI=<($9$k%-!<!#(B" |
| 194 |
:type (if (get 'key-sequence 'widget-type) |
| 195 |
'key-sequence |
| 196 |
'sexp) |
| 197 |
:group 'skk-nicola) |
| 198 |
|
| 199 |
(defcustom skk-nicola-hiragana-mode-string |
| 200 |
(cond ((eq skk-status-indicator 'left) "$B$K$3$i(B:") |
| 201 |
(t " $B$K$3$i(B")) |
| 202 |
"*$B$R$i$,$J%b!<%I$N%$%s%8%1!<%?!#(B" |
| 203 |
:type 'string |
| 204 |
:group 'skk-nicola) |
| 205 |
|
| 206 |
(defcustom skk-nicola-katakana-mode-string |
| 207 |
(cond ((eq skk-status-indicator 'left) "$B%K%3%i(B:") |
| 208 |
(t " $B%K%3%i(B")) |
| 209 |
"*$B%+%?%+%J%b!<%I$N%$%s%8%1!<%?!#(B" |
| 210 |
:type 'string |
| 211 |
:group 'skk-nicola) |
| 212 |
|
| 213 |
;; Internal constants and variables. |
| 214 |
|
| 215 |
(defconst skk-nicola-hiragana-rom-string skk-hiragana-mode-string) |
| 216 |
(defconst skk-nicola-katakana-rom-string skk-katakana-mode-string) |
| 217 |
|
| 218 |
(defvar skk-nicola-plain-rule nil) |
| 219 |
(defvar skk-nicola-lshift-rule nil) |
| 220 |
(defvar skk-nicola-rshift-rule nil) |
| 221 |
|
| 222 |
(defvar skk-nicola-temp-data nil) |
| 223 |
|
| 224 |
(skk-deflocalvar skk-nicola-okuri-flag nil) |
| 225 |
|
| 226 |
;; Shut up compiler. |
| 227 |
(defvar skktut-j-mode-map) |
| 228 |
(defvar skktut-latin-mode-map) |
| 229 |
|
| 230 |
;; Hooks. |
| 231 |
|
| 232 |
(add-hook 'skk-mode-hook 'skk-nicola-setup) |
| 233 |
(add-hook 'skk-mode-hook 'skk-nicola-setup-modeline) |
| 234 |
|
| 235 |
;; Functions. |
| 236 |
|
| 237 |
(defun skk-nicola-setup () |
| 238 |
"NICOLA $B$N=i4|@_Dj$r$9$k!#(B" |
| 239 |
;; SKK $B$N=i2s5/F0;~$N$_<B9T$5$l$k$Y$-$b$N$O$3$N4X?t$KF~$l$k!#(B |
| 240 |
(dolist (key skk-nicola-lshift-keys) |
| 241 |
(define-key skk-j-mode-map |
| 242 |
key |
| 243 |
'skk-nicola-self-insert-lshift) |
| 244 |
(define-key skk-latin-mode-map |
| 245 |
key |
| 246 |
'skk-nicola-turn-on-j-mode)) |
| 247 |
(dolist (key skk-nicola-rshift-keys) |
| 248 |
(define-key skk-j-mode-map |
| 249 |
key |
| 250 |
'skk-nicola-self-insert-rshift) |
| 251 |
(define-key skk-latin-mode-map |
| 252 |
key |
| 253 |
'skk-nicola-turn-on-j-mode)) |
| 254 |
;; |
| 255 |
(when skk-nicola-help-key |
| 256 |
(define-key help-map |
| 257 |
skk-nicola-help-key |
| 258 |
'skk-nicola-help)) |
| 259 |
(when skk-nicola-2nd-help-key |
| 260 |
(define-key help-map |
| 261 |
skk-nicola-2nd-help-key |
| 262 |
'skk-nicola-2nd-help)) |
| 263 |
;; |
| 264 |
(unless skk-nicola-plain-rule |
| 265 |
(setq skk-nicola-plain-rule |
| 266 |
(symbol-value |
| 267 |
(intern |
| 268 |
(format "skk-%s-plain-rule-list" |
| 269 |
skk-kanagaki-keyboard-type))))) |
| 270 |
(unless skk-nicola-lshift-rule |
| 271 |
(setq skk-nicola-lshift-rule |
| 272 |
(symbol-value |
| 273 |
(intern |
| 274 |
(format "skk-%s-lshift-rule-list" |
| 275 |
skk-kanagaki-keyboard-type))))) |
| 276 |
(unless skk-nicola-rshift-rule |
| 277 |
(setq skk-nicola-rshift-rule |
| 278 |
(symbol-value |
| 279 |
(intern |
| 280 |
(format "skk-%s-rshift-rule-list" |
| 281 |
skk-kanagaki-keyboard-type))))) |
| 282 |
;; |
| 283 |
(remove-hook 'skk-mode-hook 'skk-nicola-setup)) |
| 284 |
|
| 285 |
(defun skk-nicola-setup-modeline () |
| 286 |
(cl-case skk-kanagaki-state |
| 287 |
(kana |
| 288 |
(setq skk-hiragana-mode-string skk-nicola-hiragana-mode-string |
| 289 |
skk-katakana-mode-string skk-nicola-katakana-mode-string)) |
| 290 |
(rom |
| 291 |
(setq skk-hiragana-mode-string skk-nicola-hiragana-rom-string |
| 292 |
skk-katakana-mode-string skk-nicola-katakana-rom-string))) |
| 293 |
;; |
| 294 |
(skk-modify-indicator-alist 'katakana |
| 295 |
skk-katakana-mode-string) |
| 296 |
(skk-modify-indicator-alist 'hiragana |
| 297 |
skk-hiragana-mode-string) |
| 298 |
;; |
| 299 |
(skk-update-modeline (if skk-katakana |
| 300 |
'katakana |
| 301 |
'hiragana))) |
| 302 |
|
| 303 |
(defun skk-nicola-setup-tutorial () |
| 304 |
(dolist (key skk-nicola-lshift-keys) |
| 305 |
(define-key skktut-j-mode-map |
| 306 |
key |
| 307 |
'skk-nicola-self-insert-lshift) |
| 308 |
(define-key skktut-latin-mode-map |
| 309 |
key |
| 310 |
'skk-nicola-turn-on-j-mode)) |
| 311 |
(dolist (key skk-nicola-rshift-keys) |
| 312 |
(define-key skktut-j-mode-map |
| 313 |
key |
| 314 |
'skk-nicola-self-insert-rshift) |
| 315 |
(define-key skktut-latin-mode-map |
| 316 |
key |
| 317 |
'skk-nicola-turn-on-j-mode))) |
| 318 |
|
| 319 |
;;;###autoload |
| 320 |
(defun skk-nicola-help (&optional arg) |
| 321 |
"$B8=:_;H$o$l$F$$$k?F;X%7%U%H%-!<G[Ns$rI=<($9$k!#(B" |
| 322 |
(interactive "p") |
| 323 |
(describe-variable |
| 324 |
(intern (format "skk-%s-keymap-display" |
| 325 |
skk-kanagaki-keyboard-type)))) |
| 326 |
|
| 327 |
;;;###autoload |
| 328 |
(defun skk-nicola-2nd-help () |
| 329 |
"skk-nicola.el $BFH<+$N%-!<Dj5A0lMw$rI=<($9$k!#(B" |
| 330 |
(interactive) |
| 331 |
(skk-kanagaki-help-1 |
| 332 |
"* SKK $B?F;X%7%U%HF~NO(B $B%X%k%W(B*" |
| 333 |
"$B?F;X%7%U%HF~NO%b!<%I$NFH<+%-!<Dj5A(B:" |
| 334 |
(nconc |
| 335 |
;; |
| 336 |
(mapcar |
| 337 |
#'(lambda (key) |
| 338 |
(cons (key-description key) |
| 339 |
"$B:8?F;X%7%U%H%-!<(B")) |
| 340 |
skk-nicola-lshift-keys) |
| 341 |
;; |
| 342 |
(mapcar |
| 343 |
#'(lambda (key) |
| 344 |
(cons (key-description key) |
| 345 |
"$B1&?F;X%7%U%H%-!<(B")) |
| 346 |
skk-nicola-rshift-keys) |
| 347 |
;; |
| 348 |
(list (cons "SPC" |
| 349 |
"$BAw$j$J$7JQ493+;O(B")) |
| 350 |
;; |
| 351 |
(list |
| 352 |
(cl-do ((spec (nth 4 skk-kanagaki-rule-tree) |
| 353 |
(cdr spec)) |
| 354 |
(list nil (car spec)) |
| 355 |
(str nil |
| 356 |
(when (memq |
| 357 |
(nth 3 list) |
| 358 |
'(skk-input-by-code-or-menu)) |
| 359 |
(nth 1 list)))) |
| 360 |
((or str |
| 361 |
(null spec)) |
| 362 |
(when (stringp str) |
| 363 |
(cons str |
| 364 |
"$B%3!<%I$^$?$O%a%K%e!<$K$h$kF~NO(B"))))) |
| 365 |
;; |
| 366 |
(list |
| 367 |
(cl-do ((spec (nth 4 skk-kanagaki-rule-tree) |
| 368 |
(cdr spec)) |
| 369 |
(list nil |
| 370 |
(car spec)) |
| 371 |
(str nil |
| 372 |
(when (memq |
| 373 |
(nth 3 list) |
| 374 |
'(skk-today)) |
| 375 |
(nth 1 list)))) |
| 376 |
((or str |
| 377 |
(null spec)) |
| 378 |
(when (stringp str) |
| 379 |
(cons str "$B:#F|$NF|IU$1$rA^F~(B"))))) |
| 380 |
;; |
| 381 |
(list |
| 382 |
(cl-do ((spec (nth 4 skk-kanagaki-rule-tree) |
| 383 |
(cdr spec)) |
| 384 |
(list nil |
| 385 |
(car spec)) |
| 386 |
(str nil |
| 387 |
(when (memq |
| 388 |
(nth 3 list) |
| 389 |
'(skk-jisx0208-latin-mode)) |
| 390 |
(nth 1 list)))) |
| 391 |
((or str |
| 392 |
(null spec)) |
| 393 |
(when (stringp str) |
| 394 |
(cons str "$BA41Q%b!<%I(B"))))) |
| 395 |
;; |
| 396 |
(list |
| 397 |
(cons (format |
| 398 |
"%c + %c" |
| 399 |
(car skk-nicola-set-henkan-point-chars) |
| 400 |
(cadr skk-nicola-set-henkan-point-chars)) |
| 401 |
"$BJQ493+;OE@$r%;%C%H!"Aw$j3+;OE@;XDj(B") |
| 402 |
(cons (format |
| 403 |
"%c + %c" |
| 404 |
(car skk-nicola-prefix-suffix-abbrev-chars) |
| 405 |
(cadr skk-nicola-prefix-suffix-abbrev-chars)) |
| 406 |
"$B@\F,<-(B or $B@\Hx<-JQ49(B ($B"&%b!<%I(B or $B"'%b!<%I(B)$B!"(Babbrev $B%b!<%I(B") |
| 407 |
(cons (format |
| 408 |
"%c + %c" |
| 409 |
(car skk-nicola-prefix-suffix-chars) |
| 410 |
(cadr skk-nicola-prefix-suffix-chars)) |
| 411 |
"$B@\F,<-(B or $B@\Hx<-JQ49(B ($B"&%b!<%I(B or $B"'%b!<%I(B)") |
| 412 |
(cons (format |
| 413 |
"%c + %c" |
| 414 |
(car skk-nicola-abbrev-chars) |
| 415 |
(cadr skk-nicola-abbrev-chars)) |
| 416 |
"abbrev $B%b!<%I(B") |
| 417 |
(cons (format |
| 418 |
"%c + %c" |
| 419 |
(car skk-nicola-toggle-kana-chars) |
| 420 |
(cadr skk-nicola-toggle-kana-chars)) |
| 421 |
"$B%+%J%b!<%I(B or $B%+%JJQ49(B") |
| 422 |
(cons "$B:8?F;X%7%U%H(B + $B1&?F;X%7%U%H(B" |
| 423 |
"latin $B%b!<%I(B $B"N(B $B$+$J%b!<%I@Z$jBX$((B") |
| 424 |
(cons (format "M-x help %s" skk-nicola-help-key) |
| 425 |
"$B8=:_$NF~NOJ}<0$N%-!<G[Ns$rI=<((B") |
| 426 |
(cons (format "M-x help %s" skk-nicola-2nd-help-key) |
| 427 |
"$B$3$N%X%k%W$rI=<((B"))))) |
| 428 |
|
| 429 |
;;;###autoload |
| 430 |
(defalias 'skk-nicola-self-insert-rshift 'skk-nicola-self-insert-lshift) |
| 431 |
|
| 432 |
;;;###autoload |
| 433 |
(defun skk-nicola-self-insert-lshift (&optional arg parg) |
| 434 |
"$B1&$^$?$O:8%7%U%H$K3d$jIU$1$k4X?t!#(B" |
| 435 |
(interactive "p") |
| 436 |
(unless parg |
| 437 |
(setq parg current-prefix-arg)) |
| 438 |
(skk-nicola-self-insert-lshift-1 arg parg) |
| 439 |
;; verbose message |
| 440 |
(skk-henkan-on-message)) |
| 441 |
|
| 442 |
;;;###autoload |
| 443 |
(let ((property 'delete-selection)) |
| 444 |
(put 'skk-nicola-self-insert-rshift property t) |
| 445 |
(put 'skk-nicola-self-insert-lshift property t)) |
| 446 |
|
| 447 |
(defun skk-nicola-self-insert-lshift-1 (arg parg) |
| 448 |
(when (or (and (markerp skk-nicola-okuri-flag) |
| 449 |
(<= (point) |
| 450 |
(marker-position skk-nicola-okuri-flag))) |
| 451 |
(not (eq skk-henkan-mode 'on))) |
| 452 |
(setq skk-nicola-okuri-flag nil)) |
| 453 |
;; |
| 454 |
(cond |
| 455 |
((and (eq skk-kanagaki-state 'kana) |
| 456 |
(not skk-jisx0201-mode)) |
| 457 |
(skk-nicola-insert arg parg)) |
| 458 |
(t |
| 459 |
(unless last-command-event |
| 460 |
(set 'last-command-event ?\s)) |
| 461 |
(call-interactively 'skk-insert)))) |
| 462 |
|
| 463 |
;;;###autoload |
| 464 |
(defun skk-nicola-turn-on-j-mode (&optional arg) |
| 465 |
"`skk-latin-mode' $B$K$*$$$F!"(B`skk-j-mode' $B$KF~$k$?$a$N%3%^%s%I!#(B |
| 466 |
$B:81&?F;X%-!<$NF1;~BG80$r8!=P$7$?>l9g$K(B `skk-j-mode' $B$KF~$k!#(B" |
| 467 |
(interactive "*p") |
| 468 |
(if (sit-for skk-nicola-latin-interval t) |
| 469 |
;; then |
| 470 |
(skk-bind-last-command-char |
| 471 |
(if (characterp (event-to-character last-command-event)) |
| 472 |
(event-to-character last-command-event) |
| 473 |
?\s) |
| 474 |
(call-interactively 'self-insert-command t)) |
| 475 |
;; else |
| 476 |
(let ((last last-command-event) |
| 477 |
(next (read-event)) |
| 478 |
char) |
| 479 |
(if (eq last next) |
| 480 |
;; then |
| 481 |
(skk-bind-last-command-char |
| 482 |
(if (characterp (event-to-character |
| 483 |
last-command-event)) |
| 484 |
(event-to-character last-command-event) |
| 485 |
?\s) |
| 486 |
(call-interactively 'self-insert-command t) |
| 487 |
(call-interactively 'self-insert-command t)) |
| 488 |
;; else |
| 489 |
(when (characterp next) |
| 490 |
(setq char next) |
| 491 |
(setq next (key-description |
| 492 |
(skk-char-to-unibyte-string char)))) |
| 493 |
(when (eq next 'space) |
| 494 |
(setq next (key-description " "))) |
| 495 |
(when (symbolp next) |
| 496 |
(setq next (key-description |
| 497 |
(vector next)))) |
| 498 |
;; |
| 499 |
(unless (stringp next) |
| 500 |
(setq next (format "%s" next))) |
| 501 |
;; |
| 502 |
(cond ((member next |
| 503 |
(mapcar |
| 504 |
#'(lambda (key) |
| 505 |
(key-description key)) |
| 506 |
(append |
| 507 |
skk-nicola-rshift-keys |
| 508 |
skk-nicola-lshift-keys))) |
| 509 |
;; |
| 510 |
(skk-j-mode-on) |
| 511 |
(skk-cursor-set skk-cursor-hiragana-color)) |
| 512 |
(char |
| 513 |
(skk-bind-last-command-char |
| 514 |
(if (characterp (event-to-character |
| 515 |
last-command-event)) |
| 516 |
(event-to-character last-command-event) |
| 517 |
?\s) |
| 518 |
(call-interactively 'self-insert-command t)) |
| 519 |
(skk-bind-last-command-char char |
| 520 |
(call-interactively 'self-insert-command |
| 521 |
t))))))) |
| 522 |
nil) |
| 523 |
|
| 524 |
;;;###autoload |
| 525 |
(defun skk-nicola-insert (&optional arg parg) |
| 526 |
"$BF1;~BG80$rG'<1$7$F!"(BNICOLA $B$+$JF~NO$r$9$k!#(B" |
| 527 |
(interactive "*p") |
| 528 |
(let (time1 |
| 529 |
time2 |
| 530 |
next-event |
| 531 |
next) |
| 532 |
;; |
| 533 |
(setq time1 (skk-nicola-format-time |
| 534 |
(current-time))) |
| 535 |
;; |
| 536 |
(unless (eq skk-henkan-mode 'on) |
| 537 |
(setq skk-nicola-okuri-flag nil)) |
| 538 |
;; |
| 539 |
(cond |
| 540 |
((sit-for skk-nicola-interval t) |
| 541 |
;; No input in the interval. |
| 542 |
(skk-nicola-insert-single this-command arg parg)) |
| 543 |
(t |
| 544 |
;; Some key's pressed. |
| 545 |
(setq time2 (skk-nicola-format-time (current-time))) |
| 546 |
;; |
| 547 |
(setq next-event (read-event) |
| 548 |
next (skk-nicola-event-to-key next-event)) |
| 549 |
(cond |
| 550 |
((skk-nicola-maybe-double-p this-command next) |
| 551 |
(skk-nicola-treat-triple this-command next |
| 552 |
time1 time2 |
| 553 |
arg)) |
| 554 |
(t |
| 555 |
;; $B:G=i$NF~NO$OC1FHBG80$G$7$+$"$j$($J$$$H3NDj!#(B |
| 556 |
(skk-nicola-insert-single this-command arg) |
| 557 |
(skk-unread-event next-event))))) |
| 558 |
;; $BE}7WE*2ACM$,$"$k$+$J(B...$B!)(B |
| 559 |
; (setq skk-nicola-temp-data |
| 560 |
; (cons |
| 561 |
; (list (or (skk-last-command-char) this-command) |
| 562 |
; period1 |
| 563 |
; next |
| 564 |
; period2 |
| 565 |
; third) |
| 566 |
; skk-nicola-temp-data)) |
| 567 |
) |
| 568 |
;; `skk-kana-input' $B$,2?$bF~NO$7$J$$$h$&$K!"(Bnil $B$rJV$7$F$*$/!#(B |
| 569 |
nil) |
| 570 |
|
| 571 |
(defun skk-nicola-format-time (time) |
| 572 |
"`current-time' $B$NJV$97k2L$rJQ49$7$FI>2A$G$-$k$h$&$K$9$k!#(B" |
| 573 |
(let ((time1 (* (float 65536) ;; 2^16 |
| 574 |
(car time))) |
| 575 |
(time2 (cadr time)) |
| 576 |
(time3 (/ (caddr time) |
| 577 |
(float 1000000)))) |
| 578 |
(+ time1 time2 time3))) |
| 579 |
|
| 580 |
(defun skk-nicola-event-to-key (event) |
| 581 |
"EVENT $B$rH/@8$9$k%-!<$r<hF@$9$k!#(B" |
| 582 |
(if (symbolp event) |
| 583 |
(vector event) |
| 584 |
event)) |
| 585 |
|
| 586 |
;; $B!A(B NICOLA $B5,3J=q$h$j(B $B!A(B |
| 587 |
;; 7.4.2$B!!BG80=g=x$@$1$G$O7hDj$G$-$J$$F1;~BG80(B |
| 588 |
;; |
| 589 |
;; $BJ8;z%-!<(Ba$B!"?F;X%-!<(Bs$B!"J8;z%-!<(Bb$B$N#3$D$N%-!<$,!"H=Dj;~4V0JFb(B |
| 590 |
;; $B$N4V3V$G=EJ#$7$F2!$5$l$?>l9g$O!"Cf1{$K64$^$l$??F;X%-!<(Bs$B$,J8(B |
| 591 |
;; $B;z%-!<(Ba$B$r=$>~$9$k$b$N$+!"J8;z%-!<(B b$B$r=$>~$9$k$b$N$+$r7hDj$7(B |
| 592 |
;; $B$J$1$l$P$J$i$J$$!#!J?^#6!K(B |
| 593 |
;; |
| 594 |
;; $B4pK\E*$K$O!"2!2<;~9o$,!"(B $B$h$j?F;X%-!<$K6a$$J8;z%-!<$H$N4V$K(B |
| 595 |
;; $BF1;~BG80$,@.N)$9$k$HH=CG$9$k!#(B |
| 596 |
;; |
| 597 |
;; $B?^(B6$B!!!!!!!VJ8;z%-!<(BON$B"*?F;X%-!<(BON$B"*J8;z%-!<(BON$B!W$NNc(B |
| 598 |
;; |
| 599 |
;; $B!!!!J8;z%-!<(Ba $B!!!!!!!!!!!!!!(B|$B!1!1!1(B| |
| 600 |
;; $B!!!!!!!!!!!!!!!!!!!!!D!D!D!D!!!!!!!!!D!D!D!D!D!D!D!D(B |
| 601 |
;; |
| 602 |
;; $B!!!!?F;X%-!<(Bs $B!!!!!!!!!!!!!!!!!!(B|$B!1!1!1(B| |
| 603 |
;; $B!!!!!!!!!!!!!!!!!!!!!D!D!D!D!D!D!!!!!!!!!D!D!D!D!D!D(B |
| 604 |
;; |
| 605 |
;; $B!!!!J8;z%-!<(Bb $B!!!!!!!!!!!!!!!!!!!!!!!!(B|$B!1!1!1(B| |
| 606 |
;; $B!!!!!!!!!!!!!!!!!!!!!D!D!D!D!D!D!D!D!D!!!!!!!!!D!D!D(B |
| 607 |
;; |
| 608 |
;; $B!!!!!!!!!!!!!!!!!!!!!!!!!!!!(B|-t1-|-t2-| |
| 609 |
;; (t1$B!"(Bt2$B$O6&$KH=Dj;~4V0JFb(B) |
| 610 |
;; |
| 611 |
;; t1=t2$B$J$i$P!"J8;z%-!<(Ba$B$H?F;X%-!<(Bs$B$,F1;~BG80!"J8;z%-!<(Bb$B$OC1FHBG80!#(B |
| 612 |
(defun skk-nicola-treat-triple (first next time1 time2 arg) |
| 613 |
"3 $B$D$NBG80$N$&$A!"$I$N(B 2 $BBG80$,F1;~BG80$+H=Dj$7$F%P%C%U%!$KA^F~$9$k!#(B" |
| 614 |
(let ((period1 (- time2 time1)) |
| 615 |
time3 |
| 616 |
period2 |
| 617 |
str |
| 618 |
third-event |
| 619 |
third) |
| 620 |
(cond |
| 621 |
((sit-for period1 t) |
| 622 |
;; 3 $B$D$a$NBG80$O@)8B;~4VFb$K$J$+$C$?!#F1;~BG80$H3NDj!#(B(< t1 t2) |
| 623 |
(skk-nicola-insert-double first next arg)) |
| 624 |
(t |
| 625 |
;; 3 $B$D$a$NBG80$,@)8B;~4VFb$K$"$C$?!#$=$N(B event $B$rD4$Y$k!#(B |
| 626 |
(setq period2 (- (setq time3 (skk-nicola-format-time |
| 627 |
(current-time))) |
| 628 |
time2) |
| 629 |
str (if (characterp next) |
| 630 |
(skk-char-to-unibyte-string next)) |
| 631 |
third-event (read-event) |
| 632 |
third (skk-nicola-event-to-key third-event)) |
| 633 |
(cond |
| 634 |
((and |
| 635 |
(skk-nicola-maybe-double-p next third) |
| 636 |
;; ($BMW$i$J$$$+$bCN$i$J$$$,!"B?>/(B `sit-for' $B$NJV$C$F$/$k;~(B |
| 637 |
;; $B4V$H(B `current-time' $B$,JV$9;~4V$H$N4V$K%:%l$,@8$8$k$3$H(B |
| 638 |
;; $B$b$"$k$N$G!"0l1~Hf3S$7$F$*$/(B) |
| 639 |
(> period1 period2)) |
| 640 |
;; $BA0$N(B 2 $BBG80$OF1;~BG80$G$O$J$$$H3NDj!#(B |
| 641 |
;; $B8e$N(B 2 $BBG80$,F1;~BG80$+$I$&$+$O!"99$K<!$NF~NO$rD4$Y$J$$$H(B |
| 642 |
;; $B3NDj$7$J$$!#(B |
| 643 |
(skk-nicola-insert-single this-command arg) |
| 644 |
(skk-nicola-treat-triple |
| 645 |
(lookup-key skk-j-mode-map (or str next)) |
| 646 |
third |
| 647 |
time2 |
| 648 |
time3 |
| 649 |
arg)) |
| 650 |
(t |
| 651 |
;; $BA0$N(B 2 $BBG80$,F1;~BG80$H3NDj!#(B(< t1 t2) |
| 652 |
(skk-nicola-insert-double this-command next arg) |
| 653 |
(skk-unread-event third-event))))))) |
| 654 |
|
| 655 |
(defun skk-nicola-insert-single (command arg &optional parg) |
| 656 |
"$BC1FHBG80$r=hM}$9$k!#(B" |
| 657 |
(let ((char last-command-event)) |
| 658 |
(cl-case command |
| 659 |
(skk-nicola-self-insert-rshift |
| 660 |
;; ($BJQ49!&%9%Z!<%9(B) |
| 661 |
(skk-nicola-space-function arg parg)) |
| 662 |
(skk-nicola-self-insert-lshift |
| 663 |
;; $B:8%7%U%H(B |
| 664 |
(skk-nicola-lshift-function arg)) |
| 665 |
(t |
| 666 |
;; $BJ8;z(B |
| 667 |
(skk-nicola-insert-kana char |
| 668 |
skk-nicola-plain-rule |
| 669 |
arg))))) |
| 670 |
|
| 671 |
(defun skk-nicola-insert-double (first next arg) |
| 672 |
"$BF1;~BG80$r=hM}$9$k!#(B" |
| 673 |
(let ((command (cond |
| 674 |
((commandp first) |
| 675 |
first) |
| 676 |
((characterp first) |
| 677 |
(lookup-key skk-j-mode-map |
| 678 |
(skk-char-to-unibyte-string first))) |
| 679 |
(t |
| 680 |
(lookup-key skk-j-mode-map first)))) |
| 681 |
(char (if (characterp first) |
| 682 |
first |
| 683 |
last-command-event)) |
| 684 |
(str (when (characterp next) |
| 685 |
(skk-char-to-unibyte-string next)))) |
| 686 |
;; |
| 687 |
(cl-case (lookup-key skk-j-mode-map (or str next)) |
| 688 |
(skk-nicola-self-insert-rshift |
| 689 |
;; $B1&%7%U%H(B |
| 690 |
(cl-case command |
| 691 |
(skk-nicola-self-insert-rshift |
| 692 |
;; [$B1&(B $B1&(B] |
| 693 |
(skk-bind-last-command-char ?\s |
| 694 |
(cond (skk-henkan-mode |
| 695 |
;; |
| 696 |
(skk-kanagaki-insert arg) |
| 697 |
(unless (>= skk-nicola-interval |
| 698 |
1) |
| 699 |
;; $BC1FHBG80$rF10l%-!<O"B3BG80$GBeMQ$9$k!#(B |
| 700 |
(skk-kanagaki-insert arg))) |
| 701 |
(t |
| 702 |
(self-insert-command |
| 703 |
(if (< 1 skk-nicola-interval) |
| 704 |
;; $BC1FHBG80$rF10l%-!<O"B3BG80$GBeMQ$9$k!#(B |
| 705 |
arg |
| 706 |
(1+ arg))))))) |
| 707 |
(skk-nicola-self-insert-lshift |
| 708 |
;; [$B:8(B $B1&(B] |
| 709 |
(skk-nicola-double-shift)) |
| 710 |
(t |
| 711 |
;; [$BJ8;z(B $B1&(B] |
| 712 |
(skk-nicola-insert-kana char |
| 713 |
skk-nicola-rshift-rule |
| 714 |
arg)))) |
| 715 |
(skk-nicola-self-insert-lshift |
| 716 |
;; $B:8%7%U%H(B |
| 717 |
(cl-case command |
| 718 |
(skk-nicola-self-insert-lshift |
| 719 |
;;[$B:8(B $B:8(B] |
| 720 |
(cond ((skk-in-minibuffer-p) |
| 721 |
(exit-minibuffer)) |
| 722 |
(t |
| 723 |
(skk-nicola-lshift-function arg) |
| 724 |
(unless (< 1 skk-nicola-interval) |
| 725 |
;; $BC1FHBG80$rF10l%-!<O"B3BG80$GBeMQ$9$k!#(B |
| 726 |
(skk-nicola-lshift-function 1))))) |
| 727 |
(skk-nicola-self-insert-rshift |
| 728 |
;; [$B1&(B $B:8(B] |
| 729 |
(skk-nicola-double-shift)) |
| 730 |
(t |
| 731 |
;; [$BJ8;z(B $B:8(B] |
| 732 |
(skk-nicola-insert-kana char |
| 733 |
skk-nicola-lshift-rule |
| 734 |
arg)))) |
| 735 |
(t |
| 736 |
;; $BJ8;z(B |
| 737 |
(cond |
| 738 |
((eq command 'skk-nicola-self-insert-rshift) |
| 739 |
;; [$B1&(B $BJ8;z(B] |
| 740 |
(skk-nicola-insert-kana next |
| 741 |
skk-nicola-rshift-rule |
| 742 |
arg)) |
| 743 |
((eq command 'skk-nicola-self-insert-lshift) |
| 744 |
;; [$B:8(B $BJ8;z(B] |
| 745 |
(skk-nicola-insert-kana next |
| 746 |
skk-nicola-lshift-rule |
| 747 |
arg)) |
| 748 |
((and (not (eq char next)) |
| 749 |
(memq last-command-event |
| 750 |
skk-nicola-set-henkan-point-chars) |
| 751 |
(memq next |
| 752 |
skk-nicola-set-henkan-point-chars)) |
| 753 |
;; [fj] |
| 754 |
(cond |
| 755 |
((not (eq skk-henkan-mode 'on)) |
| 756 |
(skk-set-henkan-point-subr 1)) |
| 757 |
((eq (point) (marker-position skk-henkan-start-point)) |
| 758 |
nil) |
| 759 |
(t |
| 760 |
(skk-nicola-set-okuri-flag)))) |
| 761 |
((and (not (eq char next)) |
| 762 |
(memq char |
| 763 |
skk-nicola-prefix-suffix-abbrev-chars) |
| 764 |
(memq next |
| 765 |
skk-nicola-prefix-suffix-abbrev-chars)) |
| 766 |
;; [gh] suffix $B$N(B $BF~NO(B |
| 767 |
(cond |
| 768 |
((eq skk-henkan-mode 'active) |
| 769 |
;; $B@\Hx8l$N=hM}(B |
| 770 |
(skk-kakutei) |
| 771 |
(let (skk-kakutei-history) |
| 772 |
(skk-set-henkan-point-subr)) |
| 773 |
(insert-and-inherit ?>)) |
| 774 |
((eq skk-henkan-mode 'on) |
| 775 |
;; $B@\F,8l$N=hM}(B |
| 776 |
(skk-kana-cleanup 'force) |
| 777 |
(insert-and-inherit ?>) |
| 778 |
(skk-set-marker skk-henkan-end-point |
| 779 |
(point)) |
| 780 |
(setq skk-henkan-count 0 |
| 781 |
skk-henkan-key (buffer-substring-no-properties |
| 782 |
skk-henkan-start-point |
| 783 |
(point)) |
| 784 |
skk-prefix "") |
| 785 |
(skk-henkan)) |
| 786 |
(t |
| 787 |
;; |
| 788 |
(skk-abbrev-mode 1)))) |
| 789 |
((and (not (eq char next)) |
| 790 |
(memq char |
| 791 |
skk-nicola-prefix-suffix-chars) |
| 792 |
(memq next |
| 793 |
skk-nicola-prefix-suffix-chars)) |
| 794 |
;; [sl] suffix $B$N(B $BF~NO(B |
| 795 |
(cond |
| 796 |
((eq skk-henkan-mode 'active) |
| 797 |
;; $B@\Hx8l$N=hM}(B |
| 798 |
(skk-kakutei) |
| 799 |
(let (skk-kakutei-history) |
| 800 |
(skk-set-henkan-point-subr)) |
| 801 |
(insert-and-inherit ?>)) |
| 802 |
((eq skk-henkan-mode 'on) |
| 803 |
;; $B@\F,8l$N=hM}(B |
| 804 |
(skk-kana-cleanup 'force) |
| 805 |
(insert-and-inherit ?>) |
| 806 |
(skk-set-marker skk-henkan-end-point |
| 807 |
(point)) |
| 808 |
(setq skk-henkan-count 0 |
| 809 |
skk-henkan-key (buffer-substring-no-properties |
| 810 |
skk-henkan-start-point |
| 811 |
(point)) |
| 812 |
skk-prefix "") |
| 813 |
(skk-henkan)))) |
| 814 |
((and (not (eq char next)) |
| 815 |
(memq char |
| 816 |
skk-nicola-abbrev-chars) |
| 817 |
(memq next |
| 818 |
skk-nicola-abbrev-chars)) |
| 819 |
;; [gh] |
| 820 |
(skk-kakutei) |
| 821 |
(skk-abbrev-mode 1)) |
| 822 |
((and (not (eq char next)) |
| 823 |
(memq char |
| 824 |
skk-nicola-toggle-kana-chars) |
| 825 |
(memq next |
| 826 |
skk-nicola-toggle-kana-chars)) |
| 827 |
;; [dk] |
| 828 |
(skk-toggle-characters 1)) |
| 829 |
(t |
| 830 |
;; [$BJ8;z(B $BJ8;z(B] |
| 831 |
(let ((str (skk-nicola-insert-kana |
| 832 |
char |
| 833 |
skk-nicola-plain-rule |
| 834 |
arg))) |
| 835 |
(when (and skk-isearch-switch |
| 836 |
(not skk-henkan-mode)) |
| 837 |
(setq isearch-cmds |
| 838 |
(cons |
| 839 |
(cond |
| 840 |
((vectorp (car isearch-cmds)) |
| 841 |
(let ((cmds (copy-sequence (car isearch-cmds)))) |
| 842 |
(aset cmds 0 (concat (aref (car isearch-cmds) 0) |
| 843 |
str)) |
| 844 |
(aset cmds 1 (concat (aref (car isearch-cmds) 1) |
| 845 |
str)) |
| 846 |
cmds)) |
| 847 |
(t |
| 848 |
(nconc |
| 849 |
(list (concat (caar isearch-cmds) |
| 850 |
str) |
| 851 |
(concat (cadar isearch-cmds) |
| 852 |
str)) |
| 853 |
(cddar isearch-cmds)))) |
| 854 |
isearch-cmds)))) |
| 855 |
(unless (and (< 1 skk-nicola-interval) |
| 856 |
(eq next char)) |
| 857 |
;; $BC1FHBG80$rF10l%-!<O"B3BG80$GBeMQ$G$-$k$h$&$K!#(B |
| 858 |
(skk-nicola-insert-kana |
| 859 |
next |
| 860 |
skk-nicola-plain-rule)))))))) |
| 861 |
|
| 862 |
(defun skk-nicola-double-shift () |
| 863 |
"$B?F;X1&%-!<$H?F;X:8%-!<$NF1;~BG80$r=hM}$9$k!#(B" |
| 864 |
(cond |
| 865 |
((and skk-j-mode |
| 866 |
(not skk-katakana)) |
| 867 |
(skk-latin-mode 1)) |
| 868 |
(t |
| 869 |
(skk-toggle-characters 1))) |
| 870 |
nil) |
| 871 |
|
| 872 |
(defun skk-nicola-maybe-double-p (first next) |
| 873 |
"FIRST $B$H(B NEXT $B$,F1;~BG80$@$C$?$i(B non-nil $B$rJV$9!#(B" |
| 874 |
(let ((command (cond |
| 875 |
((commandp first) |
| 876 |
first) |
| 877 |
((characterp first) |
| 878 |
(lookup-key skk-j-mode-map |
| 879 |
(skk-char-to-unibyte-string first))) |
| 880 |
(t |
| 881 |
(lookup-key skk-j-mode-map first)))) |
| 882 |
(char (if (characterp first) |
| 883 |
first |
| 884 |
last-command-event)) |
| 885 |
(str (when (characterp next) |
| 886 |
(skk-char-to-unibyte-string next))) |
| 887 |
(shifts '(skk-nicola-self-insert-lshift |
| 888 |
skk-nicola-self-insert-rshift))) |
| 889 |
(or |
| 890 |
;; * $B$I$A$i$+0lJ}$,?F;X(B |
| 891 |
(or (memq command shifts) |
| 892 |
(memq (lookup-key skk-j-mode-map (or str |
| 893 |
next)) |
| 894 |
shifts)) |
| 895 |
;; * skk-nicola $B$K1w$1$kFC<lF1;~BG80%-!<(B |
| 896 |
(and (not (eq char next)) |
| 897 |
(or |
| 898 |
;; [fj] |
| 899 |
(and (memq last-command-event |
| 900 |
skk-nicola-set-henkan-point-chars) |
| 901 |
(memq next |
| 902 |
skk-nicola-set-henkan-point-chars)) |
| 903 |
;; [gh] |
| 904 |
(and (memq char |
| 905 |
skk-nicola-prefix-suffix-abbrev-chars) |
| 906 |
(memq next |
| 907 |
skk-nicola-prefix-suffix-abbrev-chars)) |
| 908 |
;; [sl] |
| 909 |
(and (memq char |
| 910 |
skk-nicola-prefix-suffix-chars) |
| 911 |
(memq next |
| 912 |
skk-nicola-prefix-suffix-chars)) |
| 913 |
;; [gh] |
| 914 |
(and (memq char |
| 915 |
skk-nicola-abbrev-chars) |
| 916 |
(memq next |
| 917 |
skk-nicola-abbrev-chars)) |
| 918 |
;; [dk] |
| 919 |
(and (memq char |
| 920 |
skk-nicola-toggle-kana-chars) |
| 921 |
(memq next |
| 922 |
skk-nicola-toggle-kana-chars))))))) |
| 923 |
|
| 924 |
(defun skk-nicola-insert-kana (char rule &optional arg) |
| 925 |
"CHAR $B$r(B RULE $B$NCf$+$iC5$7$FF~NO$9$Y$-J8;zNs$r7hDj$9$k!#(B |
| 926 |
ARG $B$rM?$($i$l$?>l9g$O$=$N?t$@$1J8;zNs$rO"7k$7$FF~NO$9$k!#(B" |
| 927 |
(let* ((el (cadr (assq char rule))) |
| 928 |
(str (when el |
| 929 |
(cond ((stringp el) |
| 930 |
el) |
| 931 |
((not (listp el)) |
| 932 |
nil) |
| 933 |
(skk-katakana |
| 934 |
(car el)) |
| 935 |
(t |
| 936 |
(cdr el))))) |
| 937 |
(fun (when (and el |
| 938 |
(symbolp el)) |
| 939 |
el)) |
| 940 |
(arg (prefix-numeric-value arg))) |
| 941 |
;; |
| 942 |
(when str |
| 943 |
(if (symbolp str) |
| 944 |
(setq fun str |
| 945 |
str nil) |
| 946 |
(skk-cancel-undo-boundary) |
| 947 |
(skk-insert-str |
| 948 |
(setq str (make-string arg (string-to-char str)))))) |
| 949 |
;; |
| 950 |
(when fun |
| 951 |
(funcall fun arg)) |
| 952 |
;; |
| 953 |
(cond (skk-nicola-okuri-flag |
| 954 |
(skk-nicola-process-okuri)) |
| 955 |
((eq skk-henkan-mode 'active) |
| 956 |
(skk-kakutei))) |
| 957 |
;; $B2?$+$K;H$&$3$H$,$"$k$+$b$7$l$J$$$N$G!"(B |
| 958 |
;; STR $B$rJV$7$F$*$/!#(B |
| 959 |
str)) |
| 960 |
|
| 961 |
(defun skk-nicola-process-okuri () |
| 962 |
"$BAw$j3+;O$NI8<1$K$h$jAw$j3+;OE@$rG'<1$7!"Aw$j$"$jJQ49$r3+;O$9$k!#(B" |
| 963 |
(let ((okuri (buffer-substring-no-properties |
| 964 |
(1+ skk-nicola-okuri-flag) |
| 965 |
(point))) |
| 966 |
tag) |
| 967 |
(unless (and (not (eq skk-nicola-okuri-style |
| 968 |
'nicola-skk)) |
| 969 |
(member okuri '("$B$C(B" "$B%C(B"))) |
| 970 |
(skk-save-point |
| 971 |
(goto-char skk-nicola-okuri-flag) |
| 972 |
(when (eq (following-char) |
| 973 |
?*) |
| 974 |
(delete-char 1)) |
| 975 |
(backward-char 1) |
| 976 |
(when (member (buffer-substring-no-properties |
| 977 |
(point) |
| 978 |
(marker-position skk-nicola-okuri-flag)) |
| 979 |
'("$B$C(B" "$B%C(B")) |
| 980 |
(setq tag 'no-sokuon))) |
| 981 |
(skk-kanagaki-set-okurigana tag)))) |
| 982 |
|
| 983 |
(defun skk-nicola-set-okuri-flag () |
| 984 |
"$BAw$j3+;OE@$r(B marker $B$GI8<1$7!"Aw$j$"$jJQ49$NBT$A>uBV$KF~$k!#(B |
| 985 |
`*' $B$rA^F~$9$k$3$H$GI8<1$9$k!#(B" |
| 986 |
(interactive) |
| 987 |
(when (eq skk-henkan-mode 'on) |
| 988 |
;; $B"&%b!<%I$N$H$-$@$15!G=$9$k!#(B |
| 989 |
(let ((pt (point))) |
| 990 |
(unless (and (string= "*" |
| 991 |
(buffer-substring-no-properties |
| 992 |
(1- pt) |
| 993 |
pt)) |
| 994 |
(markerp skk-nicola-okuri-flag)) |
| 995 |
;; $B4{$KI8<1:Q$_$J$i2?$b$7$J$$!#(B |
| 996 |
(skk-set-marker skk-nicola-okuri-flag pt) |
| 997 |
(insert-and-inherit "*"))))) |
| 998 |
|
| 999 |
(defun skk-nicola-space-function (&optional arg parg) |
| 1000 |
"$B?F;X1&%-!<C1FHBG80;~$N5sF0$r7h$a$k4X?t!#(B" |
| 1001 |
(skk-bind-last-command-char ?\s |
| 1002 |
(cond |
| 1003 |
((eq skk-henkan-mode 'active) |
| 1004 |
(call-interactively 'skk-insert)) |
| 1005 |
((eq skk-henkan-mode 'on) |
| 1006 |
(skk-kanagaki-insert arg parg)) |
| 1007 |
(t |
| 1008 |
(self-insert-command arg))))) |
| 1009 |
|
| 1010 |
(defun skk-nicola-lshift-function (&optional arg) |
| 1011 |
"$B?F;X:8%-!<C1FHBG80;~$N5sF0$r7h$a$k4X?t!#(B" |
| 1012 |
(cond (skk-henkan-mode |
| 1013 |
;; $B3NDj$K;H$&!#(B |
| 1014 |
(skk-kakutei)) |
| 1015 |
(skk-nicola-use-lshift-as-space |
| 1016 |
;; |
| 1017 |
(skk-nicola-space-function arg)) |
| 1018 |
(skk-nicola-lshift-function |
| 1019 |
(if (commandp skk-nicola-lshift-function) |
| 1020 |
(call-interactively skk-nicola-lshift-function) |
| 1021 |
(funcall skk-nicola-lshift-function arg))) |
| 1022 |
(t |
| 1023 |
;; $B2~9T$K;H$&!#(B |
| 1024 |
(if (skk-in-minibuffer-p) |
| 1025 |
(exit-minibuffer) |
| 1026 |
(newline arg))))) |
| 1027 |
|
| 1028 |
;; Pieces of Advice. |
| 1029 |
|
| 1030 |
(defadvice skk-kanagaki-initialize (after skk-nicols-setup activate) |
| 1031 |
;; M-x skk-restart $BBP:v$H$7$F(B |
| 1032 |
(add-hook 'skk-mode-hook 'skk-nicola-setup) |
| 1033 |
(add-hook 'skk-mode-hook 'skk-nicola-setup-modeline)) |
| 1034 |
|
| 1035 |
(defadvice skk-insert (before skk-nicola-update-flag activate) |
| 1036 |
"$BAw$jBT$A>uBV$r4IM}$9$k!#(B" |
| 1037 |
(when (or (and (markerp skk-nicola-okuri-flag) |
| 1038 |
(<= (point) |
| 1039 |
(marker-position |
| 1040 |
skk-nicola-okuri-flag))) |
| 1041 |
(not (eq skk-henkan-mode 'on))) |
| 1042 |
(setq skk-nicola-okuri-flag nil))) |
| 1043 |
|
| 1044 |
(defadvice skk-kakutei (before skk-nicola-update-flag activate) |
| 1045 |
"$BAw$jBT$A>uBV$r4IM}$9$k!#(B" |
| 1046 |
(when (and skk-j-mode |
| 1047 |
(eq skk-henkan-mode 'on) |
| 1048 |
(markerp skk-nicola-okuri-flag)) |
| 1049 |
;; $B3NDj$9$k$H$-$OAw$j3+;O$NI8<1$r>C$9!#(B |
| 1050 |
(skk-save-point |
| 1051 |
(goto-char skk-nicola-okuri-flag) |
| 1052 |
(when (eq ?* (following-char)) |
| 1053 |
(delete-char 1)))) |
| 1054 |
;; |
| 1055 |
(setq skk-nicola-okuri-flag nil)) |
| 1056 |
|
| 1057 |
(defadvice skk-previous-candidate (before skk-nicola-update-flag activate) |
| 1058 |
"$BAw$jBT$A>uBV$r4IM}$9$k!#(B" |
| 1059 |
(when (or (and (markerp skk-nicola-okuri-flag) |
| 1060 |
(<= (point) |
| 1061 |
(marker-position |
| 1062 |
skk-nicola-okuri-flag))) |
| 1063 |
(not (eq skk-henkan-mode 'on))) |
| 1064 |
(setq skk-nicola-okuri-flag nil))) |
| 1065 |
|
| 1066 |
(defadvice skk-insert (around skk-nicola-workaround activate) |
| 1067 |
;; |
| 1068 |
(let* ((list (symbol-value |
| 1069 |
(intern (format "skk-%s-plain-rule-list" |
| 1070 |
skk-kanagaki-keyboard-type)))) |
| 1071 |
(cell1 (rassoc '("$B!"(B") list)) |
| 1072 |
(cell2 (rassoc '("$B!#(B") list)) |
| 1073 |
marker) |
| 1074 |
(cond |
| 1075 |
((and (eq skk-kanagaki-state 'kana) |
| 1076 |
skk-j-mode |
| 1077 |
(or (eq last-command-event |
| 1078 |
(car cell1)) |
| 1079 |
(eq last-command-event |
| 1080 |
(car cell2))) |
| 1081 |
skk-henkan-mode) |
| 1082 |
;; $B$J$<$+$3$1$k!#860x2rL@Cf!#(B |
| 1083 |
(cond |
| 1084 |
((not (eq skk-henkan-mode 'active)) |
| 1085 |
(setq marker skk-henkan-start-point) |
| 1086 |
(skk-kakutei) |
| 1087 |
ad-do-it |
| 1088 |
(unless (or (string= (char-to-string (char-before)) |
| 1089 |
(cadr cell1)) |
| 1090 |
(string= (char-to-string (char-before)) |
| 1091 |
(cadr cell2))) |
| 1092 |
(skk-save-point |
| 1093 |
(goto-char marker) |
| 1094 |
(skk-set-henkan-point-subr)))) |
| 1095 |
(t |
| 1096 |
(skk-kakutei) |
| 1097 |
ad-do-it))) |
| 1098 |
(t |
| 1099 |
ad-do-it)))) |
| 1100 |
|
| 1101 |
(defadvice skk-isearch-setup-keymap (before skk-nicola-workaround activate) |
| 1102 |
"$B?F;X%-!<$G%5!<%A$,=*N;$7$F$7$^$o$J$$$h$&$K$9$k!#(B" |
| 1103 |
(let ((keys (append skk-nicola-lshift-keys |
| 1104 |
skk-nicola-rshift-keys))) |
| 1105 |
(while keys |
| 1106 |
(define-key (ad-get-arg 0) |
| 1107 |
(car keys) |
| 1108 |
'skk-isearch-wrapper) |
| 1109 |
(setq keys (cdr keys))))) |
| 1110 |
|
| 1111 |
(defadvice isearch-char-to-string (around skk-nicola-workaround activate) |
| 1112 |
"$B%(%i!<$,=P$k$H8!:w$,CfCG$7$F;H$$?I$$$N$G!"L[$i$;$k!#(B" |
| 1113 |
(cond ((and skk-use-kana-keyboard |
| 1114 |
(featurep 'skk-isearch) |
| 1115 |
(with-current-buffer |
| 1116 |
(get-buffer-create |
| 1117 |
skk-isearch-working-buffer) |
| 1118 |
skk-mode)) |
| 1119 |
(ignore-errors |
| 1120 |
ad-do-it)) |
| 1121 |
(t |
| 1122 |
ad-do-it))) |
| 1123 |
|
| 1124 |
(put 'skk-nicola-insert 'isearch-command t) |
| 1125 |
(put 'skk-nicola-self-insert-lshift 'isearch-command t) |
| 1126 |
(put 'skk-nicola-self-insert-rshift 'isearch-command t) |
| 1127 |
|
| 1128 |
(provide 'skk-nicola) |
| 1129 |
|
| 1130 |
;; Local Variables: |
| 1131 |
;; indent-tabs-mode: nil |
| 1132 |
;; End: |
| 1133 |
|
| 1134 |
;;; skk-nicola.el ends here |