]> git.eshelyaron.com Git - emacs.git/commitdiff
(set-auto-coding): Fix for the case that end-of-line is only CR.
authorKenichi Handa <handa@m17n.org>
Wed, 7 Jan 2004 01:43:32 +0000 (01:43 +0000)
committerKenichi Handa <handa@m17n.org>
Wed, 7 Jan 2004 01:43:32 +0000 (01:43 +0000)
lisp/ChangeLog
lisp/international/mule.el

index bdfff47a9429504cd196dd9beeeb239ae1738012..7af40206b0ac6a58463b8544380719fb5eeeddb3 100644 (file)
@@ -1,3 +1,8 @@
+2004-01-07  Kenichi Handa  <handa@m17n.org>
+
+       * international/mule.el (set-auto-coding): Fix for the case that
+       end-of-line is only CR.
+
 2004-01-07  Kim F. Storm  <storm@cua.dk>
 
        * subr.el (event-start, event-end): Doc fix.
index 1674f7bf61acdd04eb84eb25755891c8cfa47948..5ba23ce9514a9f56f651a661229a8c524cab47e6 100644 (file)
@@ -1662,31 +1662,36 @@ function by default."
                  (setq coding-system nil)))))
 
        ;; If no coding: tag in the head, check the tail.
+       ;; Here we must pay attention to the case that the end-of-line
+       ;; is just "\r" and we can't use "^" nor "$" in regexp.
        (when (and tail-found (not coding-system))
          (goto-char tail-start)
-         (search-forward "\n\^L" nil t)
+         (re-search-forward "[\r\n]\^L" nil t)
          (if (re-search-forward
-              "^\\(.*\\)[ \t]*Local Variables:[ \t]*\\(.*\\)$" tail-end t)
-         ;; The prefix is what comes before "local variables:" in its
-          ;; line.  The suffix is what comes after "local variables:"
+              "[\r\n]\\([^[\r\n]*\\)[ \t]*Local Variables:[ \t]*\\([^\r\n]*\\)[\r\n]" 
+              tail-end t)
+             ;; The prefix is what comes before "local variables:" in its
+             ;; line.  The suffix is what comes after "local variables:"
              ;; in its line.
              (let* ((prefix (regexp-quote (match-string 1)))
                     (suffix (regexp-quote (match-string 2)))
                     (re-coding
                      (concat
-                      "^" prefix
+                      "[\r\n]" prefix
                       ;; N.B. without the \n below, the regexp can
                       ;; eat newlines.
-                      "[ \t]*coding[ \t]*:[ \t]*\\([^ \t\n]+\\)[ \t]*"
-                      suffix "$"))
+                      "[ \t]*coding[ \t]*:[ \t]*\\([^ \t\r\n]+\\)[ \t]*"
+                      suffix "[\r\n]"))
                     (re-unibyte
                      (concat
-                      "^" prefix
-                      "[ \t]*unibyte[ \t]*:[ \t]*\\([^ \t\n]+\\)[ \t]*"
-                      suffix "$"))
+                      "[\r\n]" prefix
+                      "[ \t]*unibyte[ \t]*:[ \t]*\\([^ \t\r\n]+\\)[ \t]*"
+                      suffix "[\r\n]"))
                     (re-end
-                     (concat "^" prefix "[ \t]*End *:[ \t]*" suffix "$"))
-                    (pos (point)))
+                     (concat "[\r\n]" prefix "[ \t]*End *:[ \t]*" suffix 
+                             "[\r\n]?"))
+                    (pos (1- (point))))
+               (forward-char -1)       ; skip back \r or \n.
                (re-search-forward re-end tail-end 'move)
                (setq tail-end (point))
                (goto-char pos)