view leim/quail/lrt.el @ 20102:c00f010468c2

Using cl macros push, pop, when, unless throughout the file. This is not further mentioned in this ChangeLog entry. Documentation largely updated. Parser rewritten for better Multifile Document processing. Macros with naked label arguments supported. Some Mule related changes. (reftex-default-label-alist-entries): Customization type is now computed from reftex-label-alist-builtin. Enumerate has new typekey `i'. `n' is now reserved for footnotes etc. (reftex-label-alist): Introduced default regular expressions. Customization type is now computed from reftex-label-alist-builtin. (reftex-label-menu-flags): New flag for showing file borders. (reftex-refontify-context): New option. (reftex-bibfile-ignore-list): Now a user option (was: variable). (reftex-cite-format): Now a user option (was: variable). Customization type is now computed from reftex-cite-format-builtin. (reftex-comment-citations): Now a user option (was: variable). (reftex-toc-follow-mode): Now a user option (was: variable). (reftex-optimizations-for-large-documents): New custom group. (reftex-keep-temporary-buffers): 1 as additional value. (reftex-initialize-temporary-buffers): New option. (reftex-enable-partial-scans): New option. (reftex-save-parse-info): New option. (reftex-plug-into-AUCTeX): Now a user option (was: variable). (reftex-auto-show-entry): New value 'copy allowed. (reftex-load-hook): Now a declared variable. (reftex-mode-hook): Now a declared variable. (reftex-label-numbers-symbol): Variable removed. (reftex-list-of-labels-symbol): Variable removed. (reftex-label-numbers-symbol): Variable removed. (reftex-bibfile-list-symbol): Variable removed. (reftex-docstruct-symbol): New variable (buffer-local). (reftex-master-include-list): Variable removed. (reftex-make-master-buffer): Function removed. (reftex-make-master-buffer-hook): Hook removed. (reftex-insert-buffer-or-file): Function removed. (reftex-parse-document): Function adapted to new parser. (reftex-access-scan-info): Changed to fit new parser. Now detects changes in label-alist related variables automatically. (reftex-parse-one,reftex-parse-all): New functions. (reftex-all-document-files): New function. (reftex-grep-document,reftex-search-document, reftex-query-replace-document): Now use `reftex-all-document-files'. (reftex-section-or-include-regexp): New variable. (reftex-everything-regexp): New variable. (reftex-find-label-regexp-format): New variable. (reftex-find-label-regexp-format2): New variable. (reftex-do-parse): New function. (reftex-is-multi): New function. (reftex-parse-from-file): New function. (reftex-locate-bibliography-files): New function. (reftex-last-assoc-before-elt): New function. (reftex-replace-label-list-segment): New function. (reftex-silence-toc-markers): New function. (reftex-access-parse-file): New function. (reftex-label): Now uses `reftex-where-am-I'. (reftex-offer-label-menu): New keys `%' and `i' and `r'. (reftex-select-item): Recursive edit moved to key `e'. New key `x' for external documents. Works now also with nin-nil pop-frame. (reftex-offer-label-menu): Now uses `reftex-where-am-I'. (reftex-make-and-insert-label-menu): More efficient, allow optional extra fontification. (reftex-find-nearby-label): Function removed. (reftex-scan-buffer-for-labels): Function removed. (reftex-section-info): New function. (reftex-nth-parens-substring): Renamed to reftex-nth-arg. Return nil when not enough args are present. (reftex-move-over-touching-args): New function. (reftex-where-am-I): New function. (reftex-nth-arg-wrapper): New function. (reftex-select-label-callback): Deal with special macros as well. (reftex-find-duplicate-labels): Ignore special entries in docstruct. (reftex-kill-temporary-buffers): New arg buffer. (reftex-show-entry): Copy context when necessary. (reftex-toc): New key `R', use reftex-where-am-I. (reftex-nearest-section): Use reftex-where-am-I. (reftex-toc-visit-line): Completely rewritten. Uses markers and several backup methods. (reftex-citation): Recursive edit moved to `e' key. (reftex-scan-buffer): Function removed. (reftex-get-bibfile-list): Changed to work with chapterbib package. (reftex-find-tex-file): New function. (reftex-find-files-on-path): Now first looks for file with additional .tex extension, then for the naked file name. (reftex-citation): Split into reftex-citation and reftex-do-citation. (reftex-do-citation): Recursive edit now on `e' key. (reftex-what-macro): Allow white space between macro arguments. (reftex-allow-for-ctrl-m): Renamed to `reftex-make-regexp-allow-for-ctrl-m'. (reftex-nearest-match): New function. (reftex-auto-mode-alist): New function. (reftex-make-desparate-section-regexp): New funtion. (reftex-get-file-buffer-force): Rewritten to use new variable `reftex-initialize-temporary-buffers'. (reftex-label-alist-builtin): Use abbreviated regexps. (reftex-label-mac-list): New variable. (reftex-parse-args): New function. (easy-menu-define): Menu extended. Some parts are now computed. from the user options. (reftex-move-to-next-arg,reftex-move-to-previous-arg) New functions. Now we can parse macros with distributed arguments. (reftex-goto-label): Function removed. (reftex-position-cursor): Function removed. (reftex-item): Function removed. (reftex-add-to-label-alist): No longer autoloaded. (reftex-toc-indent): Constant removed. (reftex-label-indent): Constant removed. (reftex-context-indent): Constant removed. (reftex-match-string): New function. (reftex-memory): New variable (reftex-reset-mode): No longer hacks local variables. Now resets path variables as well. (reftex-truncate): New functions, to make RefTeX work with Mule. (reftex-fp): New macro, to make RefTeX work with Mule. (reftex-format-bib-entry): Now uses `reftex-truncate' to truncate author names. `extra' and `title' are no longer truncated at all. (reftex-all-assq): New function. (reftex-view-crossref): Works now also if mouse click is on macro. (reftex-context-substring): Now returns substring without text properties. (reftex-tex-path,reftex-bib-path): New variables. (reftex-split): Function replaced with builtin `split-string'. (reftex-find-bib-file): New function. (reftex-find-files-on-path): Function removed. (reftex-find-file-on-path): New function. (reftex-access-search-path,reftex-parse-colon-path, reftex-recursive-directory-list,reftex-expand-path): New functions, dealing with recursive TEXINPUTS and BIBINPUTS definitions.
author Karl Heuer <kwzh@gnu.org>
date Tue, 21 Oct 1997 03:15:20 +0000
parents dd39cae4cf0f
children f245110aa619
line wrap: on
line source

;;; quail/lrt.el --- Quail package for inputting Lao characters by LRT method

;; Copyright (C) 1997 Electrotechnical Laboratory, JAPAN.
;; Licensed to the Free Software Foundation.

;; Keywords: multilingual, input method, Lao, LRT.

;; This file is part of GNU Emacs.

;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.

;;; Code:

(require 'quail)
(require 'lao-util)

;; LRT (Lao Roman Transcription) input method accepts the following
;; key sequence:
;;	consonant [+ semi-vowel-sign-lo ] + vowel [+ maa-sakod ] [+ tone-mark ]

(eval-and-compile

;; Upper vowels and tone-marks are put on the letter.
;; Semi-vowel-sign-lo and lower vowels are put under the letter.
(defconst lrt-single-consonant-table
  `(("k" . ?(1!(B)
    ("kh" . ?(1"(B)
    ("qh" . ?(1$(B)
    ("ng" . ?(1'(B)
    ("j" . ?(1((B)
    ("s" . ?(1J(B)
    ("x" . ?(1*(B)
    ("y" . ?(1-(B)
    ("d" . ?(14(B)
    ("t" . ?(15(B)
    ("th" . ?(16(B)
    ("dh" . ?(17(B)
    ("n" . ?(19(B)
    ("b" . ?(1:(B)
    ("p" . ?(1;(B)
    ("hp" . ?(1<(B)
    ("fh" . ?(1=(B)
    ("ph" . ?(1>(B)
    ("f" . ?(1?(B)
    ("m" . ?(1A(B)
    ("gn" . ?(1B(B)
    ("l" . ?(1E(B)
    ("r" . ?(1C(B)
    ("v" . ?(1G(B)
    ("w" . ?(1G(B)
    ("hh" . ?(1K(B)
    ("O" . ?(1M(B)
    ("h" . ?(1N(B)
    ("nh" . ?(1|(B)
    ("mh" . ?(1}(B)
    ("lh" . "0(1K\1(B")
    ))

;; Semi-vowel-sign-lo is put under the first letter.
;; Lower vowels are put under the last letter.
;; Upper vowels and tone-marks are put on the last letter.
(defconst lrt-double-consonant-table
  '(("ngh" . "(1K'(B")
    ("yh" . "(1K](B")
    ("wh" . "(1KG(B")
    ("hl" . "(1KE(B")
    ("hy" . "(1K-(B")         
    ("hn" . "(1K9(B")
    ("hm" . "(1KA(B")
    ))

(defconst lrt-semi-vowel-sign-lo
  '("r" . ?(1\(B))

(defconst lrt-vowel-table
  '(("a" "(1P(B" (0 ?(1P(B) (0 ?(1Q(B))
    ("ar" "(1R(B" (0 ?(1R(B))
    ("i" "(1T(B" (0 ?(1T(B))
    ("ii" "(1U(B" (0 ?(1U(B))
    ("eu" "(1V(B" (0 ?(1V(B))
    ("ur" "(1W(B" (0 ?(1W(B))
    ("u" "(1X(B" (0 ?(1X(B))
    ("uu" "(1Y(B" (0 ?(1Y(B))
    ("e" "(1`(B (1P(B" (?(1`(B 0 ?(1P(B) (?(1`(B 0 ?(1Q(B))
    ("ee" "(1`(B" (?(1`(B 0))
    ("ae" "(1a(B (1P(B" (?(1a(B 0 ?(1P(B) (?(1a(B 0 ?(1Q(B))
    ("aa" "(1a(B" (?(1a(B 0))
    ("o" "(1b(B (1P(B" (?(1b(B 0 ?(1P(B) (0 ?(1[(B) (?(1-(B ?(1b(B 0 ?(1Q(B) (?(1G(B ?(1b(B 0 ?(1Q(B))
    ("oo" "(1b(B" (?(1b(B 0))
    ("oe" "(1`(B (1RP(B" (?(1`(B 0 ?(1R(B ?(1P(B) (0 ?(1Q(B ?(1M(B))
    ("or" "(1m(B" (0 ?(1m(B) (0 ?(1M(B))
    ("er" "(1`(B (1T(B" (?(1`(B 0 ?(1T(B))
    ("ir" "(1`(B (1U(B" (?(1`(B 0 ?(1U(B))
    ("ua" "(1[GP(B" (0 ?(1[(B ?(1G(B ?(1P(B) (0 ?(1Q(B ?(1G(B))
    ("uaa" "(1[G(B" (0 ?(1[(B ?(1G(B) (0 ?(1G(B))
    ("ie" "(1`Q]P(B" (?(1`(B 0 ?(1Q(B ?(1](B ?(1P(B) (0 ?(1Q(B ?(1](B))
    ("ia" "(1`Q](B" (?(1`(B 0 ?(1Q(B ?(1](B) (0 ?(1](B))
    ("ea" "(1`VM(B" (?(1`(B 0 ?(1V(B ?(1M(B))
    ("eaa" "(1`WM(B" (?(1`(B 0 ?(1W(B ?(1M(B))
    ("ai" "(1d(B" (?(1d(B 0))
    ("ei" "(1c(B" (?(1c(B 0))
    ("ao" "(1`[R(B" (?(1`(B 0 ?(1[(B ?(1R(B))
    ("aM" "(1S(B" (0 ?(1S(B))))

;; Maa-sakod is put at the tail.
(defconst lrt-maa-sakod-table
  '((?k . ?(1!(B)
    (?g . ?(1'(B)
    (?y . ?(1-(B)
    (?d . ?(14(B)
    (?n . ?(19(B)
    (?b . ?(1:(B)
    (?m . ?(1A(B)
    (?v . ?(1G(B)
    (?w . ?(1G(B)
    ))

(defconst lrt-tone-mark-table
  '(("'" . ?(1h(B)
    ("\"" . ?(1i(B)
    ("^" . ?(1j(B)
    ("+" . ?(1k(B)
    ("~" . ?(1l(B)))

;; Return list of composing patterns for normal (without maa-sakod)
;; key sequence and with-maa-sakod key sequence starting with single
;; consonant C and optional SEMI-VOWEL.
(defun lrt-composing-pattern-single-c (c semi-vowel vowel-pattern)
  (let* ((patterns (copy-sequence vowel-pattern))
	 (tail patterns)
	 place)
    ;; Embed C and SEMI-VOWEL (if any) at the place of 0.
    (while tail
      ;; At first, make a copy.
      (setcar tail (copy-sequence (car tail)))
      ;; Then, do embedding.
      (setq place (memq 0 (car tail)))
      (setcar place c)
      (if semi-vowel
	  (setcdr place (cons semi-vowel (cdr place))))
      (setq tail (cdr tail)))
    patterns))

;; Return list of composing patterns for normal (without maa-sakod)
;; key sequence and with-maa-sakod key sequence starting with double
;; consonant STR and optional SEMI-VOWEL.
(defun lrt-composing-pattern-double-c (str semi-vowel vowel-pattern)
  (let* ((patterns (copy-sequence vowel-pattern))
	 (tail patterns)
	 (chars (string-to-list
		 (if (= (chars-in-string str) 1)
		     (decompose-string str)
		   str)))
	 place)
    ;; Embed C and SEMI-VOWEL (if any) at the place of 0.
    (while tail
      ;; At first, make a copy.
      (setcar tail (copy-sequence (car tail)))
      ;; Then, do embedding.
      (setq place (memq 0 (car tail)))
      (setcar place (car chars))
      (setcdr place (cons (nth 1 chars) (cdr place)))
      (if semi-vowel
	  ;; Embed SEMI-VOWEL in between CHARS.
	  (setcdr place (cons semi-vowel (cdr place))))
      (setq tail (cdr tail)))
    patterns))

;; Return a string made of characters in CHAR-LIST while composing
;; such characters as vowel-upper, vowel-lower, semi-vowel(lower),
;; and tone-mark with the preceding base character.
(defun lrt-compose-string (char-list)
  ;; Make a copy because the following work alters it.
  (setq char-list (copy-sequence char-list))
  (let ((i -1)
	(l char-list))
    (while l
      (if (memq (get-char-code-property (car l) 'phonetic-type)
		'(vowel-upper vowel-lower semivowel-lower tone))
	  (let (composed-char)
	    (if (< i 0)
		;; No preceding base character.
		(error "Invalid CHAR-LIST: %s" char-list))
	    (setq composed-char
		  (string-to-char (compose-chars (nth i char-list) (car l))))
	    (setcar (nthcdr i char-list) composed-char)
	    (setq l (cdr l))
	    (setcdr (nthcdr i char-list) l))
	(setq l (cdr l))
	(setq i (1+ i))))
    (concat (apply 'vector char-list))))

(defun lrt-compose-c-s-v (consonant semi-vowel vowel-pattern)
  (let ((pattern-list
	 (if (integerp consonant)
	     (lrt-composing-pattern-single-c
	      consonant semi-vowel vowel-pattern)
	   (lrt-composing-pattern-double-c
	    consonant semi-vowel vowel-pattern))))
    (cons (vector (lrt-compose-string (car pattern-list)))
	  (cons t pattern-list))))

)

(defun lrt-handle-maa-sakod ()
  (interactive)
  (if (or (= (length quail-current-key) 0)
	  (not quail-current-data))
      (quail-self-insert-command)
    (if (not (car quail-current-data))
	(progn
	  (setq quail-current-data nil)
	  (setq unread-command-events
		(cons last-command-event unread-command-events))
	  (quail-terminate-translation))
      (if (not (integerp last-command-event))
	  (error "Bogus calling sequence"))
      (let* ((maa-sakod (cdr (assq last-command-event lrt-maa-sakod-table)))
	     (maa-sakod-pattern (append
				 (or (cdr (assq maa-sakod
						(nthcdr 3 quail-current-data)))
				     (nth 2 quail-current-data)
				     (nth 1 quail-current-data))
				 (list maa-sakod))))
	(quail-delete-region)
	(setq quail-current-str (lrt-compose-string maa-sakod-pattern))
	(insert quail-current-str)
	(quail-show-translations)
	(setq quail-current-data (list nil maa-sakod-pattern))))))

(defun lrt-handle-tone-mark ()
  (interactive)
  (if (= (length quail-current-key) 0)
      (quail-self-insert-command)
    (if (not quail-current-data)
	(progn
	  (setq unread-command-events
		(cons last-command-event unread-command-events))
	  (quail-terminate-translation))
      (if (not (integerp last-command-event))
	  (error "Bogus calling sequence"))
      (let* ((tone-mark (cdr (assoc (char-to-string last-command-event)
				    lrt-tone-mark-table)))
	     (tone-mark-pattern
	      (if (car quail-current-data)
		  (copy-sequence (nth 1 quail-current-data))
		;; No need of copy because lrt-handle-maa-sakod should
		;; have already done it.
		(nth 1 quail-current-data)))
	     (tail tone-mark-pattern)
	     (double-consonant-keys lrt-double-consonant-table)
	     (double-consonant-flag nil)
	     place)

	;; Set DOUBLE-CONSONANT-FLAG to t if a user entered a double
	;; consonant.
	(while (and double-consonant-keys (not double-consonant-flag))
	  (setq double-consonant-flag
		(eq (string-match (car (car double-consonant-keys))
				  quail-current-key)
		    0)
		double-consonant-keys (cdr double-consonant-keys)))

	;; Find a place to embed TONE-MARK.  It should be after a
	;; single or double consonant and following upper or lower vowels.
	(while (and tail (not place))
	  (if (and
	       (eq (get-char-code-property (car tail) 'phonetic-type)
		   'consonant)
	       ;; Skip `(1K(B' if it is the first letter of double consonant.
	       (or (not double-consonant-flag)
		   (/= (car tail) ?(1K(B)))
	      (progn
		(setq place tail)
		(setq tail (cdr tail))
		(while (and tail
			    (memq (get-char-code-property (car tail)
							  'phonetic-type)
				  '(vowel-upper vowel-lower semivowel-lower)))
		  (setq place tail tail (cdr tail))))
	    (setq tail (cdr tail))))
	;; Embed TONE-MARK.
	(setcdr place (cons tone-mark (cdr place)))
	(quail-delete-region)
	(insert (lrt-compose-string tone-mark-pattern))
	(setq quail-current-data nil)
	(quail-terminate-translation)))))

(defmacro lrt-generate-quail-map ()
  `(quail-install-map
    ',(let ((map (list nil))
	    (semi-vowel-key (car lrt-semi-vowel-sign-lo))
	    (semi-vowel-char (cdr lrt-semi-vowel-sign-lo))
	    l1 e1 l2 e2 pattern key)
	;; Single consonants.
	(setq l1 lrt-single-consonant-table)
	(while l1
	  (setq e1 (car l1))
	  (quail-defrule-internal (car e1) (vector (cdr e1)) map)
	  (quail-defrule-internal
	   (concat (car e1) semi-vowel-key)
	   (if (stringp (cdr e1))
	       (compose-string (format "%s%c" (cdr e1) semi-vowel-char))
	     (compose-string (format "%c%c" (cdr e1) semi-vowel-char)))
	   map)
	  (setq l2 lrt-vowel-table)
	  (while l2
	    (setq e2 (car l2))
	    (setq key (concat (car e1) (car e2))
		  pattern (lrt-compose-c-s-v (cdr e1) nil (nthcdr 2 e2)))
	    (quail-defrule-internal key pattern map)
	    (quail-defrule-internal
	     (concat key " ")
	     (vector (concat (aref (car pattern) 0) " "))  map)
	    (setq key (concat (car e1) semi-vowel-key (car e2))
		  pattern (lrt-compose-c-s-v (cdr e1) semi-vowel-char
					     (nthcdr 2 e2)))
	    (quail-defrule-internal key pattern map)
	    (quail-defrule-internal
	     (concat key " ")
	     (vector (concat (aref (car pattern) 0) " "))  map)
	    (setq l2 (cdr l2)))
	  (setq l1 (cdr l1)))

	;; Double consonants.
	(setq l1 lrt-double-consonant-table)
	(while l1
	  (setq e1 (car l1))
	  (quail-defrule-internal (car e1) (vector (cdr e1)) map)
	  (quail-defrule-internal
	   (concat (car e1) semi-vowel-key)
	   (vector (concat (compose-string
			    (format "%c%c" (sref (cdr e1) 0) semi-vowel-char))
			   (substring (cdr e1) (charset-bytes 'lao))))
	   map)
	  (setq l2 lrt-vowel-table)
	  (while l2
	    (setq e2 (car l2))
	    (setq key (concat (car e1) (car e2))
		  pattern (lrt-compose-c-s-v (cdr e1) nil (nthcdr 2 e2)))
	    (quail-defrule-internal key pattern map)
	    (quail-defrule-internal
	     (concat key " ")
	     (vector (concat (aref (car pattern) 0) " "))  map)
	    (setq key (concat (car e1) semi-vowel-key (car e2))
		  pattern (lrt-compose-c-s-v (cdr e1) semi-vowel-char
					     (nthcdr 2 e2)))
	    (quail-defrule-internal key pattern map)
	    (quail-defrule-internal
	     (concat key " ")
	     (vector (concat (aref (car pattern) 0) " "))  map)
	    (setq l2 (cdr l2)))
	  (setq l1 (cdr l1)))

	;; Vowels.
	(setq l1 lrt-vowel-table)
	(while l1
	  (setq e1 (car l1) l1 (cdr l1))
	  (quail-defrule-internal (car e1) (vector (nth 1 e1)) map))

	;; Tone-marks.
	(setq l1 lrt-tone-mark-table)
	(while l1
	  (setq e1 (car l1) l1 (cdr l1))
	  (quail-defrule-internal (car e1) (cdr e1) map))

	map)))

(quail-define-package
 "lao-lrt" "Lao" "(1E(BR" t
 "Lao input method using LRT (Lao Roman Transcription).
`\\' (backslash) + number-key	=> (1p(B,(1q(B,(1r(B,...	LAO DIGIT ZERO, ONE, TWO, ...
`\\' (backslash) + `\\'		=> (1f(B		LAO KO LA (REPETITION)
`\\' (backslash) + `$'		=> (1O(B		LAO ELLIPSIS
"
 '(("k" . lrt-handle-maa-sakod)
   ("g" . lrt-handle-maa-sakod)
   ("y" . lrt-handle-maa-sakod)
   ("d" . lrt-handle-maa-sakod)
   ("n" . lrt-handle-maa-sakod)
   ("b" . lrt-handle-maa-sakod)
   ("m" . lrt-handle-maa-sakod)
   ("v" . lrt-handle-maa-sakod)
   ("w" . lrt-handle-maa-sakod)
   ("'" . lrt-handle-tone-mark)
   ("\"" . lrt-handle-tone-mark)
   ("^" . lrt-handle-tone-mark)
   ("+" . lrt-handle-tone-mark)
   ("~" . lrt-handle-tone-mark))
 'forget-last-selection 'deterministic 'kbd-translate 'show-layout
  nil nil nil nil nil t)

(lrt-generate-quail-map)

;; Additional key definitions for Lao digits.

(quail-defrule "\\0" ?(1p(B)
(quail-defrule "\\1" ?(1q(B)
(quail-defrule "\\2" ?(1r(B)
(quail-defrule "\\3" ?(1s(B)
(quail-defrule "\\4" ?(1t(B)
(quail-defrule "\\5" ?(1u(B)
(quail-defrule "\\6" ?(1v(B)
(quail-defrule "\\7" ?(1w(B)
(quail-defrule "\\8" ?(1x(B)
(quail-defrule "\\9" ?(1y(B)
(quail-defrule "\\\\" ?(1f(B)
(quail-defrule "\\$" ?(1O(B)

;;; quail/lrt.el ends here