1 ;;; isearch-x.el --- extended isearch handling commands
3 ;; Copyright (C) 1997, 2001, 2004 Free Software Foundation, Inc.
4 ;; Copyright (C) 1995, 1997, 1998, 2000
5 ;; National Institute of Advanced Industrial Science and Technology (AIST)
6 ;; Registration Number H14PRO021
8 ;; Keywords: multilingual, isearch
10 ;; Author: Kenichi HANDA <handa@etl.go.jp>
11 ;; Maintainer: Kenichi HANDA <handa@etl.go.jp>
13 ;; This file is part of GNU Emacs.
15 ;; GNU Emacs is free software; you can redistribute it and/or modify
16 ;; it under the terms of the GNU General Public License as published by
17 ;; the Free Software Foundation; either version 2, or (at your option)
20 ;; GNU Emacs is distributed in the hope that it will be useful,
21 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 ;; GNU General Public License for more details.
25 ;; You should have received a copy of the GNU General Public License
26 ;; along with GNU Emacs; see the file COPYING. If not, write to the
27 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
28 ;; Boston, MA 02111-1307, USA.
35 (defun isearch-toggle-specified-input-method ()
36 "Select an input method and turn it on in interactive search."
38 (let ((overriding-terminal-local-map nil
))
39 (toggle-input-method t
))
40 (setq isearch-input-method-function input-method-function
41 isearch-input-method-local-p t
)
42 (setq input-method-function nil
)
46 (defun isearch-toggle-input-method ()
47 "Toggle input method in interactive search."
49 (let ((overriding-terminal-local-map nil
))
50 (toggle-input-method))
51 (setq isearch-input-method-function input-method-function
52 isearch-input-method-local-p t
)
53 (setq input-method-function nil
)
56 (defvar isearch-minibuffer-local-map
57 (let ((map (copy-keymap minibuffer-local-map
)))
58 (define-key map
[with-keyboard-coding
] 'isearch-with-keyboard-coding
)
59 (define-key map
[with-input-method
] 'isearch-with-input-method
)
61 "Keymap to use in minibuffer for multibyte character inputting in isearch.")
63 ;; Exit from recursive edit safely. Set in `after-change-functions'
64 ;; by isearch-with-keyboard-coding.
65 (defun isearch-exit-recursive-edit (start end length
)
69 ;; Simulate character decoding by the keyboard coding system in the
70 ;; current buffer (minibuffer). As soon as a character is inserted,
71 ;; it exits from minibuffer.
73 (defun isearch-with-keyboard-coding ()
75 (let ((after-change-functions '(isearch-exit-recursive-edit)))
79 ;; Simulate the work of the current input method in the current buffer
82 (defun isearch-with-input-method ()
84 (let ((key (car unread-command-events
))
86 (setq unread-command-events
(cdr unread-command-events
)
87 events
(funcall input-method-function key
))
88 ;; EVENTS is a list of events the input method has generated. It
89 ;; contains a character event and/or the special event
90 ;; `compose-last-chars'. We extract only character events and
91 ;; insert the corresponding characters.
93 (if (integerp (car events
)) (insert (car events
)))
94 (setq events
(cdr events
)))
98 (defun isearch-process-search-multibyte-characters (last-char)
99 (if (eq this-command
'isearch-printing-char
)
100 (let ((overriding-terminal-local-map nil
)
101 (prompt (concat (isearch-message-prefix)))
102 (minibuffer-local-map isearch-minibuffer-local-map
)
104 (if isearch-input-method-function
105 (let (;; Let input method work rather tersely.
106 (input-method-verbose-flag nil
))
107 (setq unread-command-events
108 (cons 'with-input-method
109 (cons last-char unread-command-events
))
110 ;; Inherit current-input-method in a minibuffer.
111 str
(read-string prompt isearch-message nil nil t
))
113 ;; All inputs were deleted while the input method
116 (setq str
(substring str
(length isearch-message
)))
117 (if (and (= (length str
) 1)
118 (= (aref str
0) last-char
)
120 ;; The input method couldn't handle LAST-CHAR.
123 (if (and (not str
) (keyboard-coding-system))
124 (setq unread-command-events
125 (cons 'with-keyboard-coding
126 (cons last-char unread-command-events
))
127 str
(read-string prompt
)))
129 (if (and str
(> (length str
) 0))
130 (let ((unread-command-events nil
))
131 (isearch-process-search-string str str
))
133 (isearch-process-search-char last-char
)))
135 ;;; arch-tag: 1a90a6cf-2cb2-477a-814a-9ff895852822
136 ;;; isearch-x.el ends here