comparison lisp/international/mule-util.el @ 88810:c949437b3a53

(detect-coding-with-priority): Rewritten.
author Dave Love <fx@gnu.org>
date Sat, 29 Jun 2002 10:44:03 +0000
parents 8b4e3bbe01d4
children bf78a07ee032
comparison
equal deleted inserted replaced
88809:0d0f856a4c77 88810:c949437b3a53
1 ;;; mule-util.el --- utility functions for mulitilingual environment (mule) 1 ;;; mule-util.el --- utility functions for mulitilingual environment (mule)
2 2
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. 3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
4 ;; Licensed to the Free Software Foundation. 4 ;; Licensed to the Free Software Foundation.
5 ;; Copyright (C) 2002 Free Software Foundation, Inc.
5 6
6 ;; Keywords: mule, multilingual 7 ;; Keywords: mule, multilingual
7 8
8 ;; This file is part of GNU Emacs. 9 ;; This file is part of GNU Emacs.
9 10
263 (let ((eol-type-1 (coding-system-eol-type coding-system-1)) 264 (let ((eol-type-1 (coding-system-eol-type coding-system-1))
264 (eol-type-2 (coding-system-eol-type coding-system-2))) 265 (eol-type-2 (coding-system-eol-type coding-system-2)))
265 (or (eq eol-type-1 eol-type-2) 266 (or (eq eol-type-1 eol-type-2)
266 (and (vectorp eol-type-1) (vectorp eol-type-2))))))) 267 (and (vectorp eol-type-1) (vectorp eol-type-2)))))))
267 268
268 ;; Fixme: delete this?
269 ;;;###autoload 269 ;;;###autoload
270 (defmacro detect-coding-with-priority (from to priority-list) 270 (defmacro detect-coding-with-priority (from to priority-list)
271 "Detect a coding system of the text between FROM and TO with PRIORITY-LIST. 271 "Detect a coding system of the text between FROM and TO with PRIORITY-LIST.
272 PRIORITY-LIST is an alist of coding categories vs the corresponding 272 PRIORITY-LIST is an alist of coding categories vs the corresponding
273 coding systems ordered by priority." 273 coding systems ordered by priority."
274 `(unwind-protect 274 `(with-coding-priority ,(mapcar #'cdr priority-list)
275 (let* ((prio-list ,priority-list) 275 (detect-coding-region ,from ,to)))
276 (coding-category-list coding-category-list) 276 (make-obsolete 'detect-coding-with-priority
277 ,@(mapcar (function (lambda (x) (list x x))) 277 "Use with-coding-priority and detect-coding-region" "22.1")
278 coding-category-list))
279 (mapc (function (lambda (x) (set (car x) (cdr x))))
280 prio-list)
281 (set-coding-priority (mapcar #'car prio-list))
282 (detect-coding-region ,from ,to))
283 ;; We must restore the internal database.
284 (set-coding-priority coding-category-list)
285 (update-coding-systems-internal)))
286 278
287 ;;;###autoload 279 ;;;###autoload
288 (defun detect-coding-with-language-environment (from to lang-env) 280 (defun detect-coding-with-language-environment (from to lang-env)
289 "Detect a coding system of the text between FROM and TO with LANG-ENV. 281 "Detect a coding system of the text between FROM and TO with LANG-ENV.
290 The detection takes into account the coding system priorities for the 282 The detection takes into account the coding system priorities for the