(bat-generic-mode): "::"-style comments don't
[bpt/emacs.git] / lisp / international / isearch-x.el
1 ;;; isearch-x.el --- extended isearch handling commands
2
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
4 ;; Licensed to the Free Software Foundation.
5
6 ;; Keywords: multilingual, isearch
7
8 ;; Author: Kenichi HANDA <handa@etl.go.jp>
9 ;; Maintainer: Kenichi HANDA <handa@etl.go.jp>
10
11 ;; This file is part of GNU Emacs.
12
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; any later version.
17
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
22
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 ;; Boston, MA 02111-1307, USA.
27
28 ;;; Code:
29
30 ;;;###autoload
31 (defun isearch-toggle-specified-input-method ()
32 "Select an input method and turn it on in interactive search."
33 (interactive)
34 (let ((overriding-terminal-local-map nil))
35 (toggle-input-method t))
36 (setq isearch-input-method-function input-method-function
37 isearch-input-method-local-p t)
38 (setq input-method-function nil)
39 (isearch-update))
40
41 ;;;###autoload
42 (defun isearch-toggle-input-method ()
43 "Toggle input method in interactive search."
44 (interactive)
45 (let ((overriding-terminal-local-map nil))
46 (toggle-input-method))
47 (setq isearch-input-method-function input-method-function
48 isearch-input-method-local-p t)
49 (setq input-method-function nil)
50 (isearch-update))
51
52 (defvar isearch-minibuffer-local-map
53 (let ((map (make-keymap)))
54 (define-key map [t] 'isearch-minibuffer-non-self-insert)
55 (let ((i ?\ ))
56 (while (< i 256)
57 (define-key map (vector i) 'isearch-minibuffer-self-insert)
58 (setq i (1+ i))))
59 (let ((l (generic-character-list))
60 (table (nth 1 map)))
61 (while l
62 (set-char-table-default table (car l) 'isearch-minibuffer-self-insert)
63 (setq l (cdr l))))
64 (define-key map "\C-m" 'exit-minibuffer)
65 (define-key map [return] 'exit-minibuffer)
66 (define-key map "\C-g" 'exit-minibuffer)
67 map)
68 "Keymap of minibuffer to input multibyte characters while isearching.")
69
70 (defun isearch-minibuffer-non-self-insert ()
71 (interactive)
72 (setq unread-command-events (cons last-command-event unread-command-events))
73 (exit-minibuffer))
74
75 (defun isearch-minibuffer-self-insert ()
76 (interactive)
77 (let ((events (cons last-command-event unread-post-input-method-events)))
78 (catch 'isearch-tag
79 (while events
80 (let* ((event (car events))
81 (cmd (key-binding (vector event))))
82 (cond ((or (eq cmd 'isearch-printing-char)
83 (eq cmd 'isearch-minibuffer-self-insert))
84 (insert event)
85 (setq events (cdr events)))
86 ((eq cmd 'exit-minibuffer)
87 (setq events (cdr events))
88 (throw 'isearch-tag nil))
89 (t
90 (throw 'isearch-tag nil))))))
91 (setq unread-post-input-method-events events)
92 (exit-minibuffer)))
93
94 ;;;###autoload
95 (defun isearch-process-search-multibyte-characters (last-char)
96 (if (eq this-command 'isearch-printing-char)
97 (let ((overriding-terminal-local-map nil)
98 ;; Let input method work rather tersely.
99 (input-method-verbose-flag nil)
100 (minibuffer-local-map isearch-minibuffer-local-map)
101 str)
102 (setq unread-command-events
103 (cons last-char unread-command-events))
104 (setq str (read-multilingual-string
105 (concat (isearch-message-prefix) isearch-message)
106 nil
107 current-input-method))
108 (if (and str (> (length str) 0))
109 (let ((unread-command-events nil))
110 (isearch-process-search-string str str))
111 (isearch-update)))
112 (isearch-process-search-char last-char)))
113
114 ;;; isearch-x.el ends here