(font-lock-comment-delimiter-face): Fix up the inheritance.
[bpt/emacs.git] / lisp / international / isearch-x.el
CommitLineData
4ed46869
KH
1;;; isearch-x.el --- extended isearch handling commands
2
4ed46869 3;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
fa526c4a 4;; Licensed to the Free Software Foundation.
c3b0c268 5;; Copyright (C) 2001 Free Software Foundation, Inc.
4ed46869
KH
6
7;; Keywords: multilingual, isearch
8
9;; Author: Kenichi HANDA <handa@etl.go.jp>
10;; Maintainer: Kenichi HANDA <handa@etl.go.jp>
11
12;; This file is part of GNU Emacs.
13
14;; GNU Emacs 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 version 2, or (at your option)
17;; any later version.
18
19;; GNU Emacs 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
369314dc
KH
25;; along with GNU Emacs; see the file COPYING. If not, write to the
26;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
27;; Boston, MA 02111-1307, USA.
4ed46869 28
e8af40ee
PJ
29;;; Commentary:
30
4ed46869
KH
31;;; Code:
32
33;;;###autoload
34(defun isearch-toggle-specified-input-method ()
e81ed9ed 35 "Select an input method and turn it on in interactive search."
4ed46869 36 (interactive)
000028d7
KH
37 (let ((overriding-terminal-local-map nil))
38 (toggle-input-method t))
a2abd6b4
KH
39 (setq isearch-input-method-function input-method-function
40 isearch-input-method-local-p t)
41 (setq input-method-function nil)
000028d7 42 (isearch-update))
4ed46869
KH
43
44;;;###autoload
45(defun isearch-toggle-input-method ()
46 "Toggle input method in interactive search."
47 (interactive)
000028d7
KH
48 (let ((overriding-terminal-local-map nil))
49 (toggle-input-method))
a2abd6b4
KH
50 (setq isearch-input-method-function input-method-function
51 isearch-input-method-local-p t)
52 (setq input-method-function nil)
4ed46869
KH
53 (isearch-update))
54
a2abd6b4 55(defvar isearch-minibuffer-local-map
a50192e7
KH
56 (let ((map (copy-keymap minibuffer-local-map)))
57 (define-key map [with-keyboard-coding] 'isearch-with-keyboard-coding)
58 (define-key map [with-input-method] 'isearch-with-input-method)
a2abd6b4 59 map)
a50192e7 60 "Keymap to use in minibuffer for multibyte character inputting in isearch.")
a2abd6b4 61
a50192e7
KH
62;; Exit from recursive edit safely. Set in `after-change-functions'
63;; by isearch-with-keyboard-coding.
c3b0c268 64(defun isearch-exit-recursive-edit (start end length)
a2abd6b4 65 (interactive)
a50192e7
KH
66 (throw 'exit nil))
67
68;; Simulate character decoding by the keyboard coding system in the
69;; current buffer (minibuffer). As soon as a character is inserted,
70;; it exits from minibuffer.
71
72(defun isearch-with-keyboard-coding ()
73 (interactive)
74 (let ((after-change-functions '(isearch-exit-recursive-edit)))
75 (recursive-edit))
a2abd6b4
KH
76 (exit-minibuffer))
77
a50192e7
KH
78;; Simulate the work of the current input method in the current buffer
79;; (minibuffer).
80
81(defun isearch-with-input-method ()
a2abd6b4 82 (interactive)
8aa87e06
KH
83 (let ((key (car unread-command-events))
84 events)
85 (setq unread-command-events (cdr unread-command-events)
86 events (funcall input-method-function key))
a50192e7
KH
87 ;; EVENTS is a list of events the input method has generated. It
88 ;; contains a character event and/or the special event
89 ;; `compose-last-chars'. We extract only character events and
90 ;; insert the corresponding characters.
91 (while events
92 (if (integerp (car events)) (insert (car events)))
93 (setq events (cdr events)))
bbb398a1 94 (exit-minibuffer)))
a2abd6b4 95
000028d7 96;;;###autoload
4ed46869 97(defun isearch-process-search-multibyte-characters (last-char)
07474fef
KH
98 (if (eq this-command 'isearch-printing-char)
99 (let ((overriding-terminal-local-map nil)
98e008e9 100 (prompt (concat (isearch-message-prefix)))
07474fef
KH
101 (minibuffer-local-map isearch-minibuffer-local-map)
102 str)
a50192e7
KH
103 (if isearch-input-method-function
104 (let (;; Let input method work rather tersely.
5cf1bf86 105 (input-method-verbose-flag nil))
a50192e7
KH
106 (setq unread-command-events
107 (cons 'with-input-method
108 (cons last-char unread-command-events))
5cf1bf86 109 ;; Inherit current-input-method in a minibuffer.
98e008e9 110 str (read-string prompt isearch-message nil nil t))
a50192e7
KH
111 (if (not str)
112 ;; All inputs were deleted while the input method
113 ;; was working.
114 (setq str "")
98e008e9 115 (setq str (substring str (length isearch-message)))
a50192e7 116 (if (and (= (length str) 1)
5cf1bf86
KH
117 (= (aref str 0) last-char)
118 (>= last-char 128))
a50192e7
KH
119 ;; The input method couldn't handle LAST-CHAR.
120 (setq str nil)))))
121
122 (if (and (not str) (keyboard-coding-system))
123 (setq unread-command-events
124 (cons 'with-keyboard-coding
125 (cons last-char unread-command-events))
126 str (read-string prompt)))
127
07474fef 128 (if (and str (> (length str) 0))
39d484ed
KH
129 (let ((unread-command-events nil))
130 (isearch-process-search-string str str))
131 (isearch-update)))
07474fef 132 (isearch-process-search-char last-char)))
4ed46869 133
ab5796a9 134;;; arch-tag: 1a90a6cf-2cb2-477a-814a-9ff895852822
4ed46869 135;;; isearch-x.el ends here