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) | |
66 | map) | |
67 | "Keymap of minibuffer to input multibyte characters while isearching.") | |
68 | ||
69 | (defun isearch-minibuffer-non-self-insert () | |
70 | (interactive) | |
71 | (setq unread-command-events (cons last-command-event unread-command-events)) | |
72 | (exit-minibuffer)) | |
73 | ||
74 | (defun isearch-minibuffer-self-insert () | |
75 | (interactive) | |
07474fef KH |
76 | (let ((events (cons last-command-event unread-post-input-method-events))) |
77 | (catch 'isearch-tag | |
78 | (while events | |
79 | (let* ((event (car events)) | |
80 | (cmd (lookup-key isearch-mode-map (vector event)))) | |
81 | (cond ((eq cmd 'isearch-printing-char) | |
82 | (insert event) | |
83 | (setq events (cdr events))) | |
84 | ((eq cmd 'exit-minibuffer) | |
85 | (setq events (cdr events)) | |
86 | (throw 'isearch-tag nil)) | |
87 | (t | |
88 | (throw 'isearch-tag nil)))))) | |
89 | (setq unread-post-input-method-events events) | |
90 | (or unread-post-input-method-events | |
91 | (exit-minibuffer)))) | |
a2abd6b4 | 92 | |
000028d7 | 93 | ;;;###autoload |
4ed46869 | 94 | (defun isearch-process-search-multibyte-characters (last-char) |
07474fef KH |
95 | (if (eq this-command 'isearch-printing-char) |
96 | (let ((overriding-terminal-local-map nil) | |
97 | ;; Let input method work rather tersely. | |
98 | (input-method-verbose-flag nil) | |
99 | (minibuffer-local-map isearch-minibuffer-local-map) | |
100 | str) | |
101 | (setq unread-input-method-events | |
102 | (cons last-char unread-input-method-events)) | |
103 | (setq str (read-multilingual-string | |
104 | (concat (isearch-message-prefix) isearch-message) | |
105 | nil | |
106 | current-input-method)) | |
107 | (if (and str (> (length str) 0)) | |
108 | (isearch-process-search-string str str) | |
109 | (isearch-update))) | |
110 | (isearch-process-search-char last-char))) | |
4ed46869 KH |
111 | |
112 | ;;; isearch-x.el ends here |