emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "coding" in file variable list not effective


From: Kenichi Handa
Subject: Re: "coding" in file variable list not effective
Date: Wed, 7 Jan 2004 10:48:16 +0900 (JST)
User-agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/21.3 (sparc-sun-solaris2.6) MULE/5.0 (SAKAKI)

In article <address@hidden>, Sébastien Kirche <address@hidden> writes:

> i have have a file that i am currently editing under osx (actually my 
> .emacs) where i use the euro sign.
> So i save it with iso-latin-9-mac (iso-8859-15) encoding.

> To avoid typing the whole "C-x ret c iso-latin-9-mac C-x C-f filename" 
> for further editing, i placed the setting "coding: iso-latin-9-mac" in 
> my variable list at the end of file.

> I found that it has no effect : M-x describe-current-coding-system 
> shows that i am still in iso-latin-1 which is my default file coding 
> system.
> But if I place the setting in the first line between the -*- marks, the 
> coding is used accordingly.

Thank you for the report.  I've just installed the attached
fix.

---
Ken'ichi HANDA
address@hidden

        * international/mule.el (set-auto-coding): Fix for the case that
        end-of-line is only CR.

*** mule.el.~1.196.~    Wed Dec  3 16:34:51 2003
--- mule.el     Wed Jan  7 10:41:30 2004
***************
*** 1662,1692 ****
                  (setq coding-system nil)))))
  
        ;; If no coding: tag in the head, check the tail.
        (when (and tail-found (not coding-system))
          (goto-char tail-start)
!         (search-forward "\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:"
              ;; in its line.
              (let* ((prefix (regexp-quote (match-string 1)))
                     (suffix (regexp-quote (match-string 2)))
                     (re-coding
                      (concat
!                      "^" prefix
                       ;; N.B. without the \n below, the regexp can
                       ;; eat newlines.
!                      "[ \t]*coding[ \t]*:[ \t]*\\([^ \t\n]+\\)[ \t]*"
!                      suffix "$"))
                     (re-unibyte
                      (concat
!                      "^" prefix
!                      "[ \t]*unibyte[ \t]*:[ \t]*\\([^ \t\n]+\\)[ \t]*"
!                      suffix "$"))
                     (re-end
!                     (concat "^" prefix "[ \t]*End *:[ \t]*" suffix "$"))
!                    (pos (point)))
                (re-search-forward re-end tail-end 'move)
                (setq tail-end (point))
                (goto-char pos)
--- 1662,1697 ----
                  (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)
!         (re-search-forward "[\r\n]\^L" nil t)
          (if (re-search-forward
!              "[\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
!                      "[\r\n]" prefix
                       ;; N.B. without the \n below, the regexp can
                       ;; eat newlines.
!                      "[ \t]*coding[ \t]*:[ \t]*\\([^ \t\r\n]+\\)[ \t]*"
!                      suffix "[\r\n]"))
                     (re-unibyte
                      (concat
!                      "[\r\n]" prefix
!                      "[ \t]*unibyte[ \t]*:[ \t]*\\([^ \t\r\n]+\\)[ \t]*"
!                      suffix "[\r\n]"))
                     (re-end
!                     (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)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]