Remove non-free old and crusty clearcase pkg
[packages] / mule-packages / skk / skk-comp.el
1 ;;; skk-comp.el --- \e$BJd40$N$?$a$N%W%m%0%i%`\e(B
2 ;; Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
3 ;;               1999
4 ;; Masahiko Sato <masahiko@kuis.kyoto-u.ac.jp>
5
6 ;; Author: Masahiko Sato <masahiko@kuis.kyoto-u.ac.jp>
7 ;; Maintainer: Mikio Nakajima <minakaji@osaka.email.ne.jp>
8 ;; Version: $Id: skk-comp.el,v 1.2 2000-07-10 04:34:00 yoshiki Exp $
9 ;; Keywords: japanese
10 ;; Last Modified: $Date: 2000-07-10 04:34:00 $
11
12 ;; This file is part of SKK.
13
14 ;; SKK is free software; you can redistribute it and/or modify
15 ;; it under the terms of the GNU General Public License as published by
16 ;; the Free Software Foundation; either versions 2, or (at your option)
17 ;; any later version.
18
19 ;; SKK is distributed in the hope that it will be useful
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 ;; GNU General Public License for more details.
23
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with SKK, see the file COPYING.  If not, write to the Free
26 ;; Software Foundation Inc., 59 Temple Place - Suite 330, Boston,
27 ;; MA 02111-1307, USA.
28
29 ;;; Commentary:
30 ;; \e$B"&$5\e(B (TAB) -> \e$B"&$5$H$&\e(B (.) -> \e$B"&$5$$$H$&\e(B (,) -> \e$B"&$5$H$&\e(B(.) -> \e$B"&$5$$$H$&\e(B
31
32 ;;; Code:
33 (eval-when-compile (require 'skk))
34 (require 'skk-foreword)
35
36 ;;;###autoload
37 (defgroup skk-comp nil "SKK completion related customization."
38   :prefix "skk-"
39   :group 'skk )
40
41 ;;; -- user variables
42 (defcustom skk-dabbrev-like-completion nil
43   "*Non-nil \e$B$G$"$l$P!"8+=P$78l$NJd40$K$*$$$F!":G8e$KJd40$5$l$?8l$K$D$$$F99$KJd40$,9T$o$l$k!#\e(B
44 \e$BNc$($P!"\e(B
45
46   \"\e$B$5\e(B\" (,) -> \"\e$B$5$H$&\e(B\" (,) -> \"\e$B$5$H$&$;$s$;$$\e(B\"
47
48 nil \e$B$G$"$l$P!"@hF,$NJ8;z$r6&DL$K$9$kJ8;zNs$K$D$$$FJd40$,9T$J$o$l$k!#\e(B
49 \e$BNc$($P!"\e(B
50
51   \"\e$B$5\e(B\" (,) -> \"\e$B$5$H$&\e(B\" (,) -> \"\e$B$5$$$H$&\e(B\" (,) -> \"\e$B$5$/$i\e(B\""
52   :type 'boolean
53   :group 'skk-comp )
54
55 (defcustom skk-completion-function 'skk-completion-original
56   "*skk-completion \e$B$G;HMQ$9$k4X?t!#\e(B
57 skk-comp.el \e$B0J30$NJd405!G=$rMxMQ$G$-$k$h$&$K4X?t$r\e(B funcall \e$B$9$k7A$K$7$F$*$/!#\e(B"
58   :type 'function
59   :group 'skk-comp )
60
61 (defcustom skk-previous-completion-function 'skk-previous-completion-original
62   "*skk-previous-completion \e$B$G;HMQ$9$k4X?t!#\e(B
63 skk-comp.el \e$B0J30$NJd405!G=$rMxMQ$G$-$k$h$&$K4X?t$r\e(B funcall \e$B$9$k7A$K$7$F$*$/!#\e(B"
64   :type 'function
65   :group 'skk-comp )
66
67 (defcustom skk-comp-load-hook nil
68   "*skk-comp.el \e$B$r%m!<%I$7$?8e$K%3!<%k$5$l$k%U%C%/!#\e(B"
69   :type 'hook
70   :group 'skk-comp )
71
72 ;;; -- internal variables
73 ;; ---- buffer local variables
74 ;; \e$B6uJ8;zNs$KBP$7$F\e(B skk-completion \e$B$r8F$V$3$H$b$"$j$&$k$N$G!"\e(B"" \e$B$r\e(B nil \e$B$G$OBe\e(B
75 ;; \e$BMQ$G$-$J$$!#\e(B
76 (skk-deflocalvar skk-completion-word ""
77   "\e$BJd40$9$Y$-8+=P$78l!#\e(B
78 skk-dabbrev-like-completion \e$B$,\e(B non-nil \e$B$N>l9g$O!">o$K:G8e$KJd40$7$?8+=P$78l$,\e(B
79 \e$BBeF~$5$l$k!#\e(B" )
80 ;; \e$B<-=qEPO?;~%_%K%P%C%U%!$GJd40$7$?>l9g!"85$N%P%C%U%!$KLa$C$?$H$-$K\e(B
81 ;; skk-completion-word \e$B$NCM$,GK2u$5$l$F$$$J$$J}$,%Y%?!<!#\e(B
82
83 (skk-deflocalvar skk-completion-stack nil
84   "\e$BJd40$7$?8l$rJ]B8$7$F$*$/%9%?%C%/!#\e(B" )
85
86 (skk-deflocalvar skk-completion-depth 0
87   "\e$BJd40$7$?8l$r\e(B skk-completion-stack \e$B$+$i<h$j=P$90LCV!#\e(B" )
88
89 ;;;###autoload
90 (defun skk-start-henkan-with-completion (arg)
91   "\e$B"&%b!<%I$GFI$_$NJd40$r9T$J$C$?8e!"JQ49$9$k!#\e(B
92 \e$B$=$l0J30$N%b!<%I$G$O%*%j%8%J%k$N%-!<%^%C%W$K3d$jIU$1$i$l$?%3%^%s%I$r%(%_%e%l!<\e(B
93 \e$B%H$9$k!#\e(B"
94   (interactive "*P")
95   (if (and skk-henkan-on (not skk-henkan-active))
96       (progn
97         (skk-completion (not (eq last-command 'skk-completion)))
98         (skk-start-henkan arg) )
99     (skk-emulate-original-map arg) ))
100
101 ;;;###autoload
102 (defun skk-completion (first)
103   ;; skk-try-completion \e$B$N%5%V%k!<%A%s!#\e(B
104   ;; skk-comp.el \e$B0J30$NJd405!G=$rMxMQ$G$-$k$h$&$K4X?t$r\e(B funcall \e$B$9$k7A$K$7$F$*$/!#\e(B
105   (funcall skk-completion-function first) )
106
107 (defun skk-completion-original (first)
108   ;; default \e$B$N\e(B skk-completion-function.
109   (let ((inhibit-quit t)
110         ;; skk-num \e$B$,\e(B require \e$B$5$l$F$J$$$H\e(B buffer-local \e$BCM$r2u$962$l$"$j!#\e(B
111         skk-num-list
112         completion-word c-word )
113     (skk-kana-cleanup 'force)
114     (and first (setq skk-completion-stack nil skk-completion-depth 0))
115     (and (or first skk-dabbrev-like-completion)
116          (setq skk-completion-word
117                (buffer-substring-no-properties skk-henkan-start-point (point)) ))
118     (and (string= skk-completion-word "")
119          (skk-error "\e$B6uJ8;z$+$iJd40$9$k$3$H$O$G$-$^$;$s!*\e(B"
120                     "Cannot complete an empty string!" ))
121     (if (> skk-completion-depth 0)
122         ;; (\e$B2a5n$KC5:w:Q$_$NFI$_$r%"%/%;%9Cf\e(B)
123         (setq skk-completion-depth (1- skk-completion-depth)
124               c-word (nth skk-completion-depth skk-completion-stack))
125       ;; (\e$B?75,$NFI$_$r<-=q%P%C%U%!$+$iC5:w\e(B)
126       ;; skk-completion-word \e$B$O%P%C%U%!%m!<%+%kCM$J$N$G!"<-=q%P%C%U%!$K0\$kA0$K\e(B
127       ;; \e$B0l;~JQ?t$K0\$7JQ$($F$*$/!#\e(B
128       (setq completion-word skk-completion-word)
129       (with-current-buffer (skk-get-jisyo-buffer skk-jisyo)
130         (if first (goto-char skk-okuri-nasi-min))
131         (save-match-data
132           ;; case-fold-search \e$B$O!"<-=q%P%C%U%!$G$O>o$K\e(B nil\e$B!#\e(B
133           (while
134               (and (not c-word)
135                    (search-forward
136                     (concat "\n"
137                             (if skk-use-numeric-conversion
138                                 (skk-num-compute-henkan-key completion-word)
139                               completion-word ))
140                     nil t ))
141             (if (eq (following-char) ?\040) ;SPC
142                 nil
143               (setq c-word (concat completion-word
144                                    (buffer-substring-no-properties
145                                     ;; \e$B8+=P$78l$K6uGr$O4^$^$l$J$$!#\e(B" /" \e$B$r%5!<\e(B
146                                     ;; \e$B%A$9$kI,MW$O$J$$!#\e(B
147                                     (point) (1- (search-forward " ")) )))))))
148       (and (not c-word) skk-abbrev-mode skk-use-look
149            (setq c-word (skk-look-completion)) )
150       ;; \e$B?75,$K8+$D$1$?$H$-$@$1\e(B cons \e$B$9$k!#\e(B
151       (setq skk-completion-stack (cons c-word skk-completion-stack)) )
152     ;; \e$B<-=q%P%C%U%!$N30!#\e(B
153     (if (not c-word)
154         (progn
155           (setq skk-completion-depth (1+ skk-completion-depth))
156           (if skk-japanese-message-and-error
157               (error "\"%s\" \e$B$GJd40$9$Y$-8+=P$78l$O\e(B%s\e$B$"$j$^$;$s\e(B"
158                      skk-completion-word (if first "" "\e$BB>$K\e(B") )
159             (error "No %scompletions for \"%s\""
160                    (if first "" "more ") skk-completion-word )) )
161       (delete-region skk-henkan-start-point (point))
162       (insert c-word) )))
163
164 ;;;###autoload
165 (defun skk-previous-completion ()
166   ;; skk-abbrev-comma, skk-insert-comma \e$B$N%5%V%k!<%A%s!#D>A0$KJd40$r9T$C$?8+\e(B
167   ;; \e$B=P$7$rA^F~$9$k!#\e(B
168   ;; skk-comp.el \e$B0J30$NJd405!G=$rMxMQ$G$-$k$h$&$K4X?t$r\e(B funcall \e$B$9$k7A$K$7$F$*$/!#\e(B
169   (funcall skk-previous-completion-function) )
170
171 (defun skk-previous-completion-original ()
172   ;; default \e$B$N\e(B skk-previous-completion-function.
173   (let ((inhibit-quit t)
174         (c-word 
175          (progn
176            (setq skk-completion-depth (1+ skk-completion-depth))
177            (nth skk-completion-depth skk-completion-stack) )))
178     (if c-word
179         (progn
180           (delete-region skk-henkan-start-point (point))
181           (insert c-word) )
182       (setq skk-completion-depth (1- skk-completion-depth))
183       (skk-error "\"%s\"\e$B$GJd40$9$Y$-8+=P$78l$OB>$K$"$j$^$;$s\e(B"
184                  "No more previous completions for \"%s\""
185                  skk-completion-word ))))
186
187 (run-hooks 'skk-comp-load-hook)
188
189 (provide 'skk-comp)
190 ;;; Local Variables:
191 ;;; End:
192 ;;; skk-comp.el ends here