]> git.eshelyaron.com Git - emacs.git/commitdiff
(quail-conversion-keymap): New binding
authorKenichi Handa <handa@m17n.org>
Sun, 19 Jul 1998 05:17:35 +0000 (05:17 +0000)
committerKenichi Handa <handa@m17n.org>
Sun, 19 Jul 1998 05:17:35 +0000 (05:17 +0000)
for quail-conversion-delete-tail.
(quail-input-method): Suppress input method if
overriding-terminal-local-map or overriding-local-map is non-nil.
Erase contents of quail-guidance-buf.  Run the hook
input-method-after-insert-chunk-hook.
(quail-start-translation): Get the original event list by
listify-key-sequence.  Setup last-command and this-command
(quail-start-conversion): Likewise.
(quail-conversion-beginning-of-region): Set quail-translating to
nil.
(quail-conversion-end-of-region, quail-conversion-delete-char):
Likewise.
(quail-conversion-delete-tail): New function.
(quail-no-conversion): Don' run the hook
input-method-after-insert-chunk-hook.

lisp/international/quail.el

index cd830cca8bc414ec41ff453003a042693133b12b..d088ab94223947f7b39ba7cabf5e40f783b6a7d9 100644 (file)
@@ -300,6 +300,7 @@ This map is activated while translation region is active.")
     (define-key map "\C-a" 'quail-conversion-beginning-of-region)
     (define-key map "\C-e" 'quail-conversion-end-of-region)
     (define-key map "\C-d" 'quail-conversion-delete-char)
+    (define-key map "\C-k" 'quail-conversion-delete-tail)
     (define-key map "\C-h" 'quail-conversion-help)
     (define-key map "\177" 'quail-conversion-backward-delete-char)
     (define-key map [delete] 'quail-conversion-backward-delete-char)
@@ -855,9 +856,8 @@ The returned value is a Quail map specific to KEY."
 
 (defun quail-input-method (key)
   (if (or buffer-read-only
-         (and (or overriding-terminal-local-map
-                  overriding-local-map)
-              (>= key ?0) (<= key ?9)))
+         overriding-terminal-local-map
+         overriding-local-map)
       (list key)
     (quail-setup-overlays (quail-conversion-keymap))
     (let ((modified-p (buffer-modified-p)))
@@ -865,8 +865,17 @@ The returned value is a Quail map specific to KEY."
          (if (quail-conversion-keymap)
              (quail-start-conversion key)
            (quail-start-translation key))
+       (quail-delete-overlays)
+       (if (buffer-live-p quail-guidance-buf)
+           (save-excursion
+             (set-buffer quail-guidance-buf)
+             (erase-buffer)))
        (set-buffer-modified-p modified-p)
-       (quail-delete-overlays)))))
+       ;; Run this hook only when the current input method doesn't require
+       ;; conversion.  When conversion is required, the conversion function
+       ;; should run this hook at a proper timing.
+       (unless (quail-conversion-keymap)
+         (run-hooks 'input-method-after-insert-chunk-hook))))))
 
 (defun quail-overlay-region-events (overlay)
   (let ((start (overlay-start overlay))
@@ -894,16 +903,19 @@ The returned value is a Quail map specific to KEY."
        (while quail-translating
          (let* ((echo-keystrokes 0)
                 (keyseq (read-key-sequence nil))
-                (cmd (lookup-key translation-keymap keyseq t)))
+                (events (listify-key-sequence keyseq))
+                (cmd (lookup-key translation-keymap keyseq)))
            (if (commandp cmd)
                (progn
-                 (setq last-command-event (aref keyseq 0))
+                 (setq last-command-event (car (last events))
+                       last-command this-command
+                       this-command cmd)
                  (condition-case err
                      (call-interactively cmd)
                    (quail-error (message "%s" (cdr err)) (beep))))
              ;; KEYSEQ is not defined in the translation keymap.
              ;; Let's return the event(s) to the caller.
-             (setq generated-events (string-to-list keyseq)
+             (setq generated-events events
                    quail-translating nil))))
        (setq generated-events
              (append (quail-overlay-region-events quail-overlay)
@@ -938,16 +950,19 @@ The returned value is a Quail map specific to KEY."
                (quail-setup-overlays nil)))
          (let* ((echo-keystrokes 0)
                 (keyseq (read-key-sequence nil))
-                (cmd (lookup-key conversion-keymap keyseq t)))
+                (events (listify-key-sequence keyseq))
+                (cmd (lookup-key conversion-keymap keyseq)))
            (if (commandp cmd)
                (progn
-                 (setq last-command-event (aref keyseq 0))
+                 (setq last-command-event (car (last events))
+                       last-command this-command
+                       this-command cmd)
                  (condition-case err
                      (call-interactively cmd)
                    (quail-error (message "%s" (cdr err)) (beep))))
              ;; KEYSEQ is not defined in the conversion keymap.
              ;; Let's return the event(s) to the caller.
-             (setq generated-events (string-to-list keyseq)
+             (setq generated-events events
                    quail-converting nil))))
        (setq generated-events
              (append (quail-overlay-region-events quail-conv-overlay)
@@ -1265,14 +1280,17 @@ sequence counting from the head."
 
 (defun quail-conversion-beginning-of-region ()
   (interactive)
+  (setq quail-translating nil)
   (goto-char (overlay-start quail-conv-overlay)))
 
 (defun quail-conversion-end-of-region ()
   (interactive)
+  (setq quail-translating nil)
   (goto-char (overlay-end quail-conv-overlay)))
 
 (defun quail-conversion-delete-char ()
   (interactive)
+  (setq quail-translating nil)
   (if (>= (point) (overlay-end quail-conv-overlay))
       (quail-error "End of conversion region"))
   (delete-char 1)
@@ -1280,6 +1298,15 @@ sequence counting from the head."
         (overlay-end quail-conv-overlay))
       (setq quail-converting nil)))
 
+(defun quail-conversion-delete-tail ()
+  (interactive)
+  (if (>= (point) (overlay-end quail-conv-overlay))
+      (quail-error "End of conversion region"))
+  (delete-region (point) (overlay-end quail-conv-overlay))
+  (if (= (overlay-start quail-conv-overlay)
+        (overlay-end quail-conv-overlay))
+      (setq quail-converting nil)))
+
 (defun quail-conversion-backward-delete-char ()
   (interactive)
   (if (<= (point) (overlay-start quail-conv-overlay))
@@ -1298,8 +1325,7 @@ Remaining args are for FUNC."
 (defun quail-no-conversion ()
   "Do no conversion of the current conversion region of Quail."
   (interactive)
-  (setq quail-converting nil)
-  (run-hooks 'input-method-after-insert-chunk-hook))
+  (setq quail-converting nil))
 
 ;; Guidance, Completion, and Help buffer handlers.