Mercurial > emacs
changeset 19432:4492653b04e8
(quail-exit-from-minibuffer): Call
inactivate-input-method instead of (quail-mode -1).
(quail-kill-guidance-buf): New function.
(quail-mode): Doc-string and comments modified. Make this
function non-interactive. Add quail-kill-guidance-buf to
kill-buffer-hook locally.
(quail-start-translation): Check if the current Quail package
requires keyboard tranlation feature.
(quail-start-translation-in-conversion-mode): Likewise.
(quail-terminate-translation): Run hooks in
input-method-after-insert-chunk-hook.
(quail-update-translation): Don't run hooks in
input-method-after-insert-chunk-hook here.
(quail-setup-completion-buf): New function.
(quail-show-guidance-buf): Create completion buffer by calling
quail-setup-completion-buf.
(quail-completion): Create completion buffer if it is not alive.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Tue, 19 Aug 1997 10:58:40 +0000 |
parents | 9c5fdc90d3c6 |
children | 8020b553a1db |
files | lisp/international/quail.el |
diffstat | 1 files changed, 44 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/international/quail.el Tue Aug 19 10:58:40 1997 +0000 +++ b/lisp/international/quail.el Tue Aug 19 10:58:40 1997 +0000 @@ -452,12 +452,21 @@ (if (overlayp quail-conv-overlay) (delete-overlay quail-conv-overlay))) +;; Kill Quail guidance buffer. Set in kill-buffer-hook. +(defun quail-kill-guidance-buf () + (if (buffer-live-p quail-guidance-buf) + (kill-buffer quail-guidance-buf))) + (defun quail-mode (&optional arg) "Toggle Quail minor mode. With arg, turn Quail mode on if and only if arg is positive. -Try \\[describe-bindings] in Quail mode to see the available key binding. + +You should not turn on and off Quail mode manually, instead use +the commands `toggle-input-method' or `select-input-methods' (which +see). They automatically turn on or off this mode. + +Try \\[describe-bindings] in Quail mode to see the available key bindings. The command \\[describe-input-method] describes the current Quail package." - (interactive "P") (setq quail-mode (if (null arg) (null quail-mode) (> (prefix-numeric-value arg) 0))) @@ -492,15 +501,18 @@ (setq describe-current-input-method-function 'quail-help) (quail-delete-overlays) (quail-show-guidance-buf) - ;; If we are in minibuffer, turn off Quail mode before exiting. + ;; If we are in minibuffer, turn off the current input method + ;; before exiting. (if (eq (selected-window) (minibuffer-window)) (add-hook 'minibuffer-exit-hook 'quail-exit-from-minibuffer)) (make-local-hook 'post-command-hook) + (make-local-hook 'kill-buffer-hook) + (add-hook 'kill-buffer-hook 'quail-kill-guidance-buf nil t) (run-hooks 'quail-mode-hook)) (force-mode-line-update)) (defun quail-exit-from-minibuffer () - (if quail-mode (quail-mode -1)) + (inactivate-input-method) (if (<= (minibuffer-depth) 1) (remove-hook 'minibuffer-exit-hook 'quail-exit-from-minibuffer))) @@ -879,7 +891,11 @@ (setq unread-command-events (cons last-command-event unread-command-events)) ;; Check the possibility of translating the last key. - (if (assq last-command-event (cdr (quail-map))) + (if (and (integerp last-command-event) + (assq (if (quail-kbd-translate) + (quail-keyboard-translate last-command-event) + last-command-event) + (cdr (quail-map)))) ;; Ok, we can start translation. (if (quail-conversion-keymap) ;; We must start translation in conversion mode. @@ -907,7 +923,11 @@ (setq unread-command-events (cons last-command-event unread-command-events)) ;; Check the possibility of translating the last key. - (if (assq last-command-event (cdr (quail-map))) + (if (and (integerp last-command-event) + (assq (if (quail-kbd-translate) + (quail-keyboard-translate last-command-event) + last-command-event) + (cdr (quail-map)))) ;; Ok, we can start translation. (progn (quail-setup-overlays t) @@ -927,7 +947,9 @@ (overlay-end quail-overlay)))) (defun quail-terminate-translation () - "Terminate the translation of the current key." + "Terminate the translation of the current key. +Optional arg SUPPRESS-INSERT-CHUNK-HOOK if non-nil means don't run hooks +in `input-method-after-insert-chunk-hook' (which see)." (let ((start (overlay-start quail-overlay))) (if (and start (< start (overlay-end quail-overlay))) @@ -954,7 +976,8 @@ (setq overriding-terminal-local-map (if (and (overlayp quail-conv-overlay) (overlay-start quail-conv-overlay)) - (quail-conversion-keymap)))) + (quail-conversion-keymap))) + (run-hooks 'input-method-after-insert-chunk-hook)) (defun quail-select-current () "Select the current text shown in Quail translation region." @@ -985,9 +1008,8 @@ (substring quail-current-key 0 len)))) (insert (or quail-current-str quail-current-key))))) (quail-update-guidance) - (when control-flag - (quail-terminate-translation) - (run-hooks 'input-method-after-insert-chunk-hook))) + (if control-flag + (quail-terminate-translation))) (defun quail-self-insert-command () "Add the typed character to the key for translation." @@ -1280,6 +1302,15 @@ (set-window-buffer win buf) (set-window-dedicated-p win t)))) +;; Setup Quail completion buffer. +(defun quail-setup-completion-buf () + (unless (buffer-live-p quail-completion-buf) + (setq quail-completion-buf (get-buffer-create "*Quail Completions*")) + (save-excursion + (set-buffer quail-completion-buf) + (setq quail-overlay (make-overlay 1 1)) + (overlay-put quail-overlay 'face 'highlight)))) + (defun quail-show-guidance-buf () "Display a guidance buffer for Quail input method in some window. Create the buffer if it does not exist yet. @@ -1334,13 +1365,7 @@ (setq quail-guidance-win win))) ;; And, create a buffer for completion. - (or (buffer-live-p quail-completion-buf) - (progn - (setq quail-completion-buf (get-buffer-create "*Quail Completions*")) - (save-excursion - (set-buffer quail-completion-buf) - (setq quail-overlay (make-overlay 1 1)) - (overlay-put quail-overlay 'face 'highlight)))) + (quail-setup-completion-buf) (bury-buffer quail-completion-buf)) (defun quail-hide-guidance-buf () @@ -1475,6 +1500,7 @@ All possible translations of the current key and whole possible longer keys are shown." (interactive) + (quail-setup-completion-buf) (let ((key quail-current-key) (map (quail-lookup-key quail-current-key))) (save-excursion