diff options
| author | Kenichi Handa | 2004-01-07 01:43:32 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2004-01-07 01:43:32 +0000 |
| commit | c251286b57fd9d477ea403ce7038fc47347e6282 (patch) | |
| tree | 3be89e04351d0e8ae893d782cd3859573a19d614 | |
| parent | 9da88f37868c461a5d9fffb5717b6b3b953d1367 (diff) | |
| download | emacs-c251286b57fd9d477ea403ce7038fc47347e6282.tar.gz emacs-c251286b57fd9d477ea403ce7038fc47347e6282.zip | |
(set-auto-coding): Fix for the case that end-of-line is only CR.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/international/mule.el | 29 |
2 files changed, 22 insertions, 12 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index bdfff47a942..7af40206b0a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2004-01-07 Kenichi Handa <handa@m17n.org> | ||
| 2 | |||
| 3 | * international/mule.el (set-auto-coding): Fix for the case that | ||
| 4 | end-of-line is only CR. | ||
| 5 | |||
| 1 | 2004-01-07 Kim F. Storm <storm@cua.dk> | 6 | 2004-01-07 Kim F. Storm <storm@cua.dk> |
| 2 | 7 | ||
| 3 | * subr.el (event-start, event-end): Doc fix. | 8 | * subr.el (event-start, event-end): Doc fix. |
diff --git a/lisp/international/mule.el b/lisp/international/mule.el index 1674f7bf61a..5ba23ce9514 100644 --- a/lisp/international/mule.el +++ b/lisp/international/mule.el | |||
| @@ -1662,31 +1662,36 @@ function by default." | |||
| 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) |