Function: ogonek-prefixify-region

ogonek-prefixify-region is an interactive and byte-compiled function defined in ogonek.el.gz.

Signature

(ogonek-prefixify-region START END FROM-ENCODING PREFIX-CHAR)

Documentation

In a region, replace FROM-encoded Polish characters with PREFIX pairs.

A PREFIX pair generated consists of PREFIX-CHAR and the respective character listed in the ogonek-prefix-code constant. PREFIX-CHAR itself gets doubled.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/international/ogonek.el.gz
(defun ogonek-prefixify-region (start end from-encoding prefix-char)
  "In a region, replace FROM-encoded Polish characters with PREFIX pairs.
A PREFIX pair generated consists of PREFIX-CHAR and the respective
character listed in the `ogonek-prefix-code' constant.
PREFIX-CHAR itself gets doubled."
  (interactive (progn (barf-if-buffer-read-only)
    (list
    (region-beginning)
    (region-end)
    (ogonek-read-encoding "From code" 'ogonek-prefix-from-encoding)
    (ogonek-read-prefix "Prefix character" 'ogonek-prefix-char))))
  (let*
      ((from-code (ogonek-lookup-encoding from-encoding))
       (to-code ogonek-prefix-code)
       (recoding-pairs  ; `ogonek-prefix-char' added for doubling
        (ogonek-zip-lists
         (cons prefix-char from-code)
         (cons prefix-char to-code))))
    (save-excursion
      (goto-char start)
      (while (< (point) end)
        (let ((pair (assoc (following-char) recoding-pairs)))
          (if (null pair)
              ;; not a Polish character -- skip it
              (forward-char 1)
            ;; Polish character -- insert a prefix pair instead
            (delete-char 1)
            (insert ogonek-prefix-char)
            (insert (cdr pair))
            ;; the region is now one character longer
            (setq end (1+ end))))))))