"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)