Mercurial > emacs
diff lisp/international/mule.el @ 90268:d88caeac70d7
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-2
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (base, patch 1-3)
- tag of miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-704
- Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0 (patch 700-704)
- Update from CVS
- Merge from gnus--rel--5.10
- Update from CVS: lisp/cus-edit.el (customize-rogue): Minor doc fix.
* miles@gnu.org--gnu-2005/gnus--rel--5.10 (patch 185-186)
- Merge from emacs--cvs-trunk--0
- Update from CVS
author | Miles Bader <miles@gnu.org> |
---|---|
date | Thu, 19 Jan 2006 07:11:42 +0000 |
parents | 7beb78bc1f8e ac1d7b21ddfc |
children | 0f622530c46c |
line wrap: on
line diff
--- a/lisp/international/mule.el Thu Jan 19 06:54:47 2006 +0000 +++ b/lisp/international/mule.el Thu Jan 19 07:11:42 2006 +0000 @@ -1556,6 +1556,23 @@ :type '(repeat (cons (regexp :tag "Regexp") (symbol :tag "Coding system")))) +(defun auto-coding-regexp-alist-lookup (from to) + "Lookup `auto-coding-regexp-alist' for the contents of the current buffer. +The value is a coding system is specified for the region FROM and TO, +or nil." + (save-excursion + (goto-char from) + (let ((alist auto-coding-regexp-alist) + coding-system) + (while (and alist (not coding-system)) + (let ((regexp (car (car alist)))) + (if enable-multibyte-characters + (setq regexp (string-to-multibyte regexp))) + (if (re-search-forward regexp to t) + (setq coding-system (cdr (car alist))) + (setq alist (cdr alist))))) + coding-system))) + ;; See the bottom of this file for built-in auto coding functions. (defcustom auto-coding-functions '(sgml-xml-auto-coding-function sgml-html-meta-auto-coding-function) @@ -1615,24 +1632,15 @@ of CODING is not checked; it's callers responsibility to check it. -If nothing is specified, the return value is nil. - -The variable `set-auto-coding-function' (which see) is set to this -function by default." +If nothing is specified, the return value is nil." (or (let ((coding-system (auto-coding-alist-lookup filename))) (if coding-system (cons coding-system 'auto-coding-alist))) ;; Try using `auto-coding-regexp-alist'. - (save-excursion - (let ((alist auto-coding-regexp-alist) - coding-system) - (while (and alist (not coding-system)) - (let ((regexp (car (car alist)))) - (when (re-search-forward regexp (+ (point) size) t) - (setq coding-system (cdr (car alist))))) - (setq alist (cdr alist))) - (if coding-system - (cons coding-system 'auto-coding-regexp-alist)))) + (let ((coding-system (auto-coding-regexp-alist-lookup (point) + (+ (point) size)))) + (if coding-system + (cons coding-system 'auto-coding-regexp-alist))) (let* ((case-fold-search t) (head-start (point)) (head-end (+ head-start (min size 1024))) @@ -1725,7 +1733,10 @@ (defun set-auto-coding (filename size) "Return coding system for a file FILENAME of which SIZE bytes follow point. See `find-auto-coding' for how the coding system is found. -Return nil if an invalid coding system is found." +Return nil if an invalid coding system is found. + +The variable `set-auto-coding-function' (which see) is set to this +function by default." (let ((found (find-auto-coding filename size))) (if (and found (coding-system-p (car found))) (car found))))