From bc10f81b82bad77ff1b3717af899108d5b1feb7c Mon Sep 17 00:00:00 2001 From: Kenichi Handa Date: Fri, 8 Jan 1999 04:19:24 +0000 Subject: [PATCH] (decompose-region): Do decomposition on temporary unibyte buffer. --- lisp/international/mule-util.el | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/lisp/international/mule-util.el b/lisp/international/mule-util.el index 56b85b1778f..0aac9b32328 100644 --- a/lisp/international/mule-util.el +++ b/lisp/international/mule-util.el @@ -336,18 +336,29 @@ Composite characters are broken up into individual components. 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) -- 2.39.2