# HG changeset patch # User Kenichi Handa # Date 915769164 0 # Node ID 660b6f8b792855ec85e6d9b46e52253d902bbcf4 # Parent 8313b191de2c44fb01af5e428dee9a8ffdfbc378 (decompose-region): Do decomposition on temporary unibyte buffer. diff -r 8313b191de2c -r 660b6f8b7928 lisp/international/mule-util.el --- a/lisp/international/mule-util.el Fri Jan 08 04:19:24 1999 +0000 +++ b/lisp/international/mule-util.el Fri Jan 08 04:19:24 1999 +0000 @@ -336,18 +336,29 @@ When called from a program, expects two arguments, positions (integers or markers) specifying the region." (interactive "r") - (save-excursion - (save-restriction - (narrow-to-region start end) + (let ((buf (current-buffer)) + (cmpchar-head (char-to-string leading-code-composition))) + (with-temp-buffer + (insert-buffer-substring buf start end) + (set-buffer-multibyte nil) (goto-char (point-min)) - (let ((cmpchar-head (char-to-string leading-code-composition))) - (while (search-forward cmpchar-head nil t) - (let ((ch (preceding-char))) - (if (>= ch min-composite-char) - (progn - (delete-char -1) - (insert (decompose-composite-char ch))) - (forward-char 1)))))))) + (while (search-forward cmpchar-head nil t) + (if (looking-at "[\240-\377][\240-\377][\240-\377][\240-\377]+") + (let* ((from (1- (point))) + (to (match-end 0)) + (str (string-as-multibyte (buffer-substring from to)))) + (if (cmpcharp (string-to-char str)) + (progn + (delete-region from to) + (insert (string-as-unibyte (decompose-string str)))) + (goto-char to))))) + (set-buffer-multibyte t) + (let ((tempbuf (current-buffer))) + (save-excursion + (set-buffer buf) + (goto-char start) + (delete-region start end) + (insert-buffer tempbuf)))))) ;;;###autoload (defun decompose-string (string)