changeset 24027:660b6f8b7928

(decompose-region): Do decomposition on temporary unibyte buffer.
author Kenichi Handa <handa@m17n.org>
date Fri, 08 Jan 1999 04:19:24 +0000
parents 8313b191de2c
children 7ffc86429459
files lisp/international/mule-util.el
diffstat 1 files changed, 22 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- 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)