-(macro
- (handle-mark
- (delete @-)
- ;; At first, cancel the tone mark if already put.
- (move T) (select 0)
- (move M)
- (cond (V-3
- ;; Tripple-vowel
- ;; Put a tone mark on the last vowel if it is ê, or ơ.
- ;; Otherwise put a tone mark on the second vowel.
- (cond ((| (= V-1 ?ê) (= V-1 ?ơ) (= V-1 ?Ê) (= V-1 ?Ơ)))
- (1 (move @-))))
- (V-2
- ;; Double-vowel
- ;; Put a tone mark on the last vowel in the following cases:
- ;; * The last vowel is â, ă, ê, ô, ơ, ư, or ư (i.e. non-ASCII).
- ;; * The initial consonant and the first vowel is "gi" or "qu".
- ;; * tone-mark-on-last is customized to 1 in such equivocal
- ;; cases as "oa", "oe", "oo", and "uy".
- ;; Otherwise put a tone mark on the first vowel.
- (cond ((| (> V-1 127)
- (& (| (= C ?g) (= C ?G)) (| (= V-2 ?i) (= V-2 ?I)))
- (& (| (= C ?q) (= C ?Q)) (| (= V-2 ?u) (= V-2 ?U)))
- (& (| tone-mark-on-last (> C-AFTER-V))
- (| (& (| (= V-2 ?o) (= V-2 ?O))
- (| (= V-1 ?a) (= V-1 ?A) (= V-1 ?e) (= V-1 ?E)
- (= V-1 ?o) (= V-1 ?O)))
- (& (| (= V-2 ?u) (= V-2 ?U))
- (| (= V-1 ?y) (= V-1 ?Y)))))))
- (1 (move @-)))))
- (select SELECT)
- (mark T)
- (move @>)))