comparison lisp/mule/isearch-mule.el @ 70:131b0175ea99 r20-0b30

Import from CVS: tag r20-0b30
author cvs
date Mon, 13 Aug 2007 09:02:59 +0200
parents
children 6608ceec7cf8
comparison
equal deleted inserted replaced
69:804d1389bcd6 70:131b0175ea99
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))
52
53
54 ;;;###autoload
55 (defvar search-string-char-prompt "*Enter string... ")
56
57 (defvar isearch-fep-prompt "" "Prompt for isearch-fep mode.")
58 (defvar isearch-fep-mode nil "If t, isearch-fep-mode is invoked.")
59
60 (defconst isearch-fep-table
61 '((isearch-fep-string isearch-fep-prompt-string isearch-fep-read-string)
62 (isearch-fep-egg isearch-fep-prompt-egg isearch-fep-read-egg)
63 (isearch-fep-canna isearch-fep-prompt-canna isearch-fep-read-canna)
64 (isearch-fep-quail isearch-fep-prompt-quail isearch-fep-read-quail)))
65
66 ;; the followings are defined in isearch.el
67 ;; (define-key isearch-mode-map "\C-k" 'isearch-fep-string)
68 ;; (define-key isearch-mode-map "\C-\\" 'isearch-fep-egg)
69 ;; (define-key isearch-mode-map "\M-k" 'isearch-fep-egg)
70 ;; (define-key isearch-mode-map "\C-o" 'isearch-fep-canna)
71 ;; (define-key isearch-mode-map "\C-\]" 'isearch-fep-quail)
72
73 (defun isearch-fep-mode ()
74 (let ((command this-command)
75 (isearch-fep-mode t)
76 table str)
77 (while isearch-fep-mode
78 (setq table (assq command isearch-fep-table))
79 (setq isearch-fep-prompt (funcall (car (cdr table))))
80 (message "%s%s" isearch-fep-prompt (isearch-message))
81 (if (eq command 'isearch-fep-string) ;; \C-k
82 (progn
83 (setq str (funcall (nth 2 table)))
84 (setq isearch-fep-mode nil)
85 (isearch-process-search-string str str))
86 (let* ((keys (read-key-sequence nil))
87 (current-command (key-binding keys t)))
88 (setq isearch-fep-mode (not (eq command current-command)))
89 (if isearch-fep-mode
90 (if (assq current-command isearch-fep-table)
91 (setq command current-command)
92 (cond ((eq current-command 'isearch-printing-char)
93 (setq str (funcall (nth 2 table) keys))
94 (isearch-process-search-string str str))
95 ((or (eq current-command 'isearch-other-control-char)
96 (eq current-command 'isearch-other-meta-char))
97 (call-interactively current-command)
98 (setq isearch-fep-mode nil))
99 ((eq current-command 'isearch-exit)
100 (setq isearch-fep-mode nil)
101 (message "%s%s"
102 (isearch-message-prefix) isearch-message))
103 (t
104 (call-interactively current-command))))
105 (setq isearch-fep-prompt nil)
106 (message "%s%s" (isearch-message-prefix) isearch-message)))))))
107
108 ;;
109 ;; Read string from minibuffer for incremental search.
110 ;;
111
112 ;;;###autoload
113 (defun isearch-fep-string ()
114 "Read string from minibuffer for incremental search."
115 (interactive)
116 (isearch-fep-mode))
117
118 (defun isearch-fep-prompt-string ()
119 search-string-char-prompt)
120
121 (defun exit-minibuffer-and-isearch-backward ()
122 (interactive)
123 (setq unread-command-events
124 (nconc unread-command-events
125 (list (character-to-event ?\r) (character-to-event ?\r))))
126 (exit-minibuffer))
127
128 (defun isearch-fep-read-string ()
129 (save-excursion
130 (set-buffer (window-buffer (minibuffer-window)))
131 (let* ((overriding-local-map nil)
132 (minibuffer-local-map (cons 'keymap minibuffer-local-map)))
133 ;; Some program overwrites "\C-m"'s default binding.
134 (define-key minibuffer-local-map "\C-m" 'exit-minibuffer)
135 (define-key minibuffer-local-map "\C-s" 'exit-minibuffer)
136 (define-key minibuffer-local-map "\C-r"
137 'exit-minibuffer-and-isearch-backward)
138 (condition-case condition
139 (read-from-minibuffer (concat isearch-fep-prompt (isearch-message)))
140 (quit
141 (isearch-abort))))))
142
143
144 ;;
145 ;; For EGG
146 ;;
147
148 ;;;###autoload
149 (defun isearch-fep-egg ()
150 "Read string for incremental search by using egg."
151 (interactive)
152 (isearch-fep-mode))
153
154 (defun isearch-fep-prompt-egg ()
155 (if (featurep 'egg)
156 (format "[%s]" (map-indicator its:*current-map*))
157 (setq isearch-fep-mode nil)
158 (message "No EGG!! ")
159 (sit-for 1)
160 ""))
161
162 (defun isearch-exit-minibuffer-egg (from to)
163 (exit-minibuffer))
164
165 (defvar isearch-fep-egg-its-map nil)
166 (defvar isearch-fep-egg-server-type nil)
167
168 (defun isearch-minibuffer-setup-egg ()
169 (setq its:*current-map* isearch-fep-egg-its-map)
170 (setq wnn-server-type isearch-fep-egg-server-type))
171
172 (defun isearch-fep-read-egg (first-str)
173 (if (and (featurep 'egg) (= (minibuffer-depth) 0))
174 (let ((isearch-fep-egg-its-map its:*current-map*)
175 (isearch-fep-egg-server-type wnn-server-type)
176 (minibuffer-setup-hook 'isearch-minibuffer-setup-egg))
177 (save-excursion
178 (set-buffer (window-buffer (minibuffer-window)))
179 (let ((display-minibuffer-mode-in-minibuffer t)
180 (egg:*input-mode* t)
181 (egg:*mode-on* t)
182 (self-insert-after-hook 'isearch-exit-minibuffer-egg))
183 (setq unread-command-events (listify-key-sequence first-str))
184 (unwind-protect
185 (read-from-minibuffer (isearch-message))
186 (setq egg:henkan-mode-in-use nil)
187 (setq disable-undo nil)))))
188 ""))
189
190
191 ;;
192 ;; For Canna
193 ;;
194
195 ;;;###autoload
196 (defun isearch-fep-canna ()
197 "Read string for incremental search by using canna."
198 (interactive)
199 (isearch-fep-mode))
200
201 (defun isearch-fep-prompt-canna ()
202 (if (and (featurep 'canna) canna:*initialized*)
203 (format "%s" canna:*kanji-mode-string*)
204 (setq isearch-fep-mode nil)
205 (message "No Canna!! ")
206 (sit-for 1)
207 ""))
208
209 (defun isearch-exit-minibuffer-canna (from to)
210 (exit-minibuffer))
211
212 (defun isearch-fep-read-canna (first-str)
213 (if (and (featurep 'canna) (= (minibuffer-depth) 0))
214 (save-excursion
215 (set-buffer (window-buffer (minibuffer-window)))
216 (let ((display-minibuffer-mode-in-minibuffer t)
217 (canna:*japanese-mode* t)
218 (canna:*japanese-mode-in-minibuffer* t)
219 (canna:*fence-mode* nil)
220 (self-insert-after-hook 'isearch-exit-minibuffer-canna))
221 (setq unread-command-events (listify-key-sequence first-str))
222 (unwind-protect
223 (read-from-minibuffer (isearch-message))
224 ;XEmacs change:
225 (buffer-enable-undo (current-buffer)))))
226 ""))
227
228
229 ;;
230 ;; For QUAIL
231 ;;
232
233 ;;;###autoload
234 (defun isearch-fep-quail ()
235 "Read string for incremental search by using quail."
236 (interactive)
237 (require 'quail)
238 (isearch-fep-mode))
239
240 (defun isearch-fep-prompt-quail ()
241 "[QUAIL]")
242
243 (defun isearch-exit-minibuffer-quail ()
244 (if (or quail-current-key quail-current-str)
245 nil
246 (exit-minibuffer)))
247
248 (defun isearch-fep-read-quail (first-str)
249 (let ((quail-self-insert-after-hook 'isearch-exit-minibuffer-quail))
250 (setq unread-command-events
251 (nconc unread-command-events
252 (cons (character-to-event ?\\)
253 (listify-key-sequence first-str)))
254 (unwind-protect
255 (read-from-minibuffer
256 (concat isearch-fep-prompt (isearch-message)))
257 ;; XEmacs change:
258 (buffer-enable-undo (current-buffer))
259 ))))
260
261
262 (provide 'isearch-ext)
263 ;;; isearch-ext.el ends here
264