70
|
1 ;;; isearch-ext.el --- incremental search with front-end inputting method
|
|
2
|
|
3 ;; Author: SAKAI Kiyotaka <ksakai@mtl.t.u-tokyo.ac.jp>
|
|
4 ;; Keywords: search
|
|
5
|
|
6 ;; !Id: isearch-ext.el,v 1.41 1994/12/16 15:33:34 ksakai Exp !
|
|
7
|
|
8 ;; This file is part of XEmacs.
|
|
9
|
|
10 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
11 ;; under the terms of the GNU General Public License as published by
|
|
12 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
13 ;; any later version.
|
|
14
|
|
15 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
18 ;; General Public License for more details.
|
|
19
|
|
20 ;; You should have received a copy of the GNU General Public License
|
|
21 ;; along with XEmacs; see the file COPYING. If not, write to the
|
|
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
23 ;; Boston, MA 02111-1307, USA.
|
|
24
|
|
25 ;;; Commentary:
|
|
26
|
|
27 ;; This program is extension of isearch.el to support multi-lingal
|
|
28 ;; incremental search with front-end input method.
|
|
29 ;;
|
|
30 ;; If you want to use this program, simply put C-\ or C-o or C-[ when
|
|
31 ;; doing incremental search, and you can input search words with
|
|
32 ;; inputting method.
|
|
33 ;;
|
|
34 ;; For backward compatibility with mule-1.x, you can also use C-k, but
|
|
35 ;; isearch-edit-string may be more suitable for this use. If you
|
|
36 ;; think so, put the following code in your .emacs.
|
|
37 ;;
|
|
38 ;; (define-key isearch-mode-map "\C-k" 'isearch-edit-string)
|
|
39 ;;
|
|
40
|
|
41 ;; Following people contributed modifications to isearch-ext.el:
|
|
42 ;; Kenichi Handa <handa@etlken.etl.go.jp>
|
|
43 ;; YAMAMOTO Mitsuharu <mituharu@is.s.u-tokyo.ac.jp>
|
|
44 ;; A. Sasaki <beckun@cis.canon.co.jp>
|
|
45 ;; Atsuo Ohki <ohki@gssm.otsuka.tsukuba.ac.jp>
|
|
46
|
|
47 ;;; Code:
|
|
48
|
|
49 ;; #### This is far from working in XEmacs.
|
|
50
|
|
51 (eval-when-compile (require 'quail))
|
140
|
52 (eval-when-compile (require 'egg))
|
70
|
53
|
|
54
|
|
55 ;;;###autoload
|
|
56 (defvar search-string-char-prompt "*Enter string... ")
|
|
57
|
|
58 (defvar isearch-fep-prompt "" "Prompt for isearch-fep mode.")
|
|
59 (defvar isearch-fep-mode nil "If t, isearch-fep-mode is invoked.")
|
|
60
|
|
61 (defconst isearch-fep-table
|
|
62 '((isearch-fep-string isearch-fep-prompt-string isearch-fep-read-string)
|
|
63 (isearch-fep-egg isearch-fep-prompt-egg isearch-fep-read-egg)
|
|
64 (isearch-fep-canna isearch-fep-prompt-canna isearch-fep-read-canna)
|
|
65 (isearch-fep-quail isearch-fep-prompt-quail isearch-fep-read-quail)))
|
|
66
|
|
67 ;; the followings are defined in isearch.el
|
138
|
68 (define-key isearch-mode-map "\C-k" 'isearch-fep-string)
|
|
69 (define-key isearch-mode-map "\C-\\" 'isearch-fep-egg)
|
|
70 (define-key isearch-mode-map "\M-k" 'isearch-fep-egg)
|
|
71 (define-key isearch-mode-map "\C-o" 'isearch-fep-canna)
|
140
|
72 ;(define-key isearch-mode-map "\C-\]" 'isearch-fep-quail)
|
|
73
|
|
74 (put 'isearch-fep-string 'isearch-command t)
|
|
75 (put 'isearch-fep-egg 'isearch-command t)
|
|
76 (put 'isearch-fep-canna 'isearch-command t)
|
|
77 (put 'isearch-fep-prompt-string 'isearch-command t)
|
|
78 (put 'isearch-fep-prompt-egg 'isearch-command t)
|
|
79 (put 'isearch-fep-prompt-canna 'isearch-comnand t)
|
|
80 (put 'isearch-fep-read-string 'isearch-command t)
|
|
81 (put 'isearch-fep-read-egg 'isearch-command t)
|
|
82 (put 'isearch-fep-read-canna 'isearch-command t)
|
|
83 ;(put 'isearch-fep-quail 'isearch-command t)
|
70
|
84
|
|
85 (defun isearch-fep-mode ()
|
|
86 (let ((command this-command)
|
|
87 (isearch-fep-mode t)
|
|
88 table str)
|
|
89 (while isearch-fep-mode
|
|
90 (setq table (assq command isearch-fep-table))
|
|
91 (setq isearch-fep-prompt (funcall (car (cdr table))))
|
|
92 (message "%s%s" isearch-fep-prompt (isearch-message))
|
|
93 (if (eq command 'isearch-fep-string) ;; \C-k
|
|
94 (progn
|
|
95 (setq str (funcall (nth 2 table)))
|
|
96 (setq isearch-fep-mode nil)
|
|
97 (isearch-process-search-string str str))
|
|
98 (let* ((keys (read-key-sequence nil))
|
|
99 (current-command (key-binding keys t)))
|
|
100 (setq isearch-fep-mode (not (eq command current-command)))
|
|
101 (if isearch-fep-mode
|
|
102 (if (assq current-command isearch-fep-table)
|
|
103 (setq command current-command)
|
|
104 (cond ((eq current-command 'isearch-printing-char)
|
|
105 (setq str (funcall (nth 2 table) keys))
|
|
106 (isearch-process-search-string str str))
|
|
107 ((or (eq current-command 'isearch-other-control-char)
|
|
108 (eq current-command 'isearch-other-meta-char))
|
|
109 (call-interactively current-command)
|
|
110 (setq isearch-fep-mode nil))
|
|
111 ((eq current-command 'isearch-exit)
|
|
112 (setq isearch-fep-mode nil)
|
|
113 (message "%s%s"
|
|
114 (isearch-message-prefix) isearch-message))
|
|
115 (t
|
140
|
116 (ding)
|
70
|
117 (call-interactively current-command))))
|
|
118 (setq isearch-fep-prompt nil)
|
|
119 (message "%s%s" (isearch-message-prefix) isearch-message)))))))
|
|
120
|
|
121 ;;
|
|
122 ;; Read string from minibuffer for incremental search.
|
|
123 ;;
|
|
124
|
|
125 ;;;###autoload
|
|
126 (defun isearch-fep-string ()
|
|
127 "Read string from minibuffer for incremental search."
|
|
128 (interactive)
|
|
129 (isearch-fep-mode))
|
|
130
|
|
131 (defun isearch-fep-prompt-string ()
|
|
132 search-string-char-prompt)
|
|
133
|
|
134 (defun exit-minibuffer-and-isearch-backward ()
|
|
135 (interactive)
|
|
136 (setq unread-command-events
|
|
137 (nconc unread-command-events
|
|
138 (list (character-to-event ?\r) (character-to-event ?\r))))
|
|
139 (exit-minibuffer))
|
|
140
|
|
141 (defun isearch-fep-read-string ()
|
|
142 (save-excursion
|
|
143 (set-buffer (window-buffer (minibuffer-window)))
|
|
144 (let* ((overriding-local-map nil)
|
|
145 (minibuffer-local-map (cons 'keymap minibuffer-local-map)))
|
|
146 ;; Some program overwrites "\C-m"'s default binding.
|
|
147 (define-key minibuffer-local-map "\C-m" 'exit-minibuffer)
|
|
148 (define-key minibuffer-local-map "\C-s" 'exit-minibuffer)
|
|
149 (define-key minibuffer-local-map "\C-r"
|
|
150 'exit-minibuffer-and-isearch-backward)
|
|
151 (condition-case condition
|
|
152 (read-from-minibuffer (concat isearch-fep-prompt (isearch-message)))
|
|
153 (quit
|
|
154 (isearch-abort))))))
|
|
155
|
|
156
|
|
157 ;;
|
|
158 ;; For EGG
|
|
159 ;;
|
|
160
|
|
161 ;;;###autoload
|
|
162 (defun isearch-fep-egg ()
|
|
163 "Read string for incremental search by using egg."
|
|
164 (interactive)
|
|
165 (isearch-fep-mode))
|
|
166
|
|
167 (defun isearch-fep-prompt-egg ()
|
|
168 (if (featurep 'egg)
|
140
|
169 (format "[%s]->" (map-indicator its:*current-map*))
|
70
|
170 (setq isearch-fep-mode nil)
|
|
171 (message "No EGG!! ")
|
|
172 (sit-for 1)
|
|
173 ""))
|
|
174
|
|
175 (defun isearch-exit-minibuffer-egg (from to)
|
|
176 (exit-minibuffer))
|
|
177
|
|
178 (defvar isearch-fep-egg-its-map nil)
|
|
179 (defvar isearch-fep-egg-server-type nil)
|
|
180
|
|
181 (defun isearch-minibuffer-setup-egg ()
|
|
182 (setq its:*current-map* isearch-fep-egg-its-map)
|
|
183 (setq wnn-server-type isearch-fep-egg-server-type))
|
|
184
|
|
185 (defun isearch-fep-read-egg (first-str)
|
|
186 (if (and (featurep 'egg) (= (minibuffer-depth) 0))
|
|
187 (let ((isearch-fep-egg-its-map its:*current-map*)
|
|
188 (isearch-fep-egg-server-type wnn-server-type)
|
|
189 (minibuffer-setup-hook 'isearch-minibuffer-setup-egg))
|
|
190 (save-excursion
|
|
191 (set-buffer (window-buffer (minibuffer-window)))
|
|
192 (let ((display-minibuffer-mode-in-minibuffer t)
|
|
193 (egg:*input-mode* t)
|
|
194 (egg:*mode-on* t)
|
|
195 (self-insert-after-hook 'isearch-exit-minibuffer-egg))
|
140
|
196 (setq unread-command-events (mil-listify-key-sequence first-str))
|
70
|
197 (unwind-protect
|
|
198 (read-from-minibuffer (isearch-message))
|
|
199 (setq egg:henkan-mode-in-use nil)
|
140
|
200 ;;(setq disable-undo nil)
|
|
201 ))))
|
70
|
202 ""))
|
|
203
|
|
204
|
|
205 ;;
|
|
206 ;; For Canna
|
|
207 ;;
|
|
208
|
|
209 ;;;###autoload
|
|
210 (defun isearch-fep-canna ()
|
|
211 "Read string for incremental search by using canna."
|
|
212 (interactive)
|
|
213 (isearch-fep-mode))
|
|
214
|
|
215 (defun isearch-fep-prompt-canna ()
|
|
216 (if (and (featurep 'canna) canna:*initialized*)
|
|
217 (format "%s" canna:*kanji-mode-string*)
|
|
218 (setq isearch-fep-mode nil)
|
|
219 (message "No Canna!! ")
|
|
220 (sit-for 1)
|
|
221 ""))
|
|
222
|
|
223 (defun isearch-exit-minibuffer-canna (from to)
|
|
224 (exit-minibuffer))
|
|
225
|
|
226 (defun isearch-fep-read-canna (first-str)
|
|
227 (if (and (featurep 'canna) (= (minibuffer-depth) 0))
|
|
228 (save-excursion
|
|
229 (set-buffer (window-buffer (minibuffer-window)))
|
|
230 (let ((display-minibuffer-mode-in-minibuffer t)
|
|
231 (canna:*japanese-mode* t)
|
|
232 (canna:*japanese-mode-in-minibuffer* t)
|
|
233 (canna:*fence-mode* nil)
|
|
234 (self-insert-after-hook 'isearch-exit-minibuffer-canna))
|
140
|
235 (setq unread-command-events (mil-listify-key-sequence first-str))
|
70
|
236 (unwind-protect
|
|
237 (read-from-minibuffer (isearch-message))
|
|
238 ;XEmacs change:
|
|
239 (buffer-enable-undo (current-buffer)))))
|
|
240 ""))
|
|
241
|
|
242
|
|
243 ;;
|
|
244 ;; For QUAIL
|
|
245 ;;
|
|
246
|
|
247 ;;;###autoload
|
|
248 (defun isearch-fep-quail ()
|
|
249 "Read string for incremental search by using quail."
|
|
250 (interactive)
|
|
251 (require 'quail)
|
|
252 (isearch-fep-mode))
|
|
253
|
|
254 (defun isearch-fep-prompt-quail ()
|
|
255 "[QUAIL]")
|
|
256
|
|
257 (defun isearch-exit-minibuffer-quail ()
|
|
258 (if (or quail-current-key quail-current-str)
|
|
259 nil
|
|
260 (exit-minibuffer)))
|
|
261
|
|
262 (defun isearch-fep-read-quail (first-str)
|
|
263 (let ((quail-self-insert-after-hook 'isearch-exit-minibuffer-quail))
|
|
264 (setq unread-command-events
|
|
265 (nconc unread-command-events
|
|
266 (cons (character-to-event ?\\)
|
140
|
267 (mil-listify-key-sequence first-str)))
|
70
|
268 (unwind-protect
|
|
269 (read-from-minibuffer
|
|
270 (concat isearch-fep-prompt (isearch-message)))
|
|
271 ;; XEmacs change:
|
|
272 (buffer-enable-undo (current-buffer))
|
|
273 ))))
|
|
274
|
|
275
|
|
276 (provide 'isearch-ext)
|
|
277 ;;; isearch-ext.el ends here
|
|
278
|