| 1 |
;;; skk-kanagaki-util.el --- SKK $B$N2>L>F~NO%5%]!<%H$N$?$a$NF;6qH"(B -*- coding: iso-2022-jp -*- |
| 2 |
|
| 3 |
;; Copyright (C) 2000, 2001, 2002, 2003, 2004 |
| 4 |
;; Tetsuo Tsukamoto <[email protected]> |
| 5 |
|
| 6 |
;; Author: Tetsuo Tsukamoto <[email protected]> |
| 7 |
;; Keywords: hardware, japanese, mule, input method |
| 8 |
|
| 9 |
;; This file is part of Daredevil SKK. |
| 10 |
|
| 11 |
;; This program is free software: you can redistribute it and/or |
| 12 |
;; modify it under the terms of the GNU General Public License as |
| 13 |
;; published by the Free Software Foundation, either version 3 of |
| 14 |
;; the License, or (at your option) any later version. |
| 15 |
|
| 16 |
;; This program is distributed in the hope that it will be |
| 17 |
;; useful, but WITHOUT ANY WARRANTY; without even the implied |
| 18 |
;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 19 |
;; PURPOSE. See the GNU General Public License for more details. |
| 20 |
|
| 21 |
;; You should have received a copy of the GNU General Public License |
| 22 |
;; along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 23 |
|
| 24 |
;;; Commentary: |
| 25 |
|
| 26 |
;; macro$B!"(Binline function $B$O$3$3$KCV$-$^$9!#I,MW$J>l9g$O3F%b%8%e!<%k$NCf$+$i(B |
| 27 |
;; $B$3$N%W%m%0%i%`$r%m!<%I$7$^$9!#(B |
| 28 |
|
| 29 |
;;; Code: |
| 30 |
|
| 31 |
(eval-when-compile |
| 32 |
(require 'cl-lib) |
| 33 |
(require 'skk-vars) |
| 34 |
(require 'skk-macs)) |
| 35 |
|
| 36 |
(eval-when-compile |
| 37 |
(defvar skk-dcomp-start-point) |
| 38 |
(defvar skk-dcomp-end-point) |
| 39 |
(defvar skk-isearch-current-buffer) |
| 40 |
(defvar skk-nicola-okuri-flag) |
| 41 |
(defvar skk-nicola-hiragana-mode-string) |
| 42 |
(defvar skk-nicola-katakana-mode-string) |
| 43 |
(defvar skk-nicola-hiragana-rom-string) |
| 44 |
(defvar skk-nicola-katakana-rom-string)) |
| 45 |
|
| 46 |
;; Variables. |
| 47 |
|
| 48 |
(defconst skk-kanagaki-dakuten-alist |
| 49 |
'(("$B$+(B" "$B$,(B") ("$B$-(B" "$B$.(B") ("$B$/(B" "$B$0(B") ("$B$1(B" "$B$2(B") ("$B$3(B" "$B$4(B") |
| 50 |
("$B$5(B" "$B$6(B") ("$B$7(B" "$B$8(B") ("$B$9(B" "$B$:(B") ("$B$;(B" "$B$<(B") ("$B$=(B" "$B$>(B") |
| 51 |
("$B$?(B" "$B$@(B") ("$B$A(B" "$B$B(B") ("$B$D(B" "$B$E(B") ("$B$F(B" "$B$G(B") ("$B$H(B" "$B$I(B") |
| 52 |
("$B$O(B" "$B$P(B" "$B$Q(B") ("$B$R(B" "$B$S(B" "$B$T(B") ("$B$U(B" "$B$V(B" "$B$W(B") ("$B$X(B" "$B$Y(B" "$B$Z(B") |
| 53 |
("$B$[(B" "$B$\(B" "$B$](B") |
| 54 |
("$B%&(B" "$B%t(B") |
| 55 |
("$B%+(B" "$B%,(B") ("$B%-(B" "$B%.(B") ("$B%/(B" "$B%0(B") ("$B%1(B" "$B%2(B") ("$B%3(B" "$B%4(B") |
| 56 |
("$B%5(B" "$B%6(B") ("$B%7(B" "$B%8(B") ("$B%9(B" "$B%:(B") ("$B%;(B" "$B%<(B") ("$B%=(B" "$B%>(B") |
| 57 |
("$B%?(B" "$B%@(B") ("$B%A(B" "$B%B(B") ("$B%D(B" "$B%E(B") ("$B%F(B" "$B%G(B") ("$B%H(B" "$B%I(B") |
| 58 |
("$B%O(B" "$B%P(B" "$B%Q(B") ("$B%R(B" "$B%S(B" "$B%T(B") ("$B%U(B" "$B%V(B" "$B%W(B") ("$B%X(B" "$B%Y(B" "$B%Z(B") |
| 59 |
("$B%[(B" "$B%\(B" "$B%](B")) |
| 60 |
"$BByE@$HH>ByE@$rF~NO$9$k$?$a$N%k!<%k!#(B") |
| 61 |
|
| 62 |
;;;###autoload |
| 63 |
(defmacro skk-kanagaki-help-1 (bufname title list) |
| 64 |
`(let ((buf (get-buffer-create ,bufname))) |
| 65 |
(with-current-buffer buf |
| 66 |
(setq buffer-read-only nil) |
| 67 |
(erase-buffer) |
| 68 |
(insert |
| 69 |
(concat |
| 70 |
(format "%s\n\n" ,title) |
| 71 |
(mapconcat |
| 72 |
#'(lambda (cons) |
| 73 |
(cond |
| 74 |
((and (symbolp (car cons)) |
| 75 |
(symbol-value (car cons))) |
| 76 |
(format "%s $B!D(B %s\n" |
| 77 |
(key-description (symbol-value (car cons))) |
| 78 |
(cdr cons))) |
| 79 |
(t |
| 80 |
(format "%s $B!D(B %s\n" (car cons) (cdr cons))))) |
| 81 |
;; |
| 82 |
(delq nil ,list) ""))) |
| 83 |
;; |
| 84 |
(setq buffer-read-only t) |
| 85 |
(set-buffer-modified-p nil) |
| 86 |
(goto-char (point-min)) |
| 87 |
(help-mode)) |
| 88 |
(let ((standard-output buf)) |
| 89 |
(funcall #'help-print-return-message)) |
| 90 |
(display-buffer buf))) |
| 91 |
|
| 92 |
;;;###autoload |
| 93 |
(defun skk-nicola-visit-nicola-website () |
| 94 |
(interactive) |
| 95 |
(let ((func (cond |
| 96 |
((fboundp 'browse-url) |
| 97 |
'browse-url) |
| 98 |
(t |
| 99 |
'browse-url-netscape)))) |
| 100 |
(funcall func "http://nicola.sunicom.co.jp/"))) |
| 101 |
|
| 102 |
;;;###autoload |
| 103 |
(defun skk-kanagaki-toggle-rom-kana (&optional arg) |
| 104 |
"$B%m!<%^;zF~NO(B $B"N(B $B2>L>F~NO(B $B$r@Z$jBX$($k!#(B" |
| 105 |
(interactive) |
| 106 |
;; |
| 107 |
(when (featurep 'skk-nicola) |
| 108 |
(setq skk-nicola-okuri-flag nil)) |
| 109 |
;; |
| 110 |
(setq skk-kanagaki-state |
| 111 |
(if (memq arg '(kana rom)) |
| 112 |
arg |
| 113 |
(cl-case skk-kanagaki-state |
| 114 |
(kana 'rom) |
| 115 |
(rom 'kana) |
| 116 |
;; $B$H$j$"$($:!#(B |
| 117 |
(t 'kana)))) |
| 118 |
(skk-kanagaki-adjust-rule-tree) |
| 119 |
;; |
| 120 |
(when (featurep 'skk-nicola) |
| 121 |
;; $B%b!<%I9T$NI=<($ND4@a!#(B |
| 122 |
(cl-case skk-kanagaki-state |
| 123 |
(kana |
| 124 |
(setq skk-hiragana-mode-string skk-nicola-hiragana-mode-string |
| 125 |
skk-katakana-mode-string skk-nicola-katakana-mode-string)) |
| 126 |
(rom |
| 127 |
(setq skk-hiragana-mode-string skk-nicola-hiragana-rom-string |
| 128 |
skk-katakana-mode-string skk-nicola-katakana-rom-string))) |
| 129 |
;; |
| 130 |
(skk-modify-indicator-alist 'katakana skk-katakana-mode-string) |
| 131 |
(skk-modify-indicator-alist 'hiragana skk-hiragana-mode-string) |
| 132 |
;; |
| 133 |
(skk-loop-for-buffers (buffer-list) |
| 134 |
(when (and skk-j-mode |
| 135 |
(listp mode-line-format)) |
| 136 |
(skk-update-modeline (if skk-katakana |
| 137 |
'katakana |
| 138 |
'hiragana)))))) |
| 139 |
|
| 140 |
;;;###autoload |
| 141 |
(defun skk-kanagaki-dakuten (&optional arg handakuten) |
| 142 |
"$BD>A0$NJ8;z$r8+$F2DG=$J$iByE@$rIU2C$7!"$5$b$J$1$l$P(B \"$B!+(B\" $B$rF~NO$9$k!#(B" |
| 143 |
(interactive "*p") |
| 144 |
(let ((list skk-kanagaki-dakuten-alist) |
| 145 |
(pt1 (point)) |
| 146 |
(henkan-on (and skk-isearch-switch |
| 147 |
(with-current-buffer |
| 148 |
(get-buffer-create skk-isearch-working-buffer) |
| 149 |
(eq skk-henkan-mode 'on)))) |
| 150 |
char1 char2 str) |
| 151 |
(ignore-errors |
| 152 |
(setq char1 (cond |
| 153 |
((and skk-isearch-switch |
| 154 |
(not (skk-in-minibuffer-p))) |
| 155 |
(if henkan-on |
| 156 |
(with-current-buffer skk-isearch-working-buffer |
| 157 |
(skk-save-point |
| 158 |
(backward-char 1) |
| 159 |
(buffer-substring-no-properties |
| 160 |
(point) |
| 161 |
pt1))) |
| 162 |
(substring isearch-string -1))) |
| 163 |
(t |
| 164 |
(skk-save-point |
| 165 |
(backward-char 1) |
| 166 |
(buffer-substring-no-properties |
| 167 |
(point) |
| 168 |
pt1)))))) |
| 169 |
(cond |
| 170 |
((setq char2 (nth (if handakuten 2 1) (assoc char1 list))) |
| 171 |
(cond |
| 172 |
((and skk-isearch-switch |
| 173 |
(not (skk-in-minibuffer-p))) |
| 174 |
(if henkan-on |
| 175 |
(with-current-buffer skk-isearch-working-buffer |
| 176 |
(delete-char -1) |
| 177 |
(skk-insert-str char2)) |
| 178 |
(setq str isearch-string) |
| 179 |
(while (string= str (if (vectorp (car isearch-cmds)) |
| 180 |
(aref (car isearch-cmds) 0) |
| 181 |
(caar isearch-cmds))) |
| 182 |
(with-current-buffer skk-isearch-current-buffer |
| 183 |
(skk-isearch-delete-char arg))) |
| 184 |
(setq isearch-string (concat (if (vectorp (car isearch-cmds)) |
| 185 |
(aref (car isearch-cmds) 0) |
| 186 |
(caar isearch-cmds)) |
| 187 |
char2) |
| 188 |
isearch-message (concat |
| 189 |
(skk-isearch-mode-string) |
| 190 |
(mapconcat |
| 191 |
#'isearch-text-char-description |
| 192 |
isearch-string ""))) |
| 193 |
(put 'isearch-barrier 'skk-kanagaki t) |
| 194 |
(skk-unread-event (aref (where-is-internal |
| 195 |
(if isearch-forward 'isearch-repeat-forward |
| 196 |
'isearch-repeat-backward) |
| 197 |
isearch-mode-map t) |
| 198 |
0)))) |
| 199 |
(t |
| 200 |
(delete-char -1) |
| 201 |
(skk-insert-str char2)))) |
| 202 |
(t |
| 203 |
(skk-insert-str (if handakuten |
| 204 |
"$B!,(B" |
| 205 |
"$B!+(B")))))) |
| 206 |
|
| 207 |
(defadvice isearch-repeat (around skk-kanagaki-workaround activate) |
| 208 |
(cond ((get 'isearch-barrier 'skk-kanagaki) |
| 209 |
(goto-char isearch-barrier) |
| 210 |
ad-do-it |
| 211 |
(put 'isearch-barrier 'skk-kanagaki nil)) |
| 212 |
(t |
| 213 |
ad-do-it))) |
| 214 |
|
| 215 |
;;;###autoload |
| 216 |
(defun skk-kanagaki-handakuten (&optional arg) |
| 217 |
"$BD>A0$NJ8;z$r8+$F2DG=$J$iH>ByE@$rIU2C$7!"$5$b$J$1$l$P(B \"$B!,(B\" $B$rF~NO$9$k!#(B" |
| 218 |
(interactive "*p") |
| 219 |
(skk-kanagaki-dakuten arg t)) |
| 220 |
|
| 221 |
;;;###autoload |
| 222 |
(defun skk-kanagaki-bs (arg) |
| 223 |
;; OASYS $B$K$*$1$k(B BS $B%-!<$N5!G=$NBe$o$j!#$I$N$h$&$J5sF0$r$5$;$k$Y$-$+$^$@7h$^(B |
| 224 |
;; $B$C$F$$$J$$!#8=:_$N$H$3$m(B |
| 225 |
;; |
| 226 |
;; o $B"'%b!<%I$G$O(B `skk-kanagaki-esc' $B$HF1$85sF0(B |
| 227 |
;; o $B"&%b!<%I$G$O(B `skk-delete-backward-char' $B$HF1$85sF0(B |
| 228 |
;; o $B"#%b!<%I$G$O(B `delete-backward-char' $B$HF1$85sF0(B |
| 229 |
;; |
| 230 |
;; $B$H$$$&$U$&$K9M$($F$$$k!#(B |
| 231 |
(interactive "*p") |
| 232 |
;; |
| 233 |
(cond |
| 234 |
((eq skk-henkan-mode 'active) |
| 235 |
(call-interactively 'keyboard-quit)) |
| 236 |
((and (eq skk-henkan-mode 'on) |
| 237 |
(= (point) (marker-position |
| 238 |
skk-henkan-start-point))) |
| 239 |
(skk-kakutei arg)) |
| 240 |
((eq skk-henkan-mode 'on) |
| 241 |
(forward-char -1) |
| 242 |
(delete-char 1)) |
| 243 |
((and skk-isearch-switch |
| 244 |
(buffer-live-p skk-isearch-current-buffer)) |
| 245 |
(with-current-buffer skk-isearch-current-buffer |
| 246 |
(skk-isearch-delete-char arg))) |
| 247 |
(t |
| 248 |
(delete-char (- 0 arg)))) |
| 249 |
;; |
| 250 |
(when skk-dcomp-activate |
| 251 |
(skk-dcomp-after-delete-backward-char))) |
| 252 |
|
| 253 |
;;;###autoload |
| 254 |
(put 'skk-kanagaki-bs 'delete-selection 'supersede) |
| 255 |
|
| 256 |
;;;###autoload |
| 257 |
(defun skk-kanagaki-esc (&optional arg) |
| 258 |
;; OASYS $B$K$*$1$k<h$j>C$75!G=$NBe$o$j!#(B $B$H$j$"$($:(B keyboard-quit $B$N>l9g$HF1MM(B |
| 259 |
;; $B$NF0:n$r$9$k$h$&$K$K$7$F$*$/!#(BOAK $B&BHG$@$H(B |
| 260 |
;; |
| 261 |
;; o 1 $B2sL\$N<h$j>C$7$G!"JQ49A0$N>uBV$KLa$7$?>e$GJQ493+;OE@$K%]%$%s%H$r0\F0(B |
| 262 |
;; o 2 $B2sL\$N<h$j>C$7$GJQ49BP>]$NJ8;zNsA4BN$r>C5n(B |
| 263 |
;; |
| 264 |
;; $B$9$k$h$&$K$J$C$F$$$k$,!"(BSKK $B$K$*$1$kJQ49BP>]$NJ8;zNs$O(B $B"&(B $B$H%]%$%s%H$N4V$N(B |
| 265 |
;; $BJ8;zNs$G$"$j!"%]%$%s%H$r0\F0$9$k$HJQ49BP>]$,JQ$o$C$F$7$^$&!#$=$N$?$a!"%]%$(B |
| 266 |
;; $B%s%H$O0\F0$7$J$$$3$H$H$9$k!#(B |
| 267 |
(interactive "*P") |
| 268 |
(cond |
| 269 |
((skk-in-minibuffer-p) |
| 270 |
(call-interactively |
| 271 |
(if (fboundp 'minibuffer-keyboard-quit) |
| 272 |
'minibuffer-keyboard-quit |
| 273 |
'abort-recursive-edit))) |
| 274 |
(skk-henkan-mode |
| 275 |
(call-interactively 'keyboard-quit)) |
| 276 |
(t |
| 277 |
nil))) |
| 278 |
|
| 279 |
(provide 'skk-kanagaki-util) |
| 280 |
|
| 281 |
;; Local Variables: |
| 282 |
;; indent-tabs-mode: nil |
| 283 |
;; End: |
| 284 |
|
| 285 |
;;; skk-kanagaki-util.el ends here |