Mercurial > emacs
annotate lisp/international/isearch-x.el @ 90776:dd7c098af727
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 638-652)
- Update from CVS
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 202)
- Update from CVS
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-177
author | Miles Bader <miles@gnu.org> |
---|---|
date | Mon, 26 Feb 2007 23:03:45 +0000 |
parents | 95d0cdf160ea |
children | 91bf6e05918b |
rev | line source |
---|---|
17052 | 1 ;;; isearch-x.el --- extended isearch handling commands |
2 | |
75347 | 3 ;; Copyright (C) 1997, 2001, 2002, 2003, 2004, 2005, 2006, 2007 |
74544 | 4 ;; Free Software Foundation, Inc. |
74605
6ee41fdd69ff
Update AIST copyright years.
Kenichi Handa <handa@m17n.org>
parents:
74544
diff
changeset
|
5 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
75347 | 6 ;; 2005, 2006, 2007 |
62274 | 7 ;; National Institute of Advanced Industrial Science and Technology (AIST) |
8 ;; Registration Number H14PRO021 | |
17052 | 9 |
10 ;; Keywords: multilingual, isearch | |
11 | |
12 ;; Author: Kenichi HANDA <handa@etl.go.jp> | |
13 ;; Maintainer: Kenichi HANDA <handa@etl.go.jp> | |
14 | |
15 ;; This file is part of GNU Emacs. | |
16 | |
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) | |
20 ;; any later version. | |
21 | |
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. | |
26 | |
27 ;; You should have received a copy of the GNU General Public License | |
17071 | 28 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
64085 | 29 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
30 ;; Boston, MA 02110-1301, USA. | |
17052 | 31 |
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
32798
diff
changeset
|
32 ;;; Commentary: |
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
32798
diff
changeset
|
33 |
17052 | 34 ;;; Code: |
35 | |
36 ;;;###autoload | |
37 (defun isearch-toggle-specified-input-method () | |
18713
bca5a6b78f91
(isearch-input-method): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
38 "Select an input method and turn it on in interactive search." |
17052 | 39 (interactive) |
19407
50444ccff3f2
(isearch-input-method): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19390
diff
changeset
|
40 (let ((overriding-terminal-local-map nil)) |
50444ccff3f2
(isearch-input-method): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19390
diff
changeset
|
41 (toggle-input-method t)) |
22780
54069d469c31
(isearch-toggle-specified-input-method): Adjusted for the change
Kenichi Handa <handa@m17n.org>
parents:
19433
diff
changeset
|
42 (setq isearch-input-method-function input-method-function |
54069d469c31
(isearch-toggle-specified-input-method): Adjusted for the change
Kenichi Handa <handa@m17n.org>
parents:
19433
diff
changeset
|
43 isearch-input-method-local-p t) |
54069d469c31
(isearch-toggle-specified-input-method): Adjusted for the change
Kenichi Handa <handa@m17n.org>
parents:
19433
diff
changeset
|
44 (setq input-method-function nil) |
19407
50444ccff3f2
(isearch-input-method): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19390
diff
changeset
|
45 (isearch-update)) |
17052 | 46 |
47 ;;;###autoload | |
48 (defun isearch-toggle-input-method () | |
49 "Toggle input method in interactive search." | |
50 (interactive) | |
19407
50444ccff3f2
(isearch-input-method): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19390
diff
changeset
|
51 (let ((overriding-terminal-local-map nil)) |
50444ccff3f2
(isearch-input-method): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19390
diff
changeset
|
52 (toggle-input-method)) |
22780
54069d469c31
(isearch-toggle-specified-input-method): Adjusted for the change
Kenichi Handa <handa@m17n.org>
parents:
19433
diff
changeset
|
53 (setq isearch-input-method-function input-method-function |
54069d469c31
(isearch-toggle-specified-input-method): Adjusted for the change
Kenichi Handa <handa@m17n.org>
parents:
19433
diff
changeset
|
54 isearch-input-method-local-p t) |
54069d469c31
(isearch-toggle-specified-input-method): Adjusted for the change
Kenichi Handa <handa@m17n.org>
parents:
19433
diff
changeset
|
55 (setq input-method-function nil) |
17052 | 56 (isearch-update)) |
57 | |
22780
54069d469c31
(isearch-toggle-specified-input-method): Adjusted for the change
Kenichi Handa <handa@m17n.org>
parents:
19433
diff
changeset
|
58 (defvar isearch-minibuffer-local-map |
29327 | 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) | |
22780
54069d469c31
(isearch-toggle-specified-input-method): Adjusted for the change
Kenichi Handa <handa@m17n.org>
parents:
19433
diff
changeset
|
62 map) |
29327 | 63 "Keymap to use in minibuffer for multibyte character inputting in isearch.") |
64 | |
65 ;; Exit from recursive edit safely. Set in `after-change-functions' | |
66 ;; by isearch-with-keyboard-coding. | |
39090
2fd8ebeef411
(isearch-exit-recursive-edit): Take
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
67 (defun isearch-exit-recursive-edit (start end length) |
22780
54069d469c31
(isearch-toggle-specified-input-method): Adjusted for the change
Kenichi Handa <handa@m17n.org>
parents:
19433
diff
changeset
|
68 (interactive) |
29327 | 69 (throw 'exit nil)) |
70 | |
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. | |
74 | |
75 (defun isearch-with-keyboard-coding () | |
76 (interactive) | |
77 (let ((after-change-functions '(isearch-exit-recursive-edit))) | |
78 (recursive-edit)) | |
22780
54069d469c31
(isearch-toggle-specified-input-method): Adjusted for the change
Kenichi Handa <handa@m17n.org>
parents:
19433
diff
changeset
|
79 (exit-minibuffer)) |
54069d469c31
(isearch-toggle-specified-input-method): Adjusted for the change
Kenichi Handa <handa@m17n.org>
parents:
19433
diff
changeset
|
80 |
29327 | 81 ;; Simulate the work of the current input method in the current buffer |
82 ;; (minibuffer). | |
83 | |
84 (defun isearch-with-input-method () | |
22780
54069d469c31
(isearch-toggle-specified-input-method): Adjusted for the change
Kenichi Handa <handa@m17n.org>
parents:
19433
diff
changeset
|
85 (interactive) |
32798
6d04a7aba075
(isearch-with-input-method): Call input-method-function with the first
Kenichi Handa <handa@m17n.org>
parents:
29719
diff
changeset
|
86 (let ((key (car unread-command-events)) |
6d04a7aba075
(isearch-with-input-method): Call input-method-function with the first
Kenichi Handa <handa@m17n.org>
parents:
29719
diff
changeset
|
87 events) |
6d04a7aba075
(isearch-with-input-method): Call input-method-function with the first
Kenichi Handa <handa@m17n.org>
parents:
29719
diff
changeset
|
88 (setq unread-command-events (cdr unread-command-events) |
6d04a7aba075
(isearch-with-input-method): Call input-method-function with the first
Kenichi Handa <handa@m17n.org>
parents:
29719
diff
changeset
|
89 events (funcall input-method-function key)) |
29327 | 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. | |
94 (while events | |
95 (if (integerp (car events)) (insert (car events))) | |
96 (setq events (cdr events))) | |
22920
f80a1ca0112f
(isearch-minibuffer-local-map): Bind
Kenichi Handa <handa@m17n.org>
parents:
22803
diff
changeset
|
97 (exit-minibuffer))) |
22780
54069d469c31
(isearch-toggle-specified-input-method): Adjusted for the change
Kenichi Handa <handa@m17n.org>
parents:
19433
diff
changeset
|
98 |
19407
50444ccff3f2
(isearch-input-method): Deleted.
Kenichi Handa <handa@m17n.org>
parents:
19390
diff
changeset
|
99 ;;;###autoload |
17052 | 100 (defun isearch-process-search-multibyte-characters (last-char) |
22803
c52637c83ebf
(isearch-minibuffer-self-insert):
Kenichi Handa <handa@m17n.org>
parents:
22780
diff
changeset
|
101 (if (eq this-command 'isearch-printing-char) |
c52637c83ebf
(isearch-minibuffer-self-insert):
Kenichi Handa <handa@m17n.org>
parents:
22780
diff
changeset
|
102 (let ((overriding-terminal-local-map nil) |
64437
9a14f5181afd
(isearch-process-search-multibyte-characters): Remove unneeded `concat'.
Juri Linkov <juri@jurta.org>
parents:
64085
diff
changeset
|
103 (prompt (isearch-message-prefix)) |
22803
c52637c83ebf
(isearch-minibuffer-self-insert):
Kenichi Handa <handa@m17n.org>
parents:
22780
diff
changeset
|
104 (minibuffer-local-map isearch-minibuffer-local-map) |
64437
9a14f5181afd
(isearch-process-search-multibyte-characters): Remove unneeded `concat'.
Juri Linkov <juri@jurta.org>
parents:
64085
diff
changeset
|
105 str junk-hist) |
29327 | 106 (if isearch-input-method-function |
107 (let (;; Let input method work rather tersely. | |
29719
bec7534ceb14
(isearch-minibuffer-input-method)
Kenichi Handa <handa@m17n.org>
parents:
29327
diff
changeset
|
108 (input-method-verbose-flag nil)) |
29327 | 109 (setq unread-command-events |
110 (cons 'with-input-method | |
111 (cons last-char unread-command-events)) | |
29719
bec7534ceb14
(isearch-minibuffer-input-method)
Kenichi Handa <handa@m17n.org>
parents:
29327
diff
changeset
|
112 ;; Inherit current-input-method in a minibuffer. |
64437
9a14f5181afd
(isearch-process-search-multibyte-characters): Remove unneeded `concat'.
Juri Linkov <juri@jurta.org>
parents:
64085
diff
changeset
|
113 str (read-string prompt isearch-message 'junk-hist nil t)) |
9a14f5181afd
(isearch-process-search-multibyte-characters): Remove unneeded `concat'.
Juri Linkov <juri@jurta.org>
parents:
64085
diff
changeset
|
114 (if (or (not str) (< (length str) (length isearch-message))) |
29327 | 115 ;; All inputs were deleted while the input method |
116 ;; was working. | |
117 (setq str "") | |
58912
f0538bd79bc1
(isearch-process-search-multibyte-characters):
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
118 (setq str (substring str (length isearch-message))) |
29327 | 119 (if (and (= (length str) 1) |
29719
bec7534ceb14
(isearch-minibuffer-input-method)
Kenichi Handa <handa@m17n.org>
parents:
29327
diff
changeset
|
120 (= (aref str 0) last-char) |
bec7534ceb14
(isearch-minibuffer-input-method)
Kenichi Handa <handa@m17n.org>
parents:
29327
diff
changeset
|
121 (>= last-char 128)) |
29327 | 122 ;; The input method couldn't handle LAST-CHAR. |
123 (setq str nil))))) | |
124 | |
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)) | |
64437
9a14f5181afd
(isearch-process-search-multibyte-characters): Remove unneeded `concat'.
Juri Linkov <juri@jurta.org>
parents:
64085
diff
changeset
|
129 str (read-string prompt nil 'junk-hist))) |
29327 | 130 |
22803
c52637c83ebf
(isearch-minibuffer-self-insert):
Kenichi Handa <handa@m17n.org>
parents:
22780
diff
changeset
|
131 (if (and str (> (length str) 0)) |
22931
fad48aef2340
(isearch-process-search-multibyte-characters): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
22920
diff
changeset
|
132 (let ((unread-command-events nil)) |
fad48aef2340
(isearch-process-search-multibyte-characters): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
22920
diff
changeset
|
133 (isearch-process-search-string str str)) |
fad48aef2340
(isearch-process-search-multibyte-characters): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
22920
diff
changeset
|
134 (isearch-update))) |
22803
c52637c83ebf
(isearch-minibuffer-self-insert):
Kenichi Handa <handa@m17n.org>
parents:
22780
diff
changeset
|
135 (isearch-process-search-char last-char))) |
17052 | 136 |
52401 | 137 ;;; arch-tag: 1a90a6cf-2cb2-477a-814a-9ff895852822 |
17052 | 138 ;;; isearch-x.el ends here |