Function: ethio-fidel-to-sera-region
ethio-fidel-to-sera-region is an autoloaded, interactive and
byte-compiled function defined in ethio-util.el.gz.
Signature
(ethio-fidel-to-sera-region BEGIN END &optional SECONDARY FORCE)
Documentation
Convert all the FIDEL characters in the region to the SERA format.
FIDEL is the Amharic alphabet; SERA (System for Ethiopic Representation
in ASCII) is the Latin representation of Ethiopic script.
The variable ethio-primary-language specifies the primary
language and ethio-secondary-language specifies the secondary.
If the 3rd argument SECONDARY is given and non-nil, convert the region so that it begins with the secondary language; otherwise with the primary language.
If the 4th argument FORCE is given and non-nil, convert even if the buffer is read-only.
See also the descriptions of the variables
ethio-use-colon-for-colon(var)/ethio-use-colon-for-colon(fun), ethio-use-three-dot-question(var)/ethio-use-three-dot-question(fun),
ethio-quote-vowel-always and ethio-numeric-reduction.
Probably introduced at or before Emacs version 21.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/language/ethio-util.el.gz
;;;###autoload
(defun ethio-fidel-to-sera-region (begin end &optional secondary force)
"Convert all the FIDEL characters in the region to the SERA format.
FIDEL is the Amharic alphabet; SERA (System for Ethiopic Representation
in ASCII) is the Latin representation of Ethiopic script.
The variable `ethio-primary-language' specifies the primary
language and `ethio-secondary-language' specifies the secondary.
If the 3rd argument SECONDARY is given and non-nil, convert
the region so that it begins with the secondary language; otherwise with
the primary language.
If the 4th argument FORCE is given and non-nil, convert even if the
buffer is read-only.
See also the descriptions of the variables
`ethio-use-colon-for-colon', `ethio-use-three-dot-question',
`ethio-quote-vowel-always' and `ethio-numeric-reduction'."
(interactive "r\nP")
(if (and buffer-read-only
(not force)
(not (y-or-n-p "Buffer is read-only. Force to convert? ")))
(error ""))
(save-restriction
(narrow-to-region begin end)
(let ((buffer-read-only nil)
(mode (if secondary
ethio-secondary-language
ethio-primary-language))
(flag (if (ethio-prefer-amharic-p) "\\~amh " "\\~tir "))
p ch)
(goto-char (point-min))
(ethio-adjust-robin)
(unless (eq mode 'english)
(setq mode 'ethiopic))
(if (and (eq mode 'english) (looking-at "\\ce"))
(setq mode 'ethiopic))
(if (and (eq mode 'ethiopic) (looking-at "\\Ce"))
(setq mode 'english))
(insert (if (eq mode 'english) "\\~eng " flag))
(while (not (eobp))
(if (eq mode 'english)
(progn
(if (re-search-forward "\\(\\ce\\|\\\\\\)" nil 0)
(forward-char -1))
(cond
((eq (following-char) ?\\)
(insert "\\")
(forward-char 1))
((looking-at "\\ce")
(insert flag)
(setq mode 'ethiopic))))
;; If we reach here, mode is ethiopic.
(setq p (point))
(if (re-search-forward "[a-z,.;:'`?\\<&]" nil 0)
(forward-char -1))
(save-restriction
(narrow-to-region p (point))
(robin-invert-region (point-min) (point-max) "ethiopic-sera")
;; ethio-quote-vowel-always
(goto-char (point-min))
(while (re-search-forward "'[eauio]" nil t)
(save-excursion
(forward-char -2)
(setq ch (preceding-char))
(if (or (and (>= ch ?a) (<= ch ?z))
(and (>= ch ?A) (<= ch ?Z)))
(if (and (not ethio-quote-vowel-always)
(memq ch '(?e ?a ?u ?i ?o ?E ?A ?I)))
(delete-char 1))
(delete-char 1))))
;; ethio-W-sixth-always
(unless ethio-W-sixth-always
(goto-char (point-min))
(while (search-forward "W'" nil t)
(delete-char -1)
(insert "u")))
;; ethio-numeric-reduction
(when (> ethio-numeric-reduction 0)
(goto-char (point-min))
(while (re-search-forward "\\([0-9]\\)`\\([0-9]\\)" nil t)
(replace-match "\\1\\2")
(forward-char -1)))
(when (= ethio-numeric-reduction 2)
(goto-char (point-min))
(while (re-search-forward "\\([0-9]\\)1\\(0+\\)" nil t)
(replace-match "\\1\\2")))
(goto-char (point-max)))
(cond
((looking-at "[a-z]")
(insert"\\~eng ")
(setq mode 'english))
((looking-at "[,.;:'`\\]+")
(insert "\\")
(goto-char (1+ (match-end 0))))
((= (following-char) ??)
(if ethio-use-three-dot-question
(insert "\\"))
(forward-char 1))
((looking-at "[<&]")
(if (or (and (boundp 'ethio-sera-being-called-by-w3)
ethio-sera-being-called-by-w3)
(and (boundp 'sera-being-called-by-w3)
sera-being-called-by-w3))
(search-forward (if (= (following-char) ?<) ">" "&") nil 0)
(forward-char 1)))))))))