Mercurial > emacs
comparison lisp/international/quail.el @ 22765:7cf2c3800e8f
(quail-mode): This variable deleted.
(quail-current-key): Make it buffer local.
(quail-current-str, quail-current-translations): Likewise.
(quail-reset-conversion-region): This variable deleted.
(quail-use-package): Call quail-activate at the tail.
(quail-translation-keymap, quail-simple-translation-keymap): Key
bindings for quail-execute-non-quail-command deleted.
(quail-conversion-keymap): Likewise. Add key bindings for
quail-self-insert-command.
(quail-delete-overlays): Chekc overlay-start for overlays before
deleting them.
(quail-mode): This function deleted.
(quail-inactivate, quail-activate): New functions.
(quail-saved-current-map, quail-saved-current-buffer): These
variables deleted.
(quail-toggle-mode-temporarily, quail-execute-non-quail-command):
These functions deleted.
(quail-exit-conversion-mode, quail-prefix-arg): These variables
deleted.
(quail-error): New error condition.
(quail-error): New function.
(quail-translating, quail-converting): New variables.
(quail-input-method, quail-overlay-region-events): New function.
(quail-start-translation): Completely re-written.
(quail-start-translation-in-conversion-mode): This function
deleted.
(quail-start-conversion): New function.
(quail-terminate-translation): Just set quail-translating to nil.
(quail-update-translation): Put some events back to
unread-input-method-events instead of unread-command-events. Call
quail-error instead of error.
(quail-self-insert-command): Adjusted for the change of
quail-start-translation.
(quail-next-translation): Don't call
quail-execute-non-quail-command, instead, put an event back of
unread-command-events.
(quail-prev-translation, quail-next-translation-block,
quail-prev-translation-block): Likewize.
(quail-conversion-backward-char): Call quail-error instead of
error. Set quail-translating to nil.
(quail-conversion-forward-char): Likewize.
(quail-conversion-delete-char): Call quail-error instead of error.
If conversion region gets vacant, set quail-converting to nil.
(quail-conversion-backward-delete-char): Likewize.
(quail-no-conversion): Just set quail-converting to nil.
(quail-mouse-choose-completion): Call quai-error instead of error.
(quail-choose-completion-string): Likewize.
(quail-help): Don't handle quail-mode-map.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Thu, 16 Jul 1998 00:14:44 +0000 |
parents | 10b3c1cd7f18 |
children | 1b0761cbc15b |
comparison
equal
deleted
inserted
replaced
22764:8543c4052dd2 | 22765:7cf2c3800e8f |
---|---|
66 | 66 |
67 ;; A main window showing Quail guidance buffer. | 67 ;; A main window showing Quail guidance buffer. |
68 (defvar quail-guidance-win nil) | 68 (defvar quail-guidance-win nil) |
69 (make-variable-buffer-local 'quail-guidance-win) | 69 (make-variable-buffer-local 'quail-guidance-win) |
70 | 70 |
71 (defvar quail-mode nil | |
72 "Non-nil if in Quail minor mode.") | |
73 (make-variable-buffer-local 'quail-mode) | |
74 (put 'quail-mode 'permanent-local t) | |
75 | |
76 (defvar quail-overlay nil | 71 (defvar quail-overlay nil |
77 "Overlay which covers the current translation region of Quail.") | 72 "Overlay which covers the current translation region of Quail.") |
78 (make-variable-buffer-local 'quail-overlay) | 73 (make-variable-buffer-local 'quail-overlay) |
79 | 74 |
80 (defvar quail-conv-overlay nil | 75 (defvar quail-conv-overlay nil |
81 "Overlay which covers the text to be converted in Quail mode.") | 76 "Overlay which covers the text to be converted in Quail mode.") |
82 (make-variable-buffer-local 'quail-conv-overlay) | 77 (make-variable-buffer-local 'quail-conv-overlay) |
83 | 78 |
84 (defvar quail-current-key nil | 79 (defvar quail-current-key nil |
85 "Current key for translation in Quail mode.") | 80 "Current key for translation in Quail mode.") |
81 (make-variable-buffer-local 'quail-current-key) | |
86 | 82 |
87 (defvar quail-current-str nil | 83 (defvar quail-current-str nil |
88 "Currently selected translation of the current key.") | 84 "Currently selected translation of the current key.") |
85 (make-variable-buffer-local 'quail-current-str) | |
89 | 86 |
90 (defvar quail-current-translations nil | 87 (defvar quail-current-translations nil |
91 "Cons of indices and vector of possible translations of the current key. | 88 "Cons of indices and vector of possible translations of the current key. |
92 Indices is a list of (CURRENT START END BLOCK BLOCKS), where | 89 Indices is a list of (CURRENT START END BLOCK BLOCKS), where |
93 CURRENT is an index of the current translation, | 90 CURRENT is an index of the current translation, |
94 START and END are indices of the start and end of the current block, | 91 START and END are indices of the start and end of the current block, |
95 BLOCK is the current block index, | 92 BLOCK is the current block index, |
96 BLOCKS is a number of blocks of translation.") | 93 BLOCKS is a number of blocks of translation.") |
94 (make-variable-buffer-local 'quail-current-translations) | |
97 | 95 |
98 (defvar quail-current-data nil | 96 (defvar quail-current-data nil |
99 "Any Lisp object holding information of current translation status. | 97 "Any Lisp object holding information of current translation status. |
100 When a key sequence is mapped to TRANS and TRANS is a cons | 98 When a key sequence is mapped to TRANS and TRANS is a cons |
101 of actual translation and some Lisp object to be refered | 99 of actual translation and some Lisp object to be refered |
102 for translating the longer key sequence, this variable is set | 100 for translating the longer key sequence, this variable is set |
103 to that Lisp object.") | 101 to that Lisp object.") |
104 (make-variable-buffer-local 'quail-current-data) | 102 (make-variable-buffer-local 'quail-current-data) |
105 | |
106 ;; A flag to control conversion region. Normally nil, but if set to | |
107 ;; t, it means we must start the new conversion region if new key to | |
108 ;; be translated is input. | |
109 (defvar quail-reset-conversion-region nil) | |
110 | 103 |
111 ;; Quail package handlers. | 104 ;; Quail package handlers. |
112 | 105 |
113 (defvar quail-package-alist nil | 106 (defvar quail-package-alist nil |
114 "List of Quail packages. | 107 "List of Quail packages. |
230 LEIM is available from the same ftp directory as Emacs.")) | 223 LEIM is available from the same ftp directory as Emacs.")) |
231 (error "Can't use the Quail package `%s'" package-name)) | 224 (error "Can't use the Quail package `%s'" package-name)) |
232 (setq libraries (cdr libraries)))))) | 225 (setq libraries (cdr libraries)))))) |
233 (quail-select-package package-name) | 226 (quail-select-package package-name) |
234 (setq current-input-method-title (quail-title)) | 227 (setq current-input-method-title (quail-title)) |
235 (quail-mode 1)) | 228 (quail-activate)) |
236 | 229 |
237 (defun quail-inactivate () | 230 (defconst quail-translation-keymap |
238 "Turn off Quail input method." | |
239 (interactive) | |
240 (setq overriding-terminal-local-map nil) | |
241 (quail-mode -1)) | |
242 | |
243 (or (assq 'quail-mode minor-mode-alist) | |
244 (setq minor-mode-alist | |
245 (cons '(quail-mode " Quail") minor-mode-alist))) | |
246 | |
247 (defvar quail-mode-map | |
248 (let ((map (make-keymap)) | 231 (let ((map (make-keymap)) |
249 (i ? )) | 232 (i ?\ )) |
250 (while (< i 127) | |
251 (define-key map (char-to-string i) 'quail-start-translation) | |
252 (setq i (1+ i))) | |
253 (setq i 128) | |
254 (while (< i 256) | |
255 (define-key map (vector i) 'quail-start-translation) | |
256 (setq i (1+ i))) | |
257 map) | |
258 "Keymap for Quail mode.") | |
259 | |
260 (or (assq 'quail-mode minor-mode-map-alist) | |
261 (setq minor-mode-map-alist | |
262 (cons (cons 'quail-mode quail-mode-map) minor-mode-map-alist))) | |
263 | |
264 ;; Since some Emacs Lisp programs (e.g. viper.el) make | |
265 ;; minor-mode-map-alist buffer-local, we must be sure to register | |
266 ;; quail-mode-map in default-value of minor-mode-map-alist. | |
267 (if (local-variable-p 'minor-mode-map-alist) | |
268 (let ((map (default-value 'minor-mode-map-alist))) | |
269 (or (assq 'quail-mode map) | |
270 (set-default 'minor-mode-map-alist (cons 'quail-mode map))))) | |
271 | |
272 (defvar quail-translation-keymap | |
273 (let ((map (make-keymap)) | |
274 (i 0)) | |
275 (while (< i ?\ ) | |
276 (define-key map (char-to-string i) 'quail-execute-non-quail-command) | |
277 (setq i (1+ i))) | |
278 (while (< i 127) | 233 (while (< i 127) |
279 (define-key map (char-to-string i) 'quail-self-insert-command) | 234 (define-key map (char-to-string i) 'quail-self-insert-command) |
280 (setq i (1+ i))) | 235 (setq i (1+ i))) |
281 (setq i 128) | 236 (setq i 128) |
282 (while (< i 256) | 237 (while (< i 256) |
298 ;; any completion visible in the *Quail Completions* buffer. | 253 ;; any completion visible in the *Quail Completions* buffer. |
299 (define-key map [kp-enter] 'quail-select-current) | 254 (define-key map [kp-enter] 'quail-select-current) |
300 (define-key map [mouse-2] 'quail-mouse-choose-completion) | 255 (define-key map [mouse-2] 'quail-mouse-choose-completion) |
301 (define-key map [down-mouse-2] nil) | 256 (define-key map [down-mouse-2] nil) |
302 (define-key map "\C-h" 'quail-translation-help) | 257 (define-key map "\C-h" 'quail-translation-help) |
303 ;;; This interferes with handling of escape sequences on non-X terminals. | |
304 ;;; (define-key map "\e" '(keymap (t . quail-execute-non-quail-command))) | |
305 (define-key map [?\C- ] 'quail-select-current) | 258 (define-key map [?\C- ] 'quail-select-current) |
306 (define-key map [tab] 'quail-completion) | 259 (define-key map [tab] 'quail-completion) |
307 (define-key map [delete] 'quail-delete-last-char) | 260 (define-key map [delete] 'quail-delete-last-char) |
308 (define-key map [backspace] 'quail-delete-last-char) | 261 (define-key map [backspace] 'quail-delete-last-char) |
309 (let ((meta-map (make-sparse-keymap))) | 262 (let ((meta-map (make-sparse-keymap))) |
310 (define-key map (char-to-string meta-prefix-char) meta-map) | 263 (define-key map (char-to-string meta-prefix-char) meta-map) |
311 (define-key map [escape] meta-map)) | 264 (define-key map [escape] meta-map)) |
312 (define-key map (vector meta-prefix-char t) | |
313 'quail-execute-non-quail-command) | |
314 ;; At last, define default key binding. | |
315 (define-key map [t] 'quail-execute-non-quail-command) | |
316 map) | 265 map) |
317 "Keymap used processing translation in complex Quail modes. | 266 "Keymap used processing translation in complex Quail modes. |
318 Only a few especially complex input methods use this map; | 267 Only a few especially complex input methods use this map; |
319 most use `quail-simple-translation-keymap' instead. | 268 most use `quail-simple-translation-keymap' instead. |
320 This map is activated while translation region is active.") | 269 This map is activated while translation region is active.") |
321 | 270 |
322 (defvar quail-simple-translation-keymap | 271 (defconst quail-simple-translation-keymap |
323 (let ((map (make-keymap)) | 272 (let ((map (make-keymap)) |
324 (i 0)) | 273 (i ?\ )) |
325 (while (< i ?\ ) | |
326 (define-key map (char-to-string i) 'quail-execute-non-quail-command) | |
327 (setq i (1+ i))) | |
328 (while (< i 127) | 274 (while (< i 127) |
329 (define-key map (char-to-string i) 'quail-self-insert-command) | 275 (define-key map (char-to-string i) 'quail-self-insert-command) |
330 (setq i (1+ i))) | 276 (setq i (1+ i))) |
331 (define-key map "\177" 'quail-delete-last-char) | 277 (define-key map "\177" 'quail-delete-last-char) |
332 (define-key map [delete] 'quail-delete-last-char) | 278 (define-key map [delete] 'quail-delete-last-char) |
333 (define-key map [backspace] 'quail-delete-last-char) | 279 (define-key map [backspace] 'quail-delete-last-char) |
334 ;;; This interferes with handling of escape sequences on non-X terminals. | |
335 ;;; (define-key map "\e" '(keymap (t . quail-execute-non-quail-command))) | |
336 (let ((meta-map (make-sparse-keymap))) | 280 (let ((meta-map (make-sparse-keymap))) |
337 (define-key map (char-to-string meta-prefix-char) meta-map) | 281 (define-key map (char-to-string meta-prefix-char) meta-map) |
338 (define-key map [escape] meta-map)) | 282 (define-key map [escape] meta-map)) |
339 (define-key map (vector meta-prefix-char t) | |
340 'quail-execute-non-quail-command) | |
341 ;; At last, define default key binding. | |
342 (define-key map [t] | |
343 'quail-execute-non-quail-command) | |
344 map) | 283 map) |
345 "Keymap used while processing translation in simple Quail modes. | 284 "Keymap used while processing translation in simple Quail modes. |
346 A few especially complex input methods use `quail--translation-keymap' instead. | 285 A few especially complex input methods use `quail--translation-keymap' instead. |
347 This map is activated while translation region is active.") | 286 This map is activated while translation region is active.") |
348 | 287 |
349 (defvar quail-conversion-keymap | 288 (defconst quail-conversion-keymap |
350 (let ((map (make-keymap)) | 289 (let ((map (make-keymap)) |
351 (i 0)) | 290 (i ?\ )) |
352 (while (< i ?\ ) | |
353 (define-key map (char-to-string i) 'quail-execute-non-quail-command) | |
354 (setq i (1+ i))) | |
355 (while (< i 127) | 291 (while (< i 127) |
356 (define-key map (char-to-string i) | 292 (define-key map (char-to-string i) 'quail-self-insert-command) |
357 'quail-start-translation-in-conversion-mode) | |
358 (setq i (1+ i))) | 293 (setq i (1+ i))) |
359 (setq i 128) | 294 (setq i 128) |
360 (while (< i 256) | 295 (while (< i 256) |
361 (define-key map (vector i) 'quail-start-translation-in-conversion-mode) | 296 (define-key map (vector i) 'quail-self-insert-command) |
362 (setq i (1+ i))) | 297 (setq i (1+ i))) |
363 (define-key map "\C-b" 'quail-conversion-backward-char) | 298 (define-key map "\C-b" 'quail-conversion-backward-char) |
364 (define-key map "\C-f" 'quail-conversion-forward-char) | 299 (define-key map "\C-f" 'quail-conversion-forward-char) |
365 (define-key map "\C-a" 'quail-conversion-beginning-of-region) | 300 (define-key map "\C-a" 'quail-conversion-beginning-of-region) |
366 (define-key map "\C-e" 'quail-conversion-end-of-region) | 301 (define-key map "\C-e" 'quail-conversion-end-of-region) |
367 (define-key map "\C-d" 'quail-conversion-delete-char) | 302 (define-key map "\C-d" 'quail-conversion-delete-char) |
368 (define-key map "\C-h" 'quail-conversion-help) | 303 (define-key map "\C-h" 'quail-conversion-help) |
369 ;;; This interferes with handling of escape sequences on non-X terminals. | |
370 ;;; (define-key map "\e" '(keymap (t . quail-execute-non-quail-command))) | |
371 (define-key map "\177" 'quail-conversion-backward-delete-char) | 304 (define-key map "\177" 'quail-conversion-backward-delete-char) |
372 (define-key map [delete] 'quail-conversion-backward-delete-char) | 305 (define-key map [delete] 'quail-conversion-backward-delete-char) |
373 (define-key map [backspace] 'quail-conversion-backward-delete-char) | 306 (define-key map [backspace] 'quail-conversion-backward-delete-char) |
374 (let ((meta-map (make-sparse-keymap))) | |
375 (define-key map (char-to-string meta-prefix-char) meta-map) | |
376 (define-key map [escape] meta-map)) | |
377 (define-key map (vector meta-prefix-char t) | |
378 'quail-execute-non-quail-command) | |
379 ;; At last, define default key binding. | |
380 (define-key map [t] 'quail-execute-non-quail-command) | |
381 map) | 307 map) |
382 "Keymap used for processing conversion in Quail mode. | 308 "Keymap used for processing conversion in Quail mode. |
383 This map is activated while convesion region is active but translation | 309 This map is activated while convesion region is active but translation |
384 region is not active.") | 310 region is not active.") |
385 | 311 |
521 (if input-method-highlight-flag | 447 (if input-method-highlight-flag |
522 (overlay-put quail-conv-overlay 'face 'underline)))))) | 448 (overlay-put quail-conv-overlay 'face 'underline)))))) |
523 | 449 |
524 ;; Delete overlays used in Quail mode. | 450 ;; Delete overlays used in Quail mode. |
525 (defun quail-delete-overlays () | 451 (defun quail-delete-overlays () |
526 (if (overlayp quail-overlay) | 452 (if (and (overlayp quail-overlay) (overlay-start quail-overlay)) |
527 (delete-overlay quail-overlay)) | 453 (delete-overlay quail-overlay)) |
528 (if (overlayp quail-conv-overlay) | 454 (if (and (overlayp quail-conv-overlay) (overlay-start quail-conv-overlay)) |
529 (delete-overlay quail-conv-overlay))) | 455 (delete-overlay quail-conv-overlay))) |
530 | 456 |
531 ;; Kill Quail guidance buffer. Set in kill-buffer-hook. | 457 ;; Kill Quail guidance buffer. Set in kill-buffer-hook. |
532 (defun quail-kill-guidance-buf () | 458 (defun quail-kill-guidance-buf () |
533 (if (buffer-live-p quail-guidance-buf) | 459 (if (buffer-live-p quail-guidance-buf) |
534 (kill-buffer quail-guidance-buf))) | 460 (kill-buffer quail-guidance-buf))) |
535 | 461 |
536 (defun quail-mode (&optional arg) | 462 (defun quail-inactivate () |
537 "Toggle Quail minor mode. | 463 "Inactivate Quail input method." |
538 With arg, turn Quail mode on if and only if arg is positive. | 464 (interactive) |
539 | 465 (quail-activate -1)) |
540 In Quail mode, all printable characters are bound to | 466 |
541 `quail-start-translation'. This function checks if the current input | 467 (defun quail-activate (&optional arg) |
542 method will translate the last input key. If not, the key is handled | 468 "Activate Quail input method. |
543 out of Quail mode, i.e, in another activated minor mode or in the | 469 With arg, activate Quail input method if and only if arg is positive. |
544 current major mode. | 470 |
545 \\{quail-mode-map} | 471 While this input method is active, the variable |
546 Unlike the other minor modes, this is not an interactive function. | 472 `input-method-function' is bound to the function `quail-input-method'." |
547 Use the commands \\[toggle-input-method] (`toggle-input-method') or | 473 (if (and arg |
548 \\[set-input-method] (`set-input-method') which automatically turn on | 474 (< (prefix-numeric-value arg) 0)) |
549 Quail mode with an appropriate Quail package, or turn it off." | 475 ;; Let's inactivate Quail input method. |
550 (setq quail-mode | 476 (unwind-protect |
551 (if (null arg) (null quail-mode) | 477 (progn |
552 (> (prefix-numeric-value arg) 0))) | 478 (quail-hide-guidance-buf) |
553 (if (null quail-mode) | 479 (quail-delete-overlays) |
554 ;; Let's turn off Quail mode. | 480 (setq describe-current-input-method-function nil) |
555 (progn | 481 (run-hooks 'quail-inactivate-hook)) |
556 (quail-hide-guidance-buf) | 482 (kill-local-variable 'input-method-function)) |
557 (quail-delete-overlays) | 483 ;; Let's active Quail input method. |
558 (setq describe-current-input-method-function nil) | |
559 (run-hooks 'quail-mode-exit-hook)) | |
560 ;; Let's turn on Quail mode. | |
561 ;; At first, be sure that quail-mode is at the first element of | |
562 ;; minor-mode-map-alist. | |
563 (or (eq (car minor-mode-map-alist) 'quail-mode) | |
564 (let ((l minor-mode-map-alist)) | |
565 (while (cdr l) | |
566 (if (eq (car (cdr l)) 'quail-mode) | |
567 (progn | |
568 (setcdr l (cdr (cdr l))) | |
569 (setq l nil)) | |
570 (setq l (cdr l)))) | |
571 (setq minor-mode-map-alist (cons 'quail-mode minor-mode-map-alist)))) | |
572 (if (null quail-current-package) | 484 (if (null quail-current-package) |
573 ;; Quail package is not yet selected. Select one now. | 485 ;; Quail package is not yet selected. Select one now. |
574 (let (name) | 486 (let (name) |
575 (if quail-package-alist | 487 (if quail-package-alist |
576 (setq name (car (car quail-package-alist))) | 488 (setq name (car (car quail-package-alist))) |
577 (setq quail-mode nil) | |
578 (error "No Quail package loaded")) | 489 (error "No Quail package loaded")) |
579 (quail-select-package name))) | 490 (quail-select-package name))) |
580 (setq inactivate-current-input-method-function 'quail-inactivate) | 491 (setq inactivate-current-input-method-function 'quail-inactivate) |
581 (setq describe-current-input-method-function 'quail-help) | 492 (setq describe-current-input-method-function 'quail-help) |
582 (quail-delete-overlays) | 493 (quail-delete-overlays) |
583 (quail-show-guidance-buf) | 494 (quail-show-guidance-buf) |
584 ;; If we are in minibuffer, turn off the current input method | 495 ;; If we are in minibuffer, turn off the current input method |
585 ;; before exiting. | 496 ;; before exiting. |
586 (if (eq (selected-window) (minibuffer-window)) | 497 (if (eq (selected-window) (minibuffer-window)) |
587 (add-hook 'minibuffer-exit-hook 'quail-exit-from-minibuffer)) | 498 (add-hook 'minibuffer-exit-hook 'quail-exit-from-minibuffer)) |
588 (make-local-hook 'post-command-hook) | |
589 (make-local-hook 'kill-buffer-hook) | 499 (make-local-hook 'kill-buffer-hook) |
590 (add-hook 'kill-buffer-hook 'quail-kill-guidance-buf nil t) | 500 (add-hook 'kill-buffer-hook 'quail-kill-guidance-buf nil t) |
591 (run-hooks 'quail-mode-hook)) | 501 (run-hooks 'quail-activate-hook) |
592 (force-mode-line-update)) | 502 (make-local-variable 'input-method-function) |
503 (setq input-method-function 'quail-input-method))) | |
593 | 504 |
594 (defun quail-exit-from-minibuffer () | 505 (defun quail-exit-from-minibuffer () |
595 (inactivate-input-method) | 506 (inactivate-input-method) |
596 (if (<= (minibuffer-depth) 1) | 507 (if (<= (minibuffer-depth) 1) |
597 (remove-hook 'minibuffer-exit-hook 'quail-exit-from-minibuffer))) | 508 (remove-hook 'minibuffer-exit-hook 'quail-exit-from-minibuffer))) |
598 | |
599 (defvar quail-saved-current-map nil) | |
600 (defvar quail-saved-current-buffer nil) | |
601 | |
602 ;; Toggle Quail mode. This function is added to `post-command-hook' | |
603 ;; in Quail mode, to turn Quail mode temporarily off, or back on after | |
604 ;; one non-Quail command. | |
605 (defun quail-toggle-mode-temporarily () | |
606 (if quail-mode | |
607 ;; We are going to handle following events out of Quail mode. | |
608 (setq quail-saved-current-buffer (current-buffer) | |
609 quail-saved-current-map overriding-terminal-local-map | |
610 quail-mode nil | |
611 overriding-terminal-local-map nil) | |
612 ;; We have just executed one non-Quail command. We don't need | |
613 ;; this hook any more. | |
614 (remove-hook 'post-command-hook 'quail-toggle-mode-temporarily t) | |
615 (if (eq (current-buffer) quail-saved-current-buffer) | |
616 ;; We should go back to Quail mode only when the current input | |
617 ;; method was not turned off by the last command. | |
618 (when current-input-method | |
619 (setq quail-mode t | |
620 overriding-terminal-local-map quail-saved-current-map) | |
621 (if input-method-exit-on-invalid-key | |
622 (inactivate-input-method))) | |
623 ;; The last command changed the current buffer, we should not go | |
624 ;; back to Quail mode in this new buffer, but should turn on | |
625 ;; Quail mode in the original buffer. | |
626 (save-excursion | |
627 (set-buffer quail-saved-current-buffer) | |
628 (setq quail-mode t) | |
629 (quail-delete-overlays))))) | |
630 | |
631 (defun quail-execute-non-quail-command () | |
632 "Execute one non-Quail command out of Quail mode. | |
633 The current translation and conversion are terminated." | |
634 (interactive) | |
635 (let* ((key (this-command-keys)) | |
636 (keylist (listify-key-sequence key))) | |
637 (setq unread-command-events (append keylist unread-command-events))) | |
638 (reset-this-command-lengths) | |
639 (quail-terminate-translation) | |
640 (quail-delete-overlays) | |
641 (setq overriding-terminal-local-map nil) | |
642 (if (buffer-live-p quail-guidance-buf) | |
643 (save-excursion | |
644 (set-buffer quail-guidance-buf) | |
645 (erase-buffer))) | |
646 (add-hook 'post-command-hook 'quail-toggle-mode-temporarily nil t)) | |
647 | 509 |
648 ;; Keyboard layout translation handlers. | 510 ;; Keyboard layout translation handlers. |
649 | 511 |
650 ;; Some Quail packages provide localized keyboard simulation which | 512 ;; Some Quail packages provide localized keyboard simulation which |
651 ;; requires a particular keyboard layout. In this case, what we need | 513 ;; requires a particular keyboard layout. In this case, what we need |
982 (progn | 844 (progn |
983 (setcdr map (funcall (cdr map) key len)))) | 845 (setcdr map (funcall (cdr map) key len)))) |
984 )) | 846 )) |
985 map)) | 847 map)) |
986 | 848 |
987 ;; If set to non-nil, exit conversion mode before starting new translation. | 849 (put 'quail-error 'error-conditions '(quail-error error)) |
988 (defvar quail-exit-conversion-mode nil) | 850 (defun quail-error (&rest args) |
989 | 851 (signal 'quail-error (apply 'format args))) |
990 (defvar quail-prefix-arg nil) | 852 |
991 | 853 (defvar quail-translating nil) |
992 (defun quail-start-translation (arg) | 854 (defvar quail-converting nil) |
993 "Start translating the typed character in Quail mode." | 855 |
994 (interactive "*p") | 856 (defun quail-input-method (key) |
995 (setq prefix-arg current-prefix-arg) | 857 (if (or buffer-read-only |
996 (setq quail-prefix-arg arg) | 858 (and (or overriding-terminal-local-map |
997 (setq unread-command-events | 859 overriding-local-map) |
998 (cons last-command-event unread-command-events)) | 860 (>= key ?0) (<= key ?9))) |
999 ;; Check the possibility of translating the last key. | 861 (list key) |
1000 (if (and (integerp last-command-event) | 862 (quail-setup-overlays (quail-conversion-keymap)) |
1001 (assq (if (quail-kbd-translate) | 863 (let ((modified-p (buffer-modified-p))) |
1002 (quail-keyboard-translate last-command-event) | 864 (unwind-protect |
1003 last-command-event) | 865 (if (quail-conversion-keymap) |
866 (quail-start-conversion key) | |
867 (quail-start-translation key)) | |
868 (set-buffer-modified-p modified-p) | |
869 (quail-delete-overlays))))) | |
870 | |
871 (defun quail-overlay-region-events (overlay) | |
872 (let ((start (overlay-start overlay)) | |
873 (end (overlay-end overlay))) | |
874 (if (< start end) | |
875 (prog1 | |
876 (string-to-list (buffer-substring start end)) | |
877 (delete-region start end))))) | |
878 | |
879 (defun quail-start-translation (key) | |
880 "Start translation of the typed character KEY by the current Quail package." | |
881 ;; Check the possibility of translating KEY. | |
882 (if (and (integerp key) | |
883 (assq (if (quail-kbd-translate) (quail-keyboard-translate key) key) | |
1004 (cdr (quail-map)))) | 884 (cdr (quail-map)))) |
1005 ;; Ok, we can start translation. | 885 ;; Ok, we can start translation. |
1006 (if (quail-conversion-keymap) | 886 (let* ((translation-keymap (quail-translation-keymap)) |
1007 ;; We must start translation in conversion mode. | 887 (overriding-terminal-local-map translation-keymap) |
1008 (setq quail-exit-conversion-mode nil | 888 (generated-events nil) |
1009 overriding-terminal-local-map (quail-conversion-keymap)) | 889 (input-method-function nil)) |
1010 (quail-setup-overlays nil) | 890 (setq quail-current-key "" |
1011 (setq quail-current-key "") | 891 quail-current-str nil |
1012 (setq overriding-terminal-local-map (quail-translation-keymap))) | 892 quail-translating t |
1013 ;; Since the last event doesn't start any translation, handle it | 893 unread-command-events (cons key unread-command-events)) |
1014 ;; out of Quail mode. We come back to Quail mode later by setting | 894 (while quail-translating |
1015 ;; function `quail-toggle-mode-temporarily' in | 895 (let* ((echo-keystrokes 0) |
1016 ;; `post-command-hook'. | 896 (keyseq (read-key-sequence nil)) |
1017 (add-hook 'post-command-hook 'quail-toggle-mode-temporarily nil t))) | 897 (cmd (lookup-key translation-keymap keyseq t))) |
1018 | 898 (if (commandp cmd) |
1019 (defsubst quail-point-in-conversion-region () | 899 (progn |
1020 "Return non-nil value if the point is in conversion region of Quail mode." | 900 (setq last-command-event (aref keyseq 0)) |
1021 (let (start pos) | 901 (condition-case err |
1022 (and (setq start (overlay-start quail-conv-overlay)) | 902 (call-interactively cmd) |
1023 (>= (setq pos (point)) start) | 903 (quail-error (message "%s" (cdr err)) (beep)))) |
1024 (<= pos (overlay-end quail-conv-overlay))))) | 904 ;; KEYSEQ is not defined in the translation keymap. |
1025 | 905 ;; Let's return the event(s) to the caller. |
1026 (defun quail-start-translation-in-conversion-mode () | 906 (setq generated-events (string-to-list keyseq) |
1027 "Start translating the typed character in conversion mode of Quail mode." | 907 quail-translating nil)))) |
1028 (interactive "*") | 908 (setq generated-events |
1029 (setq unread-command-events | 909 (append (quail-overlay-region-events quail-overlay) |
1030 (cons last-command-event unread-command-events)) | 910 generated-events)) |
1031 ;; Check the possibility of translating the last key. | 911 generated-events) |
1032 (if (and (integerp last-command-event) | 912 |
1033 (assq (if (quail-kbd-translate) | 913 ;; Since KEY doesn't start any translation, just return it. |
1034 (quail-keyboard-translate last-command-event) | 914 (list key))) |
1035 last-command-event) | 915 |
916 (defun quail-start-conversion (key) | |
917 "Start conversion of the typed character KEY by the current Quail package." | |
918 ;; Check the possibility of translating KEY. | |
919 (if (and (integerp key) | |
920 (assq (if (quail-kbd-translate) (quail-keyboard-translate key) key) | |
1036 (cdr (quail-map)))) | 921 (cdr (quail-map)))) |
1037 ;; Ok, we can start translation. | 922 ;; Ok, we can start translation and conversion. |
1038 (progn | 923 (let* ((conversion-keymap (quail-conversion-keymap)) |
1039 (quail-setup-overlays t) | 924 (overriding-terminal-local-map conversion-keymap) |
1040 (setq quail-current-key "") | 925 (generated-events nil) |
1041 (setq overriding-terminal-local-map (quail-translation-keymap)) | 926 (input-method-function nil)) |
1042 (move-overlay quail-overlay (point) (point))) | 927 (setq quail-current-key "" |
1043 ;; Since the last event doesn't start any translation, handle it | 928 quail-current-str nil |
1044 ;; out of Quail mode. We come back to Quail mode later by setting | 929 quail-converting t |
1045 ;; function `quail-toggle-mode-temporarily' in | 930 quail-translating t |
1046 ;; `post-command-hook'. | 931 unread-command-events (cons key unread-command-events)) |
1047 (add-hook 'post-command-hook 'quail-toggle-mode-temporarily nil t))) | 932 (while quail-converting |
933 (or quail-translating | |
934 (progn | |
935 (setq quail-current-key "" | |
936 quail-current-str nil | |
937 quail-translating t) | |
938 (quail-setup-overlays nil))) | |
939 (let* ((echo-keystrokes 0) | |
940 (keyseq (read-key-sequence nil)) | |
941 (cmd (lookup-key conversion-keymap keyseq t))) | |
942 (if (commandp cmd) | |
943 (progn | |
944 (setq last-command-event (aref keyseq 0)) | |
945 (condition-case err | |
946 (call-interactively cmd) | |
947 (quail-error (message "%s" (cdr err)) (beep)))) | |
948 ;; KEYSEQ is not defined in the conversion keymap. | |
949 ;; Let's return the event(s) to the caller. | |
950 (setq generated-events (string-to-list keyseq) | |
951 quail-converting nil)))) | |
952 (setq generated-events | |
953 (append (quail-overlay-region-events quail-conv-overlay) | |
954 generated-events)) | |
955 generated-events) | |
956 | |
957 ;; Since KEY doesn't start any translation, just return it. | |
958 (list key))) | |
1048 | 959 |
1049 (defsubst quail-delete-region () | 960 (defsubst quail-delete-region () |
1050 "Delete the text in the current translation region of Quail." | 961 "Delete the text in the current translation region of Quail." |
1051 (if (overlay-start quail-overlay) | 962 (if (overlay-start quail-overlay) |
1052 (delete-region (overlay-start quail-overlay) | 963 (delete-region (overlay-start quail-overlay) |
1053 (overlay-end quail-overlay)))) | 964 (overlay-end quail-overlay)))) |
1054 | 965 |
1055 (defun quail-terminate-translation () | 966 (defun quail-terminate-translation () |
1056 "Terminate the translation of the current key." | 967 "Terminate the translation of the current key." |
1057 (when (overlayp quail-overlay) | 968 (setq quail-translating nil) |
1058 (let ((start (overlay-start quail-overlay))) | |
1059 (if (and start | |
1060 (< start (overlay-end quail-overlay))) | |
1061 ;; Here we simulate self-insert-command. | |
1062 (let ((seq (string-to-sequence | |
1063 (buffer-substring (overlay-start quail-overlay) | |
1064 (overlay-end quail-overlay)) | |
1065 'list)) | |
1066 last-command-char) | |
1067 (goto-char start) | |
1068 (quail-delete-region) | |
1069 (setq last-command-char (car seq)) | |
1070 (self-insert-command (or quail-prefix-arg 1)) | |
1071 (setq quail-prefix-arg nil) | |
1072 (setq seq (cdr seq)) | |
1073 (while seq | |
1074 (setq last-command-char (car seq)) | |
1075 (self-insert-command 1) | |
1076 (setq seq (cdr seq)))))) | |
1077 (delete-overlay quail-overlay)) | |
1078 (if (buffer-live-p quail-guidance-buf) | 969 (if (buffer-live-p quail-guidance-buf) |
1079 (save-excursion | 970 (save-excursion |
1080 (set-buffer quail-guidance-buf) | 971 (set-buffer quail-guidance-buf) |
1081 (erase-buffer))) | 972 (erase-buffer)))) |
1082 (setq overriding-terminal-local-map | |
1083 (quail-conversion-keymap)) | |
1084 ;; Run this hook only when the current input method doesn't require | |
1085 ;; conversion. When conversion is required, the conversion function | |
1086 ;; should run this hook at a proper timing. | |
1087 (unless (quail-conversion-keymap) | |
1088 (run-hooks 'input-method-after-insert-chunk-hook))) | |
1089 | 973 |
1090 (defun quail-select-current () | 974 (defun quail-select-current () |
1091 "Select the current text shown in Quail translation region." | 975 "Select the current text shown in Quail translation region." |
1092 (interactive) | 976 (interactive) |
1093 (quail-terminate-translation)) | 977 (quail-terminate-translation)) |
1094 | 978 |
1095 ;; Update the current translation status according to CONTROL-FLAG. | 979 ;; Update the current translation status according to CONTROL-FLAG. |
1096 ;; If CONTROL-FLAG is integer value, it is the number of keys in the | 980 ;; If CONTROL-FLAG is integer value, it is the number of keys in the |
1097 ;; head quail-current-key which can be translated. The remaining keys | 981 ;; head quail-current-key which can be translated. The remaining keys |
1098 ;; are put back to unread-command-events to be handled again. | 982 ;; are put back to unread-input-method-events to be handled again. |
1099 ;; If CONTROL-FLAG is t, terminate the translation for the whole keys | 983 ;; If CONTROL-FLAG is t, terminate the translation for the whole keys |
1100 ;; in quail-current-key. | 984 ;; in quail-current-key. |
1101 ;; If CONTROL-FLAG is nil, proceed the translation with more keys. | 985 ;; If CONTROL-FLAG is nil, proceed the translation with more keys. |
1102 | 986 |
1103 (defun quail-update-translation (control-flag) | 987 (defun quail-update-translation (control-flag) |
1107 (funcall func control-flag) | 991 (funcall func control-flag) |
1108 (if (numberp control-flag) | 992 (if (numberp control-flag) |
1109 (let ((len (length quail-current-key))) | 993 (let ((len (length quail-current-key))) |
1110 (while (> len control-flag) | 994 (while (> len control-flag) |
1111 (setq len (1- len)) | 995 (setq len (1- len)) |
1112 (setq unread-command-events | 996 (setq unread-input-method-events |
1113 (cons (aref quail-current-key len) | 997 (cons (aref quail-current-key len) |
1114 unread-command-events))) | 998 unread-input-method-events))) |
1115 ;; Insert the translated sequence. | 999 ;; Insert the translated sequence. |
1116 ;; It is a string containing multibyte characters. | 1000 ;; It is a string containing multibyte characters. |
1117 ;; If enable-multibyte-characters, just insert it. | 1001 ;; If enable-multibyte-characters, just insert it. |
1118 (if enable-multibyte-characters | 1002 (if enable-multibyte-characters |
1119 (insert (or quail-current-str | 1003 (insert (or quail-current-str |
1125 (substring quail-current-key 0 len)))) | 1009 (substring quail-current-key 0 len)))) |
1126 (if (stringp char) | 1010 (if (stringp char) |
1127 (setq char (sref char 0))) | 1011 (setq char (sref char 0))) |
1128 (if (= (length (split-char char)) 2) | 1012 (if (= (length (split-char char)) 2) |
1129 (insert-char (logand char 255) 1) | 1013 (insert-char (logand char 255) 1) |
1130 (error "Three-byte characters require enabling multibyte characters"))))) | 1014 (quail-error "Three-byte characters require enabling multibyte characters"))))) |
1131 (insert (or quail-current-str quail-current-key))))) | 1015 (insert (or quail-current-str quail-current-key))))) |
1132 (quail-update-guidance) | 1016 (quail-update-guidance) |
1133 (if control-flag | 1017 (if control-flag |
1134 (quail-terminate-translation))) | 1018 (quail-terminate-translation))) |
1135 | 1019 |
1141 (unless (catch 'quail-tag | 1025 (unless (catch 'quail-tag |
1142 (quail-update-translation (quail-translate-key)) | 1026 (quail-update-translation (quail-translate-key)) |
1143 t) | 1027 t) |
1144 ;; If someone throws for `quail-tag' by value nil, we exit from | 1028 ;; If someone throws for `quail-tag' by value nil, we exit from |
1145 ;; translation mode. | 1029 ;; translation mode. |
1146 (setq overriding-terminal-local-map nil))) | 1030 (setq quail-translating nil))) |
1147 | 1031 |
1148 ;; Return the actual definition part of Quail map MAP. | 1032 ;; Return the actual definition part of Quail map MAP. |
1149 (defun quail-map-definition (map) | 1033 (defun quail-map-definition (map) |
1150 (let ((def (car map))) | 1034 (let ((def (car map))) |
1151 (if (and (consp def) (not (vectorp (cdr def)))) | 1035 (if (and (consp def) (not (vectorp (cdr def)))) |
1292 ;; We are already at the tail. | 1176 ;; We are already at the tail. |
1293 (beep) | 1177 (beep) |
1294 (setcar indices (1+ (car indices))) | 1178 (setcar indices (1+ (car indices))) |
1295 (quail-update-current-translations) | 1179 (quail-update-current-translations) |
1296 (quail-update-translation nil))) | 1180 (quail-update-translation nil))) |
1297 (quail-execute-non-quail-command))) | 1181 (setq unread-command-events |
1182 (cons last-command-event unread-command-events)) | |
1183 (quail-terminate-translation))) | |
1298 | 1184 |
1299 (defun quail-prev-translation () | 1185 (defun quail-prev-translation () |
1300 "Select previous translation in the current batch of candidates." | 1186 "Select previous translation in the current batch of candidates." |
1301 (interactive) | 1187 (interactive) |
1302 (if quail-current-translations | 1188 (if quail-current-translations |
1305 ;; We are already at the head. | 1191 ;; We are already at the head. |
1306 (beep) | 1192 (beep) |
1307 (setcar indices (1- (car indices))) | 1193 (setcar indices (1- (car indices))) |
1308 (quail-update-current-translations) | 1194 (quail-update-current-translations) |
1309 (quail-update-translation nil))) | 1195 (quail-update-translation nil))) |
1310 (quail-execute-non-quail-command))) | 1196 (setq unread-command-events |
1197 (cons last-command-event unread-command-events)) | |
1198 (quail-terminate-translation))) | |
1311 | 1199 |
1312 (defun quail-next-translation-block () | 1200 (defun quail-next-translation-block () |
1313 "Select from the next block of translations." | 1201 "Select from the next block of translations." |
1314 (interactive) | 1202 (interactive) |
1315 (if quail-current-translations | 1203 (if quail-current-translations |
1319 ;; We are already at the last block. | 1207 ;; We are already at the last block. |
1320 (beep) | 1208 (beep) |
1321 (setcar indices (+ (nth 2 indices) offset)) | 1209 (setcar indices (+ (nth 2 indices) offset)) |
1322 (quail-update-current-translations) | 1210 (quail-update-current-translations) |
1323 (quail-update-translation nil))) | 1211 (quail-update-translation nil))) |
1324 (quail-execute-non-quail-command))) | 1212 (setq unread-command-events |
1213 (append (string-to-list unread-command-events))) | |
1214 (quail-terminate-translation))) | |
1325 | 1215 |
1326 (defun quail-prev-translation-block () | 1216 (defun quail-prev-translation-block () |
1327 "Select the previous batch of 10 translation candidates." | 1217 "Select the previous batch of 10 translation candidates." |
1328 (interactive) | 1218 (interactive) |
1329 (if quail-current-translations | 1219 (if quail-current-translations |
1337 (if (< (+ (nth 1 indices) offset) (nth 2 indices)) | 1227 (if (< (+ (nth 1 indices) offset) (nth 2 indices)) |
1338 (progn | 1228 (progn |
1339 (setcar indices (+ (nth 1 indices) offset)) | 1229 (setcar indices (+ (nth 1 indices) offset)) |
1340 (quail-update-current-translations))) | 1230 (quail-update-current-translations))) |
1341 (quail-update-translation nil))) | 1231 (quail-update-translation nil))) |
1342 (quail-execute-non-quail-command))) | 1232 (setq unread-command-events |
1233 (cons last-command-event unread-command-events)) | |
1234 (quail-terminate-translation))) | |
1343 | 1235 |
1344 (defun quail-abort-translation () | 1236 (defun quail-abort-translation () |
1345 "Abort translation and delete the current Quail key sequence." | 1237 "Abort translation and delete the current Quail key sequence." |
1346 (interactive) | 1238 (interactive) |
1347 (quail-delete-region) | 1239 (quail-delete-region) |
1358 ;; For conversion mode. | 1250 ;; For conversion mode. |
1359 | 1251 |
1360 (defun quail-conversion-backward-char () | 1252 (defun quail-conversion-backward-char () |
1361 (interactive) | 1253 (interactive) |
1362 (if (<= (point) (overlay-start quail-conv-overlay)) | 1254 (if (<= (point) (overlay-start quail-conv-overlay)) |
1363 (error "Beginning of conversion region")) | 1255 (quail-error "Beginning of conversion region")) |
1256 (setq quail-translating nil) | |
1364 (forward-char -1)) | 1257 (forward-char -1)) |
1365 | 1258 |
1366 (defun quail-conversion-forward-char () | 1259 (defun quail-conversion-forward-char () |
1367 (interactive) | 1260 (interactive) |
1368 (if (>= (point) (overlay-end quail-conv-overlay)) | 1261 (if (>= (point) (overlay-end quail-conv-overlay)) |
1369 (error "End of conversion region")) | 1262 (quail-error "End of conversion region")) |
1263 (setq quail-translating nil) | |
1370 (forward-char 1)) | 1264 (forward-char 1)) |
1371 | 1265 |
1372 (defun quail-conversion-beginning-of-region () | 1266 (defun quail-conversion-beginning-of-region () |
1373 (interactive) | 1267 (interactive) |
1374 (goto-char (overlay-start quail-conv-overlay))) | 1268 (goto-char (overlay-start quail-conv-overlay))) |
1378 (goto-char (overlay-end quail-conv-overlay))) | 1272 (goto-char (overlay-end quail-conv-overlay))) |
1379 | 1273 |
1380 (defun quail-conversion-delete-char () | 1274 (defun quail-conversion-delete-char () |
1381 (interactive) | 1275 (interactive) |
1382 (if (>= (point) (overlay-end quail-conv-overlay)) | 1276 (if (>= (point) (overlay-end quail-conv-overlay)) |
1383 (error "End of conversion region")) | 1277 (quail-error "End of conversion region")) |
1384 (delete-char 1) | 1278 (delete-char 1) |
1385 (when (= (overlay-start quail-conv-overlay) | 1279 (if (= (overlay-start quail-conv-overlay) |
1386 (overlay-end quail-conv-overlay)) | 1280 (overlay-end quail-conv-overlay)) |
1387 (quail-delete-overlays) | 1281 (setq quail-converting nil))) |
1388 (setq overriding-terminal-local-map nil))) | |
1389 | 1282 |
1390 (defun quail-conversion-backward-delete-char () | 1283 (defun quail-conversion-backward-delete-char () |
1391 (interactive) | 1284 (interactive) |
1392 (if (<= (point) (overlay-start quail-conv-overlay)) | 1285 (if (<= (point) (overlay-start quail-conv-overlay)) |
1393 (error "Beginning of conversion region")) | 1286 (quail-error "Beginning of conversion region")) |
1394 (delete-char -1) | 1287 (delete-char -1) |
1395 (when (= (overlay-start quail-conv-overlay) | 1288 (if (= (overlay-start quail-conv-overlay) |
1396 (overlay-end quail-conv-overlay)) | 1289 (overlay-end quail-conv-overlay)) |
1397 (quail-delete-overlays) | 1290 (setq quail-converting nil))) |
1398 (setq overriding-terminal-local-map nil))) | |
1399 | 1291 |
1400 (defun quail-do-conversion (func &rest args) | 1292 (defun quail-do-conversion (func &rest args) |
1401 "Call FUNC to convert text in the current conversion region of Quail. | 1293 "Call FUNC to convert text in the current conversion region of Quail. |
1402 Remaining args are for FUNC." | 1294 Remaining args are for FUNC." |
1403 (delete-overlay quail-overlay) | 1295 (delete-overlay quail-overlay) |
1404 (apply func args)) | 1296 (apply func args)) |
1405 | 1297 |
1406 (defun quail-no-conversion () | 1298 (defun quail-no-conversion () |
1407 "Do no conversion of the current conversion region of Quail." | 1299 "Do no conversion of the current conversion region of Quail." |
1408 (interactive) | 1300 (interactive) |
1409 (quail-delete-overlays) | 1301 (setq quail-converting nil) |
1410 (setq overriding-terminal-local-map nil) | |
1411 (run-hooks 'input-method-after-insert-chunk-hook)) | 1302 (run-hooks 'input-method-after-insert-chunk-hook)) |
1412 | 1303 |
1413 ;; Guidance, Completion, and Help buffer handlers. | 1304 ;; Guidance, Completion, and Help buffer handlers. |
1414 | 1305 |
1415 ;; Make a new one-line frame for Quail guidance buffer. | 1306 ;; Make a new one-line frame for Quail guidance buffer. |
1750 (if (and (not (eobp)) (get-text-property (point) 'mouse-face)) | 1641 (if (and (not (eobp)) (get-text-property (point) 'mouse-face)) |
1751 (setq end (point) beg (1+ (point)))) | 1642 (setq end (point) beg (1+ (point)))) |
1752 (if (and (not (bobp)) (get-text-property (1- (point)) 'mouse-face)) | 1643 (if (and (not (bobp)) (get-text-property (1- (point)) 'mouse-face)) |
1753 (setq end (1- (point)) beg (point))) | 1644 (setq end (1- (point)) beg (point))) |
1754 (if (null beg) | 1645 (if (null beg) |
1755 (error "No completion here")) | 1646 (quail-error "No completion here")) |
1756 (setq beg (previous-single-property-change beg 'mouse-face)) | 1647 (setq beg (previous-single-property-change beg 'mouse-face)) |
1757 (setq end (or (next-single-property-change end 'mouse-face) | 1648 (setq end (or (next-single-property-change end 'mouse-face) |
1758 (point-max))) | 1649 (point-max))) |
1759 (setq choice (buffer-substring beg end))))) | 1650 (setq choice (buffer-substring beg end))))) |
1760 ; (let ((owindow (selected-window))) | 1651 ; (let ((owindow (selected-window))) |
1780 ;; active minibuffer. | 1671 ;; active minibuffer. |
1781 (if (and (string-match "\\` \\*Minibuf-[0-9]+\\*\\'" (buffer-name buffer)) | 1672 (if (and (string-match "\\` \\*Minibuf-[0-9]+\\*\\'" (buffer-name buffer)) |
1782 (or (not (active-minibuffer-window)) | 1673 (or (not (active-minibuffer-window)) |
1783 (not (equal buffer | 1674 (not (equal buffer |
1784 (window-buffer (active-minibuffer-window)))))) | 1675 (window-buffer (active-minibuffer-window)))))) |
1785 (error "Minibuffer is not active for completion") | 1676 (quail-error "Minibuffer is not active for completion") |
1786 ;; Insert the completion into the buffer where completion was requested. | 1677 ;; Insert the completion into the buffer where completion was requested. |
1787 (set-buffer buffer) | 1678 (set-buffer buffer) |
1788 ; (if base-size | 1679 ; (if base-size |
1789 ; (delete-region (+ base-size (point-min)) (point)) | 1680 ; (delete-region (+ base-size (point-min)) (point)) |
1790 ; (choose-completion-delete-max-match choice)) | 1681 ; (choose-completion-delete-max-match choice)) |
1819 (quail-title) | 1710 (quail-title) |
1820 "])\n---- Documentation ----\n" | 1711 "])\n---- Documentation ----\n" |
1821 (quail-docstring)) | 1712 (quail-docstring)) |
1822 (newline) | 1713 (newline) |
1823 (if (quail-show-layout) (quail-show-kbd-layout)) | 1714 (if (quail-show-layout) (quail-show-kbd-layout)) |
1824 (quail-help-insert-keymap-description | |
1825 quail-mode-map | |
1826 "---- Key bindings (before starting translation) ---- | |
1827 key binding | |
1828 --- -------\n") | |
1829 (quail-help-insert-keymap-description | 1715 (quail-help-insert-keymap-description |
1830 (quail-translation-keymap) | 1716 (quail-translation-keymap) |
1831 "--- Key bindings (while translating) --- | 1717 "--- Key bindings (while translating) --- |
1832 key binding | 1718 key binding |
1833 --- -------\n") | 1719 --- -------\n") |