comparison 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
comparison
equal deleted inserted replaced
90267:e5855ea89245 90268:d88caeac70d7
1554 :group 'files 1554 :group 'files
1555 :group 'mule 1555 :group 'mule
1556 :type '(repeat (cons (regexp :tag "Regexp") 1556 :type '(repeat (cons (regexp :tag "Regexp")
1557 (symbol :tag "Coding system")))) 1557 (symbol :tag "Coding system"))))
1558 1558
1559 (defun auto-coding-regexp-alist-lookup (from to)
1560 "Lookup `auto-coding-regexp-alist' for the contents of the current buffer.
1561 The value is a coding system is specified for the region FROM and TO,
1562 or nil."
1563 (save-excursion
1564 (goto-char from)
1565 (let ((alist auto-coding-regexp-alist)
1566 coding-system)
1567 (while (and alist (not coding-system))
1568 (let ((regexp (car (car alist))))
1569 (if enable-multibyte-characters
1570 (setq regexp (string-to-multibyte regexp)))
1571 (if (re-search-forward regexp to t)
1572 (setq coding-system (cdr (car alist)))
1573 (setq alist (cdr alist)))))
1574 coding-system)))
1575
1559 ;; See the bottom of this file for built-in auto coding functions. 1576 ;; See the bottom of this file for built-in auto coding functions.
1560 (defcustom auto-coding-functions '(sgml-xml-auto-coding-function 1577 (defcustom auto-coding-functions '(sgml-xml-auto-coding-function
1561 sgml-html-meta-auto-coding-function) 1578 sgml-html-meta-auto-coding-function)
1562 "A list of functions which attempt to determine a coding system. 1579 "A list of functions which attempt to determine a coding system.
1563 1580
1613 `auto-coding-regexp-alist', `coding:', or `auto-coding-functions' 1630 `auto-coding-regexp-alist', `coding:', or `auto-coding-functions'
1614 indicating by what CODING is specified. Note that the validity 1631 indicating by what CODING is specified. Note that the validity
1615 of CODING is not checked; it's callers responsibility to check 1632 of CODING is not checked; it's callers responsibility to check
1616 it. 1633 it.
1617 1634
1618 If nothing is specified, the return value is nil. 1635 If nothing is specified, the return value is nil."
1619
1620 The variable `set-auto-coding-function' (which see) is set to this
1621 function by default."
1622 (or (let ((coding-system (auto-coding-alist-lookup filename))) 1636 (or (let ((coding-system (auto-coding-alist-lookup filename)))
1623 (if coding-system 1637 (if coding-system
1624 (cons coding-system 'auto-coding-alist))) 1638 (cons coding-system 'auto-coding-alist)))
1625 ;; Try using `auto-coding-regexp-alist'. 1639 ;; Try using `auto-coding-regexp-alist'.
1626 (save-excursion 1640 (let ((coding-system (auto-coding-regexp-alist-lookup (point)
1627 (let ((alist auto-coding-regexp-alist) 1641 (+ (point) size))))
1628 coding-system) 1642 (if coding-system
1629 (while (and alist (not coding-system)) 1643 (cons coding-system 'auto-coding-regexp-alist)))
1630 (let ((regexp (car (car alist))))
1631 (when (re-search-forward regexp (+ (point) size) t)
1632 (setq coding-system (cdr (car alist)))))
1633 (setq alist (cdr alist)))
1634 (if coding-system
1635 (cons coding-system 'auto-coding-regexp-alist))))
1636 (let* ((case-fold-search t) 1644 (let* ((case-fold-search t)
1637 (head-start (point)) 1645 (head-start (point))
1638 (head-end (+ head-start (min size 1024))) 1646 (head-end (+ head-start (min size 1024)))
1639 (tail-start (+ head-start (max (- size 3072) 0))) 1647 (tail-start (+ head-start (max (- size 3072) 0)))
1640 (tail-end (+ head-start size)) 1648 (tail-end (+ head-start size))
1723 (cons coding-system 'auto-coding-functions))))) 1731 (cons coding-system 'auto-coding-functions)))))
1724 1732
1725 (defun set-auto-coding (filename size) 1733 (defun set-auto-coding (filename size)
1726 "Return coding system for a file FILENAME of which SIZE bytes follow point. 1734 "Return coding system for a file FILENAME of which SIZE bytes follow point.
1727 See `find-auto-coding' for how the coding system is found. 1735 See `find-auto-coding' for how the coding system is found.
1728 Return nil if an invalid coding system is found." 1736 Return nil if an invalid coding system is found.
1737
1738 The variable `set-auto-coding-function' (which see) is set to this
1739 function by default."
1729 (let ((found (find-auto-coding filename size))) 1740 (let ((found (find-auto-coding filename size)))
1730 (if (and found (coding-system-p (car found))) 1741 (if (and found (coding-system-p (car found)))
1731 (car found)))) 1742 (car found))))
1732 1743
1733 (setq set-auto-coding-function 'set-auto-coding) 1744 (setq set-auto-coding-function 'set-auto-coding)