Commit | Line | Data |
---|---|---|
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. |
4ed46869 KH |
5 | |
6 | ;; Keywords: multilingual, isearch | |
7 | ||
8 | ;; Author: Kenichi HANDA <handa@etl.go.jp> | |
9 | ;; Maintainer: Kenichi HANDA <handa@etl.go.jp> | |
10 | ||
11 | ;; This file is part of GNU Emacs. | |
12 | ||
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) | |
16 | ;; any later version. | |
17 | ||
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. | |
22 | ||
23 | ;; You should have received a copy of the GNU General Public License | |
369314dc KH |
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. | |
4ed46869 KH |
27 | |
28 | ;;; Code: | |
29 | ||
30 | ;;;###autoload | |
31 | (defun isearch-toggle-specified-input-method () | |
e81ed9ed | 32 | "Select an input method and turn it on in interactive search." |
4ed46869 | 33 | (interactive) |
000028d7 KH |
34 | (let ((overriding-terminal-local-map nil)) |
35 | (toggle-input-method t)) | |
a2abd6b4 KH |
36 | (setq isearch-input-method-function input-method-function |
37 | isearch-input-method-local-p t) | |
38 | (setq input-method-function nil) | |
000028d7 | 39 | (isearch-update)) |
4ed46869 KH |
40 | |
41 | ;;;###autoload | |
42 | (defun isearch-toggle-input-method () | |
43 | "Toggle input method in interactive search." | |
44 | (interactive) | |
000028d7 KH |
45 | (let ((overriding-terminal-local-map nil)) |
46 | (toggle-input-method)) | |
a2abd6b4 KH |
47 | (setq isearch-input-method-function input-method-function |
48 | isearch-input-method-local-p t) | |
49 | (setq input-method-function nil) | |
4ed46869 KH |
50 | (isearch-update)) |
51 | ||
a2abd6b4 KH |
52 | (defvar isearch-minibuffer-local-map |
53 | (let ((map (make-keymap))) | |
54 | (define-key map [t] 'isearch-minibuffer-non-self-insert) | |
55 | (let ((i ?\ )) | |
56 | (while (< i 256) | |
57 | (define-key map (vector i) 'isearch-minibuffer-self-insert) | |
58 | (setq i (1+ i)))) | |
59 | (let ((l (generic-character-list)) | |
60 | (table (nth 1 map))) | |
61 | (while l | |
62 | (set-char-table-default table (car l) 'isearch-minibuffer-self-insert) | |
63 | (setq l (cdr l)))) | |
64 | (define-key map "\C-m" 'exit-minibuffer) | |
65 | (define-key map [return] 'exit-minibuffer) | |
bbb398a1 | 66 | (define-key map "\C-g" 'exit-minibuffer) |
a2abd6b4 KH |
67 | map) |
68 | "Keymap of minibuffer to input multibyte characters while isearching.") | |
69 | ||
70 | (defun isearch-minibuffer-non-self-insert () | |
71 | (interactive) | |
72 | (setq unread-command-events (cons last-command-event unread-command-events)) | |
73 | (exit-minibuffer)) | |
74 | ||
75 | (defun isearch-minibuffer-self-insert () | |
76 | (interactive) | |
07474fef KH |
77 | (let ((events (cons last-command-event unread-post-input-method-events))) |
78 | (catch 'isearch-tag | |
79 | (while events | |
80 | (let* ((event (car events)) | |
bbb398a1 KH |
81 | (cmd (key-binding (vector event)))) |
82 | (cond ((or (eq cmd 'isearch-printing-char) | |
83 | (eq cmd 'isearch-minibuffer-self-insert)) | |
07474fef KH |
84 | (insert event) |
85 | (setq events (cdr events))) | |
86 | ((eq cmd 'exit-minibuffer) | |
87 | (setq events (cdr events)) | |
88 | (throw 'isearch-tag nil)) | |
89 | (t | |
90 | (throw 'isearch-tag nil)))))) | |
91 | (setq unread-post-input-method-events events) | |
bbb398a1 | 92 | (exit-minibuffer))) |
a2abd6b4 | 93 | |
000028d7 | 94 | ;;;###autoload |
4ed46869 | 95 | (defun isearch-process-search-multibyte-characters (last-char) |
07474fef KH |
96 | (if (eq this-command 'isearch-printing-char) |
97 | (let ((overriding-terminal-local-map nil) | |
98 | ;; Let input method work rather tersely. | |
99 | (input-method-verbose-flag nil) | |
100 | (minibuffer-local-map isearch-minibuffer-local-map) | |
101 | str) | |
bbb398a1 KH |
102 | (setq unread-command-events |
103 | (cons last-char unread-command-events)) | |
07474fef KH |
104 | (setq str (read-multilingual-string |
105 | (concat (isearch-message-prefix) isearch-message) | |
106 | nil | |
107 | current-input-method)) | |
108 | (if (and str (> (length str) 0)) | |
bbb398a1 KH |
109 | (isearch-process-search-string str str)) |
110 | (isearch-update)) | |
07474fef | 111 | (isearch-process-search-char last-char))) |
4ed46869 KH |
112 | |
113 | ;;; isearch-x.el ends here |