]> git.eshelyaron.com Git - emacs.git/commitdiff
Mostly re-written.
authorKenichi Handa <handa@m17n.org>
Wed, 31 May 2000 03:50:57 +0000 (03:50 +0000)
committerKenichi Handa <handa@m17n.org>
Wed, 31 May 2000 03:50:57 +0000 (03:50 +0000)
lisp/ChangeLog
lisp/international/isearch-x.el

index bfd84d9cd57e0eb26ace55ea81b65b229d362988..025d1aa43f1bfcf147ef3778fdd2a9715a13527b 100644 (file)
@@ -1,3 +1,14 @@
+2000-05-31  Kenichi Handa  <handa@etl.go.jp>
+
+       * isearch.el (isearch-printing-char): If keyboard coding system is
+       being used, call isearch-process-search-multibyte-characters.
+
+       * international/isearch-x.el: Mostly rewritten.
+
+       * international/quail.el (quail-start-conversion): Don't include
+       unhandled events in the returned events, but set them in
+       unread-command-events.  Exit if all inputs are deleted.
+
 2000-05-30  Jason Rumney  <jasonr@gnu.org>
 
        * w32-fns.el (w32-charset-info-alist): Add each charset separately.
index 4b5342177610089104f5fd8351740ad3023d2e1f..442a3e3d172356d0414d50e8285af1e48f8569ff 100644 (file)
   (isearch-update))
 
 (defvar isearch-minibuffer-local-map
-  (let ((map (make-keymap)))
-    (define-key map [t] 'isearch-minibuffer-non-self-insert)
-    (let ((i ?\ ))
-      (while (< i 256)
-       (define-key map (vector i) 'isearch-minibuffer-self-insert)
-       (setq i (1+ i))))
-    (let ((l (generic-character-list))
-         (table (nth 1 map)))
-      (while l
-       (set-char-table-default table (car l) 'isearch-minibuffer-self-insert)
-       (setq l (cdr l))))
-    (define-key map "\C-m" 'exit-minibuffer)
-    (define-key map [return] 'exit-minibuffer)
-    (define-key map "\C-g" 'exit-minibuffer)
+  (let ((map (copy-keymap minibuffer-local-map)))
+    (define-key map [with-keyboard-coding] 'isearch-with-keyboard-coding)
+    (define-key map [with-input-method] 'isearch-with-input-method)
     map)
-  "Keymap of minibuffer to input multibyte characters while isearching.")
+  "Keymap to use in minibuffer for multibyte character inputting in isearch.")
 
-(defun isearch-minibuffer-non-self-insert ()
+
+;; These two variables are used to refer to the values of
+;; `current-input-method' and `input-method-function' of the original
+;; buffer in the function isearch-with-input-method which runs in a
+;; minibuffer.
+
+(defvar isearch-minibuffer-input-method nil)
+(defvar isearch-minibuffer-input-method-function nil)
+
+;; Exit from recursive edit safely.  Set in `after-change-functions'
+;; by isearch-with-keyboard-coding.
+(defun isearch-exit-recursive-edit ()
   (interactive)
-  (setq unread-command-events (cons last-command-event unread-command-events))
+  (throw 'exit nil))
+
+;; Simulate character decoding by the keyboard coding system in the
+;; current buffer (minibuffer).  As soon as a character is inserted,
+;; it exits from minibuffer.
+
+(defun isearch-with-keyboard-coding ()
+  (interactive)
+  (let ((after-change-functions '(isearch-exit-recursive-edit)))
+    (recursive-edit))
   (exit-minibuffer))
 
-(defun isearch-minibuffer-self-insert ()
+;; Simulate the work of the current input method in the current buffer
+;; (minibuffer).
+
+(defun isearch-with-input-method ()
   (interactive)
-  (let ((events (cons last-command-event unread-post-input-method-events)))
-    (catch 'isearch-tag
-      (while events
-       (let* ((event (car events))
-              (cmd (key-binding (vector event))))
-         (cond ((or (eq cmd 'isearch-printing-char)
-                    (eq cmd 'isearch-minibuffer-self-insert))
-                (insert event)
-                (setq events (cdr events)))
-               ((eq cmd 'exit-minibuffer)
-                (setq events (cdr events))
-                (throw 'isearch-tag nil))
-               (t
-                (throw 'isearch-tag nil))))))
-    (setq unread-post-input-method-events events)
+  (let* ((current-input-method isearch-minibuffer-input-method)
+        (events (funcall isearch-minibuffer-input-method-function nil)))
+    ;; EVENTS is a list of events the input method has generated.  It
+    ;; contains a character event and/or the special event
+    ;; `compose-last-chars'.  We extract only character events and
+    ;; insert the corresponding characters.
+    (while events
+      (if (integerp (car events)) (insert (car events)))
+      (setq events (cdr events)))
     (exit-minibuffer)))
 
 ;;;###autoload
 (defun isearch-process-search-multibyte-characters (last-char)
   (if (eq this-command 'isearch-printing-char)
       (let ((overriding-terminal-local-map nil)
-           ;; Let input method work rather tersely.
-           (input-method-verbose-flag nil)
+           (prompt (concat (isearch-message-prefix) isearch-message))
            (minibuffer-local-map isearch-minibuffer-local-map)
            str)
-       (setq unread-command-events
-             (cons last-char unread-command-events))
-       (setq str (read-multilingual-string
-                  (concat (isearch-message-prefix) isearch-message)
-                  nil
-                  current-input-method))
+       (if isearch-input-method-function
+           (let (;; Let input method work rather tersely.
+                 (input-method-verbose-flag nil)
+                 (isearch-minibuffer-input-method current-input-method)
+                 (isearch-minibuffer-input-method-function
+                  isearch-input-method-function))
+             (setq unread-command-events
+                   (cons 'with-input-method
+                         (cons last-char unread-command-events))
+                   str (read-string prompt))
+             (if (not str)
+                 ;; All inputs were deleted while the input method
+                 ;; was working.
+                 (setq str "")
+               (if (and (= (length str) 1)
+                        (= (aref str 0) last-char))
+                   ;; The input method couldn't handle LAST-CHAR.
+                   (setq str nil)))))
+
+       (if (and (not str) (keyboard-coding-system))
+           (setq unread-command-events
+                 (cons 'with-keyboard-coding
+                       (cons last-char unread-command-events))
+                 str (read-string prompt)))
+
        (if (and str (> (length str) 0))
            (let ((unread-command-events nil))
              (isearch-process-search-string str str))