1 ;;; isearch-x.el --- extended isearch handling commands
3 ;; Copyright (C) 1997, 2001, 2002, 2003, 2004, 2005, 2006, 2007
4 ;; Free Software Foundation, Inc.
5 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
7 ;; National Institute of Advanced Industrial Science and Technology (AIST)
8 ;; Registration Number H14PRO021
10 ;; Keywords: multilingual, isearch
12 ;; Author: Kenichi HANDA <handa@etl.go.jp>
13 ;; Maintainer: Kenichi HANDA <handa@etl.go.jp>
15 ;; This file is part of GNU Emacs.
17 ;; GNU Emacs is free software; you can redistribute it and/or modify
18 ;; it under the terms of the GNU General Public License as published by
19 ;; the Free Software Foundation; either version 2, or (at your option)
22 ;; GNU Emacs is distributed in the hope that it will be useful,
23 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
24 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 ;; GNU General Public License for more details.
27 ;; You should have received a copy of the GNU General Public License
28 ;; along with GNU Emacs; see the file COPYING. If not, write to the
29 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
30 ;; Boston, MA 02110-1301, USA.
37 (defun isearch-toggle-specified-input-method ()
38 "Select an input method and turn it on in interactive search."
40 (let ((overriding-terminal-local-map nil
))
41 (toggle-input-method t
))
42 (setq isearch-input-method-function input-method-function
43 isearch-input-method-local-p t
)
44 (setq input-method-function nil
)
48 (defun isearch-toggle-input-method ()
49 "Toggle input method in interactive search."
51 (let ((overriding-terminal-local-map nil
))
52 (toggle-input-method))
53 (setq isearch-input-method-function input-method-function
54 isearch-input-method-local-p t
)
55 (setq input-method-function nil
)
58 (defvar isearch-minibuffer-local-map
59 (let ((map (copy-keymap minibuffer-local-map
)))
60 (define-key map
[with-keyboard-coding
] 'isearch-with-keyboard-coding
)
61 (define-key map
[with-input-method
] 'isearch-with-input-method
)
63 "Keymap to use in minibuffer for multibyte character inputting in isearch.")
65 ;; Exit from recursive edit safely. Set in `after-change-functions'
66 ;; by isearch-with-keyboard-coding.
67 (defun isearch-exit-recursive-edit (start end length
)
71 ;; Simulate character decoding by the keyboard coding system in the
72 ;; current buffer (minibuffer). As soon as a character is inserted,
73 ;; it exits from minibuffer.
75 (defun isearch-with-keyboard-coding ()
77 (let ((after-change-functions '(isearch-exit-recursive-edit)))
81 ;; Simulate the work of the current input method in the current buffer
84 (defun isearch-with-input-method ()
86 (let ((key (car unread-command-events
))
88 (setq unread-command-events
(cdr unread-command-events
)
89 events
(funcall input-method-function key
))
90 ;; EVENTS is a list of events the input method has generated. It
91 ;; contains a character event and/or the special event
92 ;; `compose-last-chars'. We extract only character events and
93 ;; insert the corresponding characters.
95 (if (integerp (car events
)) (insert (car events
)))
96 (setq events
(cdr events
)))
100 (defun isearch-process-search-multibyte-characters (last-char)
101 (if (eq this-command
'isearch-printing-char
)
102 (let ((overriding-terminal-local-map nil
)
103 (prompt (isearch-message-prefix))
104 (minibuffer-local-map isearch-minibuffer-local-map
)
106 (if isearch-input-method-function
107 (let (;; Let input method work rather tersely.
108 (input-method-verbose-flag nil
))
109 (setq unread-command-events
110 (cons 'with-input-method
111 (cons last-char unread-command-events
))
112 ;; Inherit current-input-method in a minibuffer.
113 str
(read-string prompt isearch-message
'junk-hist nil t
))
114 (if (or (not str
) (< (length str
) (length isearch-message
)))
115 ;; All inputs were deleted while the input method
118 (setq str
(substring str
(length isearch-message
)))
119 (if (and (= (length str
) 1)
120 (= (aref str
0) last-char
)
122 ;; The input method couldn't handle LAST-CHAR.
125 (if (and (not str
) (keyboard-coding-system))
126 (setq unread-command-events
127 (cons 'with-keyboard-coding
128 (cons last-char unread-command-events
))
129 str
(read-string prompt nil
'junk-hist
)))
131 (if (and str
(> (length str
) 0))
132 (let ((unread-command-events nil
))
133 (isearch-process-search-string str str
))
135 (isearch-process-search-char last-char
)))
137 ;;; arch-tag: 1a90a6cf-2cb2-477a-814a-9ff895852822
138 ;;; isearch-x.el ends here