Mercurial > emacs
comparison lisp/international/mule.el @ 53526:5c66f1de4907
(set-auto-coding): Fix for the case that end-of-line is only CR.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Wed, 07 Jan 2004 01:43:04 +0000 |
parents | ee5206ee4439 |
children | f357f325cc85 |
comparison
equal
deleted
inserted
replaced
53525:00ccb778950d | 53526:5c66f1de4907 |
---|---|
1660 (setq coding-system (intern (match-string 2))) | 1660 (setq coding-system (intern (match-string 2))) |
1661 (or (coding-system-p coding-system) | 1661 (or (coding-system-p coding-system) |
1662 (setq coding-system nil))))) | 1662 (setq coding-system nil))))) |
1663 | 1663 |
1664 ;; If no coding: tag in the head, check the tail. | 1664 ;; If no coding: tag in the head, check the tail. |
1665 ;; Here we must pay attention to the case that the end-of-line | |
1666 ;; is just "\r" and we can't use "^" nor "$" in regexp. | |
1665 (when (and tail-found (not coding-system)) | 1667 (when (and tail-found (not coding-system)) |
1666 (goto-char tail-start) | 1668 (goto-char tail-start) |
1667 (search-forward "\n\^L" nil t) | 1669 (re-search-forward "[\r\n]\^L" nil t) |
1668 (if (re-search-forward | 1670 (if (re-search-forward |
1669 "^\\(.*\\)[ \t]*Local Variables:[ \t]*\\(.*\\)$" tail-end t) | 1671 "[\r\n]\\([^[\r\n]*\\)[ \t]*Local Variables:[ \t]*\\([^\r\n]*\\)[\r\n]" |
1670 ;; The prefix is what comes before "local variables:" in its | 1672 tail-end t) |
1671 ;; line. The suffix is what comes after "local variables:" | 1673 ;; The prefix is what comes before "local variables:" in its |
1674 ;; line. The suffix is what comes after "local variables:" | |
1672 ;; in its line. | 1675 ;; in its line. |
1673 (let* ((prefix (regexp-quote (match-string 1))) | 1676 (let* ((prefix (regexp-quote (match-string 1))) |
1674 (suffix (regexp-quote (match-string 2))) | 1677 (suffix (regexp-quote (match-string 2))) |
1675 (re-coding | 1678 (re-coding |
1676 (concat | 1679 (concat |
1677 "^" prefix | 1680 "[\r\n]" prefix |
1678 ;; N.B. without the \n below, the regexp can | 1681 ;; N.B. without the \n below, the regexp can |
1679 ;; eat newlines. | 1682 ;; eat newlines. |
1680 "[ \t]*coding[ \t]*:[ \t]*\\([^ \t\n]+\\)[ \t]*" | 1683 "[ \t]*coding[ \t]*:[ \t]*\\([^ \t\r\n]+\\)[ \t]*" |
1681 suffix "$")) | 1684 suffix "[\r\n]")) |
1682 (re-unibyte | 1685 (re-unibyte |
1683 (concat | 1686 (concat |
1684 "^" prefix | 1687 "[\r\n]" prefix |
1685 "[ \t]*unibyte[ \t]*:[ \t]*\\([^ \t\n]+\\)[ \t]*" | 1688 "[ \t]*unibyte[ \t]*:[ \t]*\\([^ \t\r\n]+\\)[ \t]*" |
1686 suffix "$")) | 1689 suffix "[\r\n]")) |
1687 (re-end | 1690 (re-end |
1688 (concat "^" prefix "[ \t]*End *:[ \t]*" suffix "$")) | 1691 (concat "[\r\n]" prefix "[ \t]*End *:[ \t]*" suffix |
1689 (pos (point))) | 1692 "[\r\n]?")) |
1693 (pos (1- (point)))) | |
1694 (forward-char -1) ; skip back \r or \n. | |
1690 (re-search-forward re-end tail-end 'move) | 1695 (re-search-forward re-end tail-end 'move) |
1691 (setq tail-end (point)) | 1696 (setq tail-end (point)) |
1692 (goto-char pos) | 1697 (goto-char pos) |
1693 (when (and set-auto-coding-for-load | 1698 (when (and set-auto-coding-for-load |
1694 (re-search-forward re-unibyte tail-end t)) | 1699 (re-search-forward re-unibyte tail-end t)) |