(require 'quail)
(require 'ethio-util)
-
-;;
-;; Ethiopic word separator vs. ASCII space
-;;
-
-(defvar ethio-prefer-ascii-space t)
-(make-variable-buffer-local 'ethio-prefer-ascii-space)
-
-(defun ethio-toggle-space nil
- "Toggle ASCII space and Ethiopic separator for keyboard input."
- (interactive)
- (setq ethio-prefer-ascii-space
- (not ethio-prefer-ascii-space))
- (force-mode-line-update))
-
-(defun ethio-insert-space (arg)
- "Insert ASCII spaces or Ethiopic word separators depending on context.
-
-If the current word separator (indicated in mode-line) is the ASCII space,
-insert an ASCII space. With ARG, insert that many ASCII spaces.
-
-If the current word separator is the colon-like Ethiopic word
-separator and the point is preceded by `an Ethiopic punctuation mark
-followed by zero or more ASCII spaces', then insert also an ASCII
-space. With ARG, insert that many ASCII spaces.
-
-Otherwise, insert a colon-like Ethiopic word separator. With ARG, insert that
-many Ethiopic word separators."
-
- (interactive "*p")
- (cond
- (ethio-prefer-ascii-space
- (insert-char 32 arg))
- ((save-excursion
- (skip-chars-backward " ")
- (memq (preceding-char)
- '(?\e$(3$h\e(B ?\e$(3$i\e(B ?\e$(3$j\e(B ?\e$(3$k\e(B ?\e$(3$l\e(B ?\e$(3$m\e(B ?\e$(3$n\e(B ?\e$(3$o\e(B ?\e$(3%t\e(B ?\e$(3%u\e(B ?\e$(3%v\e(B ?\e$(3%w\e(B ?\e$(3%x\e(B)))
- (insert-char 32 arg))
- (t
- (insert-char ?\e$(3$h\e(B arg))))
-
-(defun ethio-insert-ethio-space (arg)
- "Insert the Ethiopic word delimiter (the colon-like character).
-With ARG, insert that many delimiters."
- (interactive "*p")
- (insert-char ?\e$(3$h\e(B arg))
-
-;;
-;; Ethiopic punctuation vs. ASCII punctuation
-;;
-
-(defvar ethio-prefer-ascii-punctuation nil)
-(make-variable-buffer-local 'ethio-prefer-ascii-punctuation)
-
-(defun ethio-toggle-punctuation nil
- "Toggle Ethiopic punctuations and ASCII punctuations for keyboard input."
- (interactive)
- (setq ethio-prefer-ascii-punctuation
- (not ethio-prefer-ascii-punctuation))
- (let* ((keys '("." ".." "..." "," ",," ";" ";;" ":" "::" ":::" "*" "**"))
- (puncs
- (if ethio-prefer-ascii-punctuation
- '(?. [".."] ["..."] ?, [",,"] ?\; [";;"] ?: ["::"] [":::"] ?* ["**"])
- '(?\e$(3$i\e(B ?\e$(3%u\e(B ?. ?\e$(3$j\e(B ?, ?\e$(3$k\e(B ?\; ?\e$(3$h\e(B ?\e$(3$i\e(B ?: ?* ?\e$(3$o\e(B))))
- (while keys
- (quail-defrule (car keys) (car puncs) "ethiopic")
- (setq keys (cdr keys)
- puncs (cdr puncs)))
- (force-mode-line-update)))
-
-;;
-;; Gemination
-;;
-
-(defun ethio-gemination nil
- "Compose the character before the point with the Ethiopic gemination mark.
-If the characater is already composed, decompose it and remove the gemination
-mark."
- (interactive "*")
- (cond
- ((eq (char-charset (preceding-char)) 'ethiopic)
- (insert "\e$(3%s\e(B")
- (compose-region
- (save-excursion (backward-char 2) (point))
- (point))
- (forward-char 1))
- ((eq (char-charset (preceding-char)) 'leading-code-composition)
- (decompose-region
- (save-excursion (backward-char 1) (point))
- (point))
- (delete-backward-char 1))
- (t
- (error ""))))
;;
;; The package "ethiopic"
'("\e$(3$O#U!.\e(B "
(ethio-prefer-ascii-space "_" "\e$(3$h\e(B")
(ethio-prefer-ascii-punctuation "." "\e$(3$i\e(B"))
- t " KEYS AND FUNCTIONS
+ t " QUAIL PACKAGE FOR ETHIOPIC (TIGRIGNA AND AMHARIC)
+
+When you activate this package, Ethio minor mode is also turned on.
+
+ KEYS AND FUNCTIONS
F2 or `M-x ethio-toggle-space'
Toggles space characters for keyboard input. The current mode is
If the characater is already composed, decompose it and remove the
gemination mark."
- '(([f2] . ethio-toggle-space)
- ([f3] . ethio-toggle-punctuation)
- (" " . ethio-insert-space)
- ([?\S- ] . ethio-insert-ethio-space)
- ([?\C-'] . ethio-gemination))
+ ;; The following keys should work as defined in lisp/language/ethio-util,
+ ;; even during the translation.
+ '(([f2] . quail-execute-non-quail-command)
+ ([f3] . quail-execute-non-quail-command)
+ (" " . quail-execute-non-quail-command)
+ ([?\S- ] . quail-execute-non-quail-command)
+ ([?\C-'] . quail-execute-non-quail-command))
t t)
-;; These keys should work even if translation region is not active.
-(define-key quail-mode-map [f2] 'ethio-toggle-space)
-(define-key quail-mode-map [f3] 'ethio-toggle-punctuation)
-(define-key quail-mode-map " " 'ethio-insert-space)
-(define-key quail-mode-map [?\S- ] 'ethio-insert-ethio-space)
-(define-key quail-mode-map [?\C-'] 'ethio-gemination)
-
(quail-define-rules
("he" ?\e$(3!!\e(B)
("hu" ?\e$(3!"\e(B)
("`1000000" ["\e$(3%$%%\e(B"])
)
-;; The translation of `a' depends on the language (Tigrigna or Amharic).
(add-hook 'quail-mode-hook
(lambda nil
- (if (string= (quail-name) "ethiopic")
- (quail-defrule "a"
- (if (ethio-prefer-amharic-p) ?\e$(3"c\e(B ?\e$(3"f\e(B)
- "ethiopic"))))
+ (if (not (string= (quail-name) "ethiopic"))
+ nil
+ ;; Also turn on the Ethio minor mode.
+ (ethio-mode 1)
+ ;; The translation of `a' depends on the language
+ ;; (either Tigrigna or Amharic).
+ (quail-defrule "a"
+ (if (ethio-prefer-amharic-p) ?\e$(3"c\e(B ?\e$(3"f\e(B)
+ "ethiopic"))))
;;; quail/ethiopic.el ends here