Function: ogonek-deprefixify-region

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

Signature

(ogonek-deprefixify-region START END PREFIX-CHAR TO-ENCODING)

Documentation

In a region, replace PREFIX pairs with their corresponding TO-encodings.

PREFIX-CHAR followed by a Polish character from the ogonek-prefix-code list is replaced with the corresponding TO-encoded character. A doubled PREFIX-CHAR gets replaced with a single one. A combination of PREFIX-CHAR followed by a non-Polish character, that is one not listed in the ogonek-prefix-code constant, is left unchanged.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/international/ogonek.el.gz
(defun ogonek-deprefixify-region (start end prefix-char to-encoding)
  "In a region, replace PREFIX pairs with their corresponding TO-encodings.
PREFIX-CHAR followed by a Polish character from the `ogonek-prefix-code'
list is replaced with the corresponding TO-encoded character.  A doubled
PREFIX-CHAR gets replaced with a single one.  A combination of PREFIX-CHAR
followed by a non-Polish character, that is one not listed in the
`ogonek-prefix-code' constant, is left unchanged."
  (interactive (progn (barf-if-buffer-read-only)
                (list (region-beginning)
                      (region-end)
                      (ogonek-read-prefix
                        "Prefix character" 'ogonek-prefix-char)
                      (ogonek-read-encoding
                       "To code" 'ogonek-prefix-to-encoding))))
  (let*
      ((from-code ogonek-prefix-code)
       (to-code (ogonek-lookup-encoding to-encoding))
       (recoding-pairs
        (ogonek-zip-lists
          (cons prefix-char from-code)
          (cons prefix-char to-code))))
    (save-excursion
      (goto-char start)
      (while (< (point) end)
        (forward-char 1)
       (if (or (not (= (preceding-char) prefix-char)) (= (point) end))
           ;; non-prefix character or the end-of-region -- do nothing
           ()
         ;; now, we can check the next character
         (let ((pair (assoc (following-char) recoding-pairs)))
           (if (null pair)
               ;; `following-char' is not a Polish character nor it is
               ;;  `prefix-char' since the one is among `recoding-pairs'
               (forward-char 1)
           ;; else prefix followed by a Polish character has been found
           ;; replace it by the corresponding Polish character
           (backward-char 1)
           (delete-char 2)
           (insert (cdr pair))
           ;; the region got shorter by one character
           (setq end (1- end)))))))))