diff options
| author | Kenichi Handa | 1998-10-08 06:45:36 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1998-10-08 06:45:36 +0000 |
| commit | 7b5ebb00497e62340e97061c84953c39920f87dd (patch) | |
| tree | 8658217077e14b8702fc49e2a4a0e6d4c1eccc0e | |
| parent | fd16a4c6d89567554b755f27e642738349302336 (diff) | |
| download | emacs-7b5ebb00497e62340e97061c84953c39920f87dd.tar.gz emacs-7b5ebb00497e62340e97061c84953c39920f87dd.zip | |
(quail-defrule): New optional arg APPEND.
(quail-defrule-internal): Fix bug of handling the argument APPEND.
| -rw-r--r-- | lisp/international/quail.el | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/lisp/international/quail.el b/lisp/international/quail.el index f003e1e73d9..910afe0c720 100644 --- a/lisp/international/quail.el +++ b/lisp/international/quail.el | |||
| @@ -683,7 +683,7 @@ The installed map can be referred by the function `quail-map'." | |||
| 683 | (setcar (cdr (cdr quail-current-package)) map)) | 683 | (setcar (cdr (cdr quail-current-package)) map)) |
| 684 | 684 | ||
| 685 | ;;;###autoload | 685 | ;;;###autoload |
| 686 | (defun quail-defrule (key translation &optional name) | 686 | (defun quail-defrule (key translation &optional name append) |
| 687 | "Add one translation rule, KEY to TRANSLATION, in the current Quail package. | 687 | "Add one translation rule, KEY to TRANSLATION, in the current Quail package. |
| 688 | KEY is a string meaning a sequence of keystrokes to be translated. | 688 | KEY is a string meaning a sequence of keystrokes to be translated. |
| 689 | TRANSLATION is a character, a string, a vector, a Quail map, | 689 | TRANSLATION is a character, a string, a vector, a Quail map, |
| @@ -700,15 +700,19 @@ In these cases, a key specific Quail map is generated and assigned to KEY. | |||
| 700 | 700 | ||
| 701 | If TRANSLATION is a Quail map or a function symbol which returns a Quail map, | 701 | If TRANSLATION is a Quail map or a function symbol which returns a Quail map, |
| 702 | it is used to handle KEY. | 702 | it is used to handle KEY. |
| 703 | Optional argument NAME, if specified, says which Quail package | 703 | |
| 704 | Optional 3rd argument NAME, if specified, says which Quail package | ||
| 704 | to define this translation rule in. The default is to define it in the | 705 | to define this translation rule in. The default is to define it in the |
| 705 | current Quail package." | 706 | current Quail package. |
| 707 | |||
| 708 | Optional 4th argument APPEND, if non-nil, appends TRANSLATION | ||
| 709 | to the current translations for KEY instead of replacing them." | ||
| 706 | (if name | 710 | (if name |
| 707 | (let ((package (quail-package name))) | 711 | (let ((package (quail-package name))) |
| 708 | (if (null package) | 712 | (if (null package) |
| 709 | (error "No Quail package `%s'" name)) | 713 | (error "No Quail package `%s'" name)) |
| 710 | (setq quail-current-package package))) | 714 | (setq quail-current-package package))) |
| 711 | (quail-defrule-internal key translation (quail-map))) | 715 | (quail-defrule-internal key translation (quail-map) append)) |
| 712 | 716 | ||
| 713 | ;;;###autoload | 717 | ;;;###autoload |
| 714 | (defun quail-defrule-internal (key trans map &optional append) | 718 | (defun quail-defrule-internal (key trans map &optional append) |
| @@ -761,9 +765,19 @@ current Quail package." | |||
| 761 | (error "Quail key %s is too short" key) | 765 | (error "Quail key %s is too short" key) |
| 762 | (setcdr entry trans)) | 766 | (setcdr entry trans)) |
| 763 | (setcdr entry (append trans (cdr map))))) | 767 | (setcdr entry (append trans (cdr map))))) |
| 764 | (if (and append (stringp (car map)) (stringp trans)) | 768 | (if (and (car map) append) |
| 765 | (setcar map (concat (car map) trans)) | 769 | (let ((prev (quail-get-translation (car map) key len))) |
| 766 | (setcar map trans)))))) | 770 | (if (integerp prev) |
| 771 | (setq prev (vector prev)) | ||
| 772 | (setq prev (cdr prev))) | ||
| 773 | (if (integerp trans) | ||
| 774 | (setq trans (vector trans)) | ||
| 775 | (if (stringp trans) | ||
| 776 | (setq trans (string-to-vector trans)))) | ||
| 777 | (setq trans | ||
| 778 | (cons (list 0 0 0 0 nil) | ||
| 779 | (vconcat prev trans))))) | ||
| 780 | (setcar map trans))))) | ||
| 767 | 781 | ||
| 768 | (defun quail-get-translation (def key len) | 782 | (defun quail-get-translation (def key len) |
| 769 | "Return the translation specified as DEF for KEY of length LEN. | 783 | "Return the translation specified as DEF for KEY of length LEN. |