cc-langs.el (c-nonlabel-token-key): Allow quoted character constants (as
[emacs.git] / lisp / international / isearch-x.el
blob66202a6d11d85bd722bfa4f8d3c8d58260be8aeb
1 ;;; isearch-x.el --- extended isearch handling commands
3 ;; Copyright (C) 1997, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
4 ;; Free Software Foundation, Inc.
5 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
6 ;; 2005, 2006, 2007, 2008, 2009
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 3 of the License, or
20 ;; (at your option) any later version.
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. If not, see <http://www.gnu.org/licenses/>.
30 ;;; Commentary:
32 ;;; Code:
34 ;;;###autoload
35 (defun isearch-toggle-specified-input-method ()
36 "Select an input method and turn it on in interactive search."
37 (interactive)
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)
43 (isearch-update))
45 ;;;###autoload
46 (defun isearch-toggle-input-method ()
47 "Toggle input method in interactive search."
48 (interactive)
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)
54 (isearch-update))
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)
60 map)
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)
66 (interactive)
67 (throw 'exit nil))
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 ()
74 (interactive)
75 (let ((after-change-functions '(isearch-exit-recursive-edit)))
76 (recursive-edit))
77 (exit-minibuffer))
79 ;; Simulate the work of the current input method in the current buffer
80 ;; (minibuffer).
82 (defun isearch-with-input-method ()
83 (interactive)
84 (let ((key (car unread-command-events))
85 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.
92 (while events
93 (if (integerp (car events)) (insert (car events)))
94 (setq events (cdr events)))
95 (exit-minibuffer)))
97 ;;;###autoload
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 (isearch-message-prefix))
102 (minibuffer-local-map isearch-minibuffer-local-map)
103 str junk-hist)
105 ;; PROMPT contains text-properties from
106 ;; `minibuffer-prompt-properties', and some of these can screw up
107 ;; its use in `read-string' below (specifically, a read-only
108 ;; property will cause it to signal an error), so strip them here;
109 ;; read-string will add the same properties itself anyway.
111 (set-text-properties 0 (length prompt) nil prompt)
113 (if isearch-input-method-function
114 (let (;; Let input method work rather tersely.
115 (input-method-verbose-flag nil))
116 (setq unread-command-events
117 (cons 'with-input-method
118 (cons last-char unread-command-events))
119 ;; Inherit current-input-method in a minibuffer.
120 str (read-string prompt isearch-message 'junk-hist nil t))
121 (if (or (not str) (< (length str) (length isearch-message)))
122 ;; All inputs were deleted while the input method
123 ;; was working.
124 (setq str "")
125 (setq str (substring str (length isearch-message)))
126 (if (and (= (length str) 1)
127 (= (aref str 0) last-char)
128 (>= last-char 128))
129 ;; The input method couldn't handle LAST-CHAR.
130 (setq str nil)))))
132 (if (and (not str) (keyboard-coding-system))
133 (setq unread-command-events
134 (cons 'with-keyboard-coding
135 (cons last-char unread-command-events))
136 str (read-string prompt nil 'junk-hist)))
138 (if (and str (> (length str) 0))
139 (let ((unread-command-events nil))
140 (isearch-process-search-string str str))
141 (isearch-update)))
142 (isearch-process-search-char last-char)))
144 ;; arch-tag: 1a90a6cf-2cb2-477a-814a-9ff895852822
145 ;;; isearch-x.el ends here