1 ;;; isearch-x.el --- extended isearch handling commands
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
4 ;; Licensed to the Free Software Foundation.
6 ;; Keywords: multilingual, isearch
8 ;; Author: Kenichi HANDA <handa@etl.go.jp>
9 ;; Maintainer: Kenichi HANDA <handa@etl.go.jp>
11 ;; This file is part of GNU Emacs.
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)
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.
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.
31 (defun isearch-toggle-specified-input-method ()
32 "Select an input method and turn it on in interactive search."
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
)
42 (defun isearch-toggle-input-method ()
43 "Toggle input method in interactive search."
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
)
52 (defvar isearch-minibuffer-local-map
53 (let ((map (copy-keymap minibuffer-local-map
)))
54 (define-key map
[with-keyboard-coding
] 'isearch-with-keyboard-coding
)
55 (define-key map
[with-input-method
] 'isearch-with-input-method
)
57 "Keymap to use in minibuffer for multibyte character inputting in isearch.")
59 ;; Exit from recursive edit safely. Set in `after-change-functions'
60 ;; by isearch-with-keyboard-coding.
61 (defun isearch-exit-recursive-edit ()
65 ;; Simulate character decoding by the keyboard coding system in the
66 ;; current buffer (minibuffer). As soon as a character is inserted,
67 ;; it exits from minibuffer.
69 (defun isearch-with-keyboard-coding ()
71 (let ((after-change-functions '(isearch-exit-recursive-edit)))
75 ;; Simulate the work of the current input method in the current buffer
78 (defun isearch-with-input-method ()
80 (let ((events (funcall input-method-function nil
)))
81 ;; EVENTS is a list of events the input method has generated. It
82 ;; contains a character event and/or the special event
83 ;; `compose-last-chars'. We extract only character events and
84 ;; insert the corresponding characters.
86 (if (integerp (car events
)) (insert (car events
)))
87 (setq events
(cdr events
)))
91 (defun isearch-process-search-multibyte-characters (last-char)
92 (if (eq this-command
'isearch-printing-char
)
93 (let ((overriding-terminal-local-map nil
)
94 (prompt (concat (isearch-message-prefix) isearch-message
))
95 (minibuffer-local-map isearch-minibuffer-local-map
)
97 (if isearch-input-method-function
98 (let (;; Let input method work rather tersely.
99 (input-method-verbose-flag nil
))
100 (setq unread-command-events
101 (cons 'with-input-method
102 (cons last-char unread-command-events
))
103 ;; Inherit current-input-method in a minibuffer.
104 str
(read-string prompt nil nil nil t
))
106 ;; All inputs were deleted while the input method
109 (if (and (= (length str
) 1)
110 (= (aref str
0) last-char
)
112 ;; The input method couldn't handle LAST-CHAR.
115 (if (and (not str
) (keyboard-coding-system))
116 (setq unread-command-events
117 (cons 'with-keyboard-coding
118 (cons last-char unread-command-events
))
119 str
(read-string prompt
)))
121 (if (and str
(> (length str
) 0))
122 (let ((unread-command-events nil
))
123 (isearch-process-search-string str str
))
125 (isearch-process-search-char last-char
)))
127 ;;; isearch-x.el ends here