]> git.eshelyaron.com Git - emacs.git/commitdiff
(detect-coding-with-priority): Restore the internal database.
authorKenichi Handa <handa@m17n.org>
Mon, 15 Mar 1999 00:51:20 +0000 (00:51 +0000)
committerKenichi Handa <handa@m17n.org>
Mon, 15 Mar 1999 00:51:20 +0000 (00:51 +0000)
lisp/international/mule-util.el

index 70872b636dc0c5cb866c52f90f2287f70c8f5977..82114740c20beb7ce7e6e9c1a0c34c7627abed72 100644 (file)
@@ -258,13 +258,19 @@ or one is an alias of the other."
   "Detect a coding system of the text between FROM and TO with PRIORITY-LIST.
 PRIORITY-LIST is an alist of coding categories vs the corresponding
 coding systems ordered by priority."
-  `(let* ((prio-list ,priority-list)
-         (coding-category-list coding-category-list)
-         ,@(mapcar (function (lambda (x) (list x x))) coding-category-list))
-     (mapcar (function (lambda (x) (set (car x) (cdr x))))
-            prio-list)
-     (set-coding-priority (mapcar (function (lambda (x) (car x))) prio-list))
-     (detect-coding-region ,from ,to)))
+  `(unwind-protect
+       (let* ((prio-list ,priority-list)
+             (coding-category-list coding-category-list)
+             ,@(mapcar (function (lambda (x) (list x x)))
+                       coding-category-list))
+        (mapcar (function (lambda (x) (set (car x) (cdr x))))
+                prio-list)
+        (set-coding-priority (mapcar (function (lambda (x) (car x)))
+                                     prio-list))
+        (detect-coding-region ,from ,to))
+     ;; We must restore the internal database.
+     (set-coding-priority coding-category-list)
+     (update-coding-systems-internal)))
 
 ;;;###autoload
 (defun detect-coding-with-language-environment (from to lang-env)