Function: ucs-normalize-block

ucs-normalize-block is a byte-compiled function defined in ucs-normalize.el.gz.

Signature

(ucs-normalize-block FROM TO &optional DECOMPOSITION-TRANSLATION-TABLE COMPOSITION-PREDICATE)

Documentation

Normalize region FROM TO, by sorting the region with canonical-cc.

If DECOMPOSITION-TRANSLATION-TABLE is given, translate region before sorting. If COMPOSITION-PREDICATE is given, then compose the region by using it.

Source Code

;; Defined in /usr/src/emacs/lisp/international/ucs-normalize.el.gz
;;------------------------------------------------------------------------------------------

;; Normalize local region.

(defun ucs-normalize-block
  (from to &optional decomposition-translation-table composition-predicate)
  "Normalize region FROM TO, by sorting the region with canonical-cc.
If DECOMPOSITION-TRANSLATION-TABLE is given, translate region
before sorting.  If COMPOSITION-PREDICATE is given, then compose
the region by using it."
  (save-restriction
    (narrow-to-region from to)
    (goto-char (point-min))
    (if decomposition-translation-table
        (translate-region from to decomposition-translation-table))
    (goto-char (point-min))
    (let ((start (point)) chars); ccc)
      (while (not (eobp))
        (forward-char)
        (when (or (eobp)
                  (= 0 (ucs-normalize-ccc (char-after (point)))))
          (setq chars
                (nconc chars
                       (ucs-normalize-block-compose-chars
                        (string-to-list (buffer-substring start (point)))
                        composition-predicate))
                start (point)))
        ;;(unless ccc (error "Undefined character can not be normalized!"))
        )
      (delete-region (point-min) (point-max))
      (apply 'insert
             (ucs-normalize-compose-chars
              chars composition-predicate)))))