From: Richard M. Stallman Date: Thu, 25 Jan 1996 06:34:56 +0000 (+0000) Subject: (iso-languages): Restructure the list to remove X-Git-Tag: emacs-19.34~1502 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=bbaf7c2857dec407cbe3833255ceda2a723d0484;p=emacs.git (iso-languages): Restructure the list to remove redundancy in list elements. (iso-accents-compose-key): Function deleted. (iso-accents-compose, iso-accents-customize, iso-accentuate, iso-accent-rassoc-unit, iso-unaccentuate, iso-deaccentuate): Adapt for new structure of `iso-languages'. --- diff --git a/lisp/international/iso-acc.el b/lisp/international/iso-acc.el index 8e3f6f58da0..abdafe3cf83 100644 --- a/lisp/international/iso-acc.el +++ b/lisp/international/iso-acc.el @@ -58,8 +58,8 @@ ;; minor mode, or disable it. ;; If you want only some of these characters to serve as accents, -;; add a language to iso-languages which specifies the accent characters -;; that you want, then select the language with iso-accents-customize. +;; add a language to `iso-languages' which specifies the accent characters +;; that you want, then select the language with `iso-accents-customize'. ;;; Code: @@ -67,156 +67,92 @@ (defvar iso-languages '(("portuguese" - (?' ?` ?^ ?\" ?~) - (((?' ?A) ?\301) ((?' ?E) ?\311) ((?' ?I) ?\315) ((?' ?O) ?\323) - ((?' ?U) ?\332) ((?' ?C) ?\307) ((?' ?a) ?\341) ((?' ?e) ?\351) - ((?' ?i) ?\355) ((?' ?o) ?\363) ((?' ?u) ?\372) ((?' ?c) ?\347) - ((?' ? ) ?') ((?` ?A) ?\300) ((?` ?a) ?\340) ((?` ? ) ?`) - ((?^ ?A) ?\302) ((?^ ?E) ?\312) ((?^ ?O) ?\324) ((?^ ?a) ?\342) - ((?^ ?e) ?\352) ((?^ ?o) ?\364) ((?^ ? ) ?^) ((?\" ?U) ?\334) - ((?\" ?u) ?\374) ((?\" ? ) ?\") ((?\~ ?A) ?\303) ((?\~ ?O) ?\325) - ((?\~ ?a) ?\343) ((?\~ ?o) ?\365) ((?\~ ?\ ) ?\~))) + (?' (?A . ?\301) (?E . ?\311) (?I . ?\315) (?O . ?\323) (?U . ?\332) + (?C . ?\307) (?a . ?\341) (?e . ?\351) (?i . ?\355) (?o . ?\363) + (?u . ?\372) (?c . ?\347) (?\ . ?')) + (?` (?A . ?\300) (?a . ?\340) (?\ . ?`)) + (?^ (?A . ?\302) (?E . ?\312) (?O . ?\324) (?a . ?\342) (?e . ?\352) + (?o . ?\364) (?\ . ?^)) + (?\" (?U . ?\334) (?u . ?\374) (?\ . ?\")) + (?\~ (?A . ?\303) (?O . ?\325) (?a . ?\343) (?o . ?\365) (?\ . ?\~))) + ("irish" - (?') - (((?' ?A) ?\301) ((?' ?E) ?\311) ((?' ?I) ?\315) ((?' ?O) ?\323) - ((?' ?U) ?\332) ((?' ?a) ?\341) ((?' ?e) ?\351) - ((?' ?i) ?\355) ((?' ?o) ?\363) ((?' ?u) ?\372) - ((?' ? ) ?') )) + (?' (?A . ?\301) (?E . ?\311) (?I . ?\315) (?O . ?\323) (?U . ?\332) + (?a . ?\341) (?e . ?\351) (?i . ?\355) (?o . ?\363) (?u . ?\372) + (?\ . ?'))) + ("french" - (?' ?` ?^ ?\" ?~) - (((?' ?A) ?\301) ((?' ?E) ?\311) ((?' ?I) ?\315) ((?' ?O) ?\323) - ((?' ?U) ?\332) ((?' ?C) ?\307) ((?' ?a) ?\341) ((?' ?e) ?\351) - ((?' ?i) ?\355) ((?' ?o) ?\363) ((?' ?u) ?\372) ((?' ?c) ?\347) - ((?' ? ) ?') ((?` ?A) ?\300) ((?` ?E) ?\310) ((?` ?a) ?\340) - ((?` ?e) ?\350) ((?` ? ) ?`) ((?^ ?A) ?\302) ((?^ ?E) ?\312) - ((?^ ?I) ?\316) ((?^ ?O) ?\324) ((?^ ?U) ?\333) ((?^ ?a) ?\342) - ((?^ ?e) ?\352) ((?^ ?i) ?\356) ((?^ ?o) ?\364) ((?^ ?u) ?\373) - ((?^ ? ) ?^) ((?\" ?U) ?\334) ((?\" ?u) ?\374) ((?\" ? ) ?\") - ((?\~ ?A) ?\303) ((?\~ ?O) ?\325) ((?\~ ?a) ?\343) ((?\~ ?o) ?\365) - ((?\~ ?\ ) ?\~))) + (?' (?A . ?\301) (?E . ?\311) (?I . ?\315) (?O . ?\323) (?U . ?\332) + (?C . ?\307) (?a . ?\341) (?e . ?\351) (?i . ?\355) (?o . ?\363) + (?u . ?\372) (?c . ?\347) (?\ . ?')) + (?` (?A . ?\300) (?E . ?\310) (?a . ?\340) (?e . ?\350) (?\ . ?`)) + (?^ (?A . ?\302) (?E . ?\312) (?I . ?\316) (?O . ?\324) (?U . ?\333) + (?a . ?\342) (?e . ?\352) (?i . ?\356) (?o . ?\364) (?u . ?\373) + (?\ . ?^)) + (?\" (?U . ?\334) (?u . ?\374) (?\ . ?\")) + (?\~ (?A . ?\303) (?O . ?\325) (?a . ?\343) (?o . ?\365) (?\ . ?\~))) + ("latin-2" - (?' ?` ?^ ?\" ?~) - (((?' ?A) ?\301) - ((?' ?C) ?\306) - ((?' ?D) ?\320) - ((?' ?E) ?\311) - ((?' ?I) ?\315) - ((?' ?L) ?\305) - ((?' ?N) ?\321) - ((?' ?O) ?\323) - ((?' ?R) ?\300) - ((?' ?S) ?\246) - ((?' ?U) ?\332) - ((?' ?Y) ?\335) - ((?' ?Z) ?\254) - ((?' ?a) ?\341) - ((?' ?c) ?\346) - ((?' ?d) ?\360) - ((?' ?e) ?\351) - ((?' ?i) ?\355) - ((?' ?l) ?\345) - ((?' ?n) ?\361) - ((?' ?o) ?\363) - ((?' ?r) ?\340) - ((?' ?s) ?\266) - ((?' ?u) ?\372) - ((?' ?y) ?\375) - ((?' ?z) ?\274) - ((?' ?') ?\264) - ((?' ? ) ?') - ((?` ?A) ?\241) - ((?` ?C) ?\307) - ((?` ?E) ?\312) - ((?` ?L) ?\243) - ((?` ?S) ?\252) - ((?` ?T) ?\336) - ((?` ?Z) ?\257) - ((?` ?a) ?\261) - ((?` ?l) ?\263) - ((?` ?c) ?\347) - ((?` ?e) ?\352) - ((?` ?s) ?\272) - ((?` ?t) ?\376) - ((?` ?z) ?\277) - ((?` ? ) ?`) - ((?` ?`) ?\252) - ((?` ?.) ?\377) - ((?^ ?A) ?\302) - ((?^ ?O) ?\324) - ((?^ ?a) ?\342) - ((?^ ?o) ?\364) - ((?^ ? ) ?^) - ((?^ ?^) ?^) ; no special code? - ((?\" ?A) ?\304) - ((?\" ?E) ?\313) - ((?\" ?O) ?\326) - ((?\" ?U) ?\334) - ((?\" ?a) ?\344) - ((?\" ?e) ?\353) - ((?\" ?o) ?\366) - ((?\" ?s) ?\337) - ((?\" ?u) ?\374) - ((?\" ? ) ?\") - ((?\" ?\") ?\250) - ((?\~ ?A) ?\303) - ((?\~ ?C) ?\310) - ((?\~ ?D) ?\317) - ((?\~ ?L) ?\245) - ((?\~ ?N) ?\322) - ((?\~ ?O) ?\325) - ((?\~ ?R) ?\330) - ((?\~ ?S) ?\251) - ((?\~ ?T) ?\253) - ((?\~ ?U) ?\333) - ((?\~ ?Z) ?\256) - ((?\~ ?a) ?\323) - ((?\~ ?c) ?\350) - ((?\~ ?d) ?\357) - ((?\~ ?l) ?\265) - ((?\~ ?n) ?\362) - ((?\~ ?o) ?\365) - ((?\~ ?r) ?\370) - ((?\~ ?s) ?\271) - ((?\~ ?t) ?\273) - ((?\~ ?u) ?\373) - ((?\~ ?z) ?\276) - ((?\~ ?\ ) ?\~) - ((?\~ ?v) ?\242);; v accent - ((?\~ ?\~) ?\242);; v accent - ((?\~ ?\.) ?\270);; cedilla accent - )) + (?' (?A . ?\301) (?C . ?\306) (?D . ?\320) (?E . ?\311) (?I . ?\315) + (?L . ?\305) (?N . ?\321) (?O . ?\323) (?R . ?\300) (?S . ?\246) + (?U . ?\332) (?Y . ?\335) (?Z . ?\254) (?a . ?\341) (?c . ?\346) + (?d . ?\360) (?e . ?\351) (?i . ?\355) (?l . ?\345) (?n . ?\361) + (?o . ?\363) (?r . ?\340) (?s . ?\266) (?u . ?\372) (?y . ?\375) + (?z . ?\274) (?' . ?\264) (?\ . ?')) + (?` (?A . ?\241) (?C . ?\307) (?E . ?\312) (?L . ?\243) (?S . ?\252) + (?T . ?\336) (?Z . ?\257) (?a . ?\261) (?l . ?\263) (?c . ?\347) + (?e . ?\352) (?s . ?\272) (?t . ?\376) (?z . ?\277) (?` . ?\252) + (?. . ?\377) (?\ . ?`)) + (?^ (?A . ?\302) (?O . ?\324) (?a . ?\342) (?o . ?\364) + (?^ . ?^) ; no special code? + (?\ . ?^)) + (?\" (?A . ?\304) (?E . ?\313) (?O . ?\326) (?U . ?\334) (?a . ?\344) + (?e . ?\353) (?o . ?\366) (?s . ?\337) (?u . ?\374) (?\" . ?\250) + (?\ . ?\")) + (?\~ (?A . ?\303) (?C . ?\310) (?D . ?\317) (?L . ?\245) (?N . ?\322) + (?O . ?\325) (?R . ?\330) (?S . ?\251) (?T . ?\253) (?U . ?\333) + (?Z . ?\256) (?a . ?\323) (?c . ?\350) (?d . ?\357) (?l . ?\265) + (?n . ?\362) (?o . ?\365) (?r . ?\370) (?s . ?\271) (?t . ?\273) + (?u . ?\373) (?z . ?\276) + (?v . ?\242) ; v accent + (?\~ . ?\242) ; v accent + (?\. . ?\270) ; cedilla accent + (?\ . ?\~))) + ("latin-1" - (?' ?` ?^ ?\" ?~ ?/) - (((?' ?A) ?\301) ((?' ?E) ?\311) ((?' ?I) ?\315) ((?' ?O) ?\323) - ((?' ?U) ?\332) ((?' ?Y) ?\335) ((?' ?a) ?\341) ((?' ?e) ?\351) - ((?' ?i) ?\355) ((?' ?o) ?\363) ((?' ?u) ?\372) ((?' ?y) ?\375) - ((?' ?') ?\264) ((?' ? ) ?') ((?` ?A) ?\300) ((?` ?E) ?\310) - ((?` ?I) ?\314) ((?` ?O) ?\322) ((?` ?U) ?\331) ((?` ?a) ?\340) - ((?` ?e) ?\350) ((?` ?i) ?\354) ((?` ?o) ?\362) ((?` ?u) ?\371) - ((?` ? ) ?`) ((?` ?`) ?`) ((?^ ?A) ?\302) ((?^ ?E) ?\312) - ((?^ ?I) ?\316) ((?^ ?O) ?\324) ((?^ ?U) ?\333) ((?^ ?a) ?\342) - ((?^ ?e) ?\352) ((?^ ?i) ?\356) ((?^ ?o) ?\364) ((?^ ?u) ?\373) - ((?^ ? ) ?^) ((?^ ?^) ?^) ((?\" ?A) ?\304) ((?\" ?E) ?\313) - ((?\" ?I) ?\317) ((?\" ?O) ?\326) ((?\" ?U) ?\334) ((?\" ?a) ?\344) - ((?\" ?e) ?\353) ((?\" ?i) ?\357) ((?\" ?o) ?\366) ((?\" ?s) ?\337) - ((?\" ?u) ?\374) ((?\" ?y) ?\377) ((?\" ? ) ?\") ((?\" ?\") ?\250) - ((?\~ ?A) ?\303) ((?\~ ?C) ?\307) ((?\~ ?D) ?\320) ((?\~ ?N) ?\321) - ((?\~ ?O) ?\325) ((?\~ ?T) ?\336) ((?\~ ?a) ?\343) ((?\~ ?c) ?\347) - ((?\~ ?d) ?\360) ((?\~ ?n) ?\361) ((?\~ ?o) ?\365) ((?\~ ?t) ?\376) - ((?\~ ?>) ?\273) ((?\~ ?<) ?\253) ((?\~ ?\ ) ?\~) ((?\~ ?\~) ?\270) - ((?\/ ?A) ?\305) ((?\/ ?E) ?\306) ((?\/ ?O) ?\330) ((?\/ ?a) ?\345) - ((?\/ ?e) ?\346) ((?\/ ?o) ?\370) ((?\/ ?\ ) ?\/) ((?\/ ?\/) ?\260)))) + (?' (?A . ?\301) (?E . ?\311) (?I . ?\315) (?O . ?\323) (?U . ?\332) + (?Y . ?\335) (?a . ?\341) (?e . ?\351) (?i . ?\355) (?o . ?\363) + (?u . ?\372) (?y . ?\375) (?' . ?\264) (?\ . ?')) + (?` (?A . ?\300) (?E . ?\310) (?I . ?\314) (?O . ?\322) (?U . ?\331) + (?a . ?\340) (?e . ?\350) (?i . ?\354) (?o . ?\362) (?u . ?\371) + (?` . ?`) (?\ . ?`)) + (?^ (?A . ?\302) (?E . ?\312) (?I . ?\316) (?O . ?\324) (?U . ?\333) + (?a . ?\342) (?e . ?\352) (?i . ?\356) (?o . ?\364) (?u . ?\373) + (?^ . ?^) (?\ . ?^)) + (?\" (?A . ?\304) (?E . ?\313) (?I . ?\317) (?O . ?\326) (?U . ?\334) + (?a . ?\344) (?e . ?\353) (?i . ?\357) (?o . ?\366) (?s . ?\337) + (?u . ?\374) (?y . ?\377) (?\" . ?\250) (?\ . ?\")) + (?\~ (?A . ?\303) (?C . ?\307) (?D . ?\320) (?N . ?\321) (?O . ?\325) + (?T . ?\336) (?a . ?\343) (?c . ?\347) (?d . ?\360) (?n . ?\361) + (?o . ?\365) (?t . ?\376) (?> . ?\273) (?< . ?\253) (?\~ . ?\270) + (?\ . ?\~)) + (?\/ (?A . ?\305) (?E . ?\306) (?O . ?\330) (?a . ?\345) (?e . ?\346) + (?o . ?\370) (?\/ . ?\260) (?\ . ?\/)))) "List of language-specific customizations for the ISO Accents mode. -Each element of the list is of the form (LANGUAGE PREFIXES LIST). +Each element of the list is of the form -LANGUAGE is a string naming the language. + (LANGUAGE + (PSEUDO-ACCENT MAPPINGS) + (PSEUDO-ACCENT MAPPINGS) + ...) -PREFIXES is a list of characters that will be used as accent prefixes. -It is currently not used. +LANGUAGE is a string naming the language. +PSEUDO-ACCENT is a char specifying an accent key. +MAPPINGS are cons cells of the form (CHAR . ISO-CHAR). -LIST is a list of accent translations. It will be the value of the -`iso-accents-list' variable.") +The net effect is that the key sequence PSEUDO-ACCENT CHAR is mapped +to ISO-CHAR on input.") (defvar iso-language nil "Language for which ISO Accents mode is currently customized. @@ -249,20 +185,9 @@ the language you choose).") (iso-accents-compose prompt) (char-to-string last-input-char))) -(defun iso-accents-compose-key (prompt) - "Modify the following character by adding an accent to it." - ;; Pick up the accent character. - (let ((combined (iso-accents-compose prompt))) - (if unread-command-events - (let ((unread unread-command-events)) - (setq unread-command-events nil) - (error "Characters %s and %s cannot be composed" - (single-key-description (aref combined 0)) - (single-key-description (car unread))))) - combined)) - (defun iso-accents-compose (prompt) (let* ((first-char last-input-char) + (list (assq first-char iso-accents-list)) ;; Wait for the second key and look up the combination. (second-char (if (or prompt (not (eq (key-binding "a") @@ -277,10 +202,10 @@ the language you choose).") (insert first-char) (prog1 (read-event) (delete-region (1- (point)) (point))))) - (entry (assoc (list first-char second-char) iso-accents-list))) + (entry (cdr (assq second-char list)))) (if entry - ;; Found it: delete the first character and insert the combination. - (concat (list (nth 1 entry))) + ;; Found it: return the mapped char + (vector entry) ;; Otherwise, advance and schedule the second key for execution. (setq unread-command-events (list second-char)) (vector first-char)))) @@ -337,24 +262,18 @@ It selects the customization based on the specifications in the (let ((table (assoc language iso-languages)) all-accents tail) (if (not table) - (error "Unknown language") - (setq iso-language language) - (setq iso-accents-list (car (cdr (cdr table)))) + (error "Unknown language '%s'" language) + (setq iso-language language + iso-accents-list (cdr table)) (if key-translation-map (substitute-key-definition 'iso-accents-accent-key nil key-translation-map) (setq key-translation-map (make-sparse-keymap))) - ;; Find all the characters that are used as accent prefixes - ;; in this language, and set up translation for them. + ;; Set up translations for all the characters that are used as + ;; accent prefixes in this language. (setq tail iso-accents-list) (while tail - (let ((acc (car (car (car tail))))) - (or (memq acc all-accents) - (setq all-accents (cons acc all-accents)))) - (setq tail (cdr tail))) - (setq tail all-accents) - (while tail - (define-key key-translation-map (char-to-string (car tail)) + (define-key key-translation-map (vector (car (car tail))) 'iso-accents-accent-key) (setq tail (cdr tail)))))) @@ -371,24 +290,22 @@ This uses the same conversion that ISO Accents mode uses for type-in." (let (entry) (while (< (point) end) (if (and (memq (preceding-char) iso-accents-enable) - (<= ?A (following-char)) - (<= (following-char) ?z) - (setq entry (assoc (list (preceding-char) (following-char)) - iso-accents-list))) + (setq entry (cdr (assq (following-char) (assq (preceding-char) iso-accents-list))))) (progn (forward-char -1) (delete-char 2) - (insert (car (cdr entry))) + (insert entry) (setq end (1- end))) (forward-char 1))))))) (defun iso-accent-rassoc-unit (value alist) - (while (and alist - (not (eq (car (cdr (car alist))) value))) - (setq alist (cdr alist))) - (if alist - (car alist) - nil)) + (let (elt acc) + (while (and alist (not elt)) + (setq acc (car (car alist)) + elt (car (rassq value (cdr (car alist)))) + alist (cdr alist))) + (if elt + (cons acc elt)))) (defun iso-unaccentuate (start end) "Convert accented characters in the region into two-character sequences. @@ -406,7 +323,7 @@ This uses the opposite of the conversion done by ISO Accents mode for type-in." iso-accents-list))) (progn (delete-char 1) - (insert (car (car entry)) (car (cdr (car entry)))) + (insert (car entry) (cdr entry)) (setq end (1+ end))) (forward-char 1))))))) @@ -425,7 +342,7 @@ Noninteractively, this operates on text from START to END." iso-accents-list))) (progn (delete-char 1) - (insert (car (cdr (car entry))))) + (insert (cdr entry))) (forward-char 1))))))) ;; Set up the default settings.