Mercurial > hg > xemacs-beta
diff lisp/files.el @ 5682:dae33b5feffe
Unify #'find-coding-system-magic-cookie-in-file, look_for_coding_system_magic_cookie()
src/ChangeLog addition:
2012-09-07 Aidan Kehoe <kehoea@parhasard.net>
* file-coding.c:
* file-coding.c (snarf_coding_system):
Take a new parameter, FIND_CODING_SYSTEM_P, which indicates that
find_coding_system() should be called.
* file-coding.c (look_for_coding_system_magic_cookie):
* file-coding.c (determine_real_coding_system):
* file-coding.c (undecided_convert):
Use this parameter.
* file-coding.c (Ffind_coding_system_magic_cookie_in_file):
New, moved from files.el, so we can use
look_for_coding_system_magic_cookie's implementation.
* file-coding.c (syms_of_file_coding):
Make Ffind_coding_system_magic_cookie_in_file available.
lisp/ChangeLog addition:
2012-09-07 Aidan Kehoe <kehoea@parhasard.net>
* files.el:
* files.el (find-coding-system-magic-cookie-in-file):
Removed. Move this to C, so we can use
look_for_coding_system_magic_cookie().
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Fri, 07 Sep 2012 22:06:01 +0100 |
parents | ee95ef1e644c |
children | cc852bdbdbaa |
line wrap: on
line diff
--- a/lisp/files.el Wed Sep 05 20:37:58 2012 +0100 +++ b/lisp/files.el Fri Sep 07 22:06:01 2012 +0100 @@ -2126,52 +2126,6 @@ ;; Ordinary variable, really set it. (t (make-local-variable var) (set var val)))) - -(defun find-coding-system-magic-cookie-in-file (file) - "Look for the coding-system magic cookie in FILE. -The coding-system magic cookie is either the local variable specification --*- ... coding: ... -*- on the first line, or the exact string -\";;;###coding system: \" somewhere within the first 3000 characters -of the file. If found, the coding system name (as a string) is returned; -otherwise nil is returned. Note that it is extremely unlikely that -either such string would occur coincidentally as the result of encoding -some characters in a non-ASCII charset, and that the spaces make it -even less likely since the space character is not a valid octet in any -ISO 2022 encoding of most non-ASCII charsets." - (save-excursion - (with-temp-buffer - (let ((coding-system-for-read 'raw-text)) - (insert-file-contents file nil 0 3000)) - (goto-char (point-min)) - (or (and (looking-at - "^[^\n]*-\\*-[^\n]*coding: \\([^ \t\n;]+\\)[^\n]*-\\*-") - (buffer-substring (match-beginning 1) (match-end 1))) - ;; (save-excursion - ;; (let (start end) - ;; (and (re-search-forward "^;+[ \t]*Local Variables:" nil t) - ;; (setq start (match-end 0)) - ;; (re-search-forward "\n;+[ \t]*End:") - ;; (setq end (match-beginning 0)) - ;; (save-restriction - ;; (narrow-to-region start end) - ;; (goto-char start) - ;; (re-search-forward "^;;; coding: \\([^\n]+\\)$" nil t) - ;; ) - ;; (let ((codesys - ;; (intern (buffer-substring - ;; (match-beginning 1)(match-end 1))))) - ;; (if (find-coding-system codesys) codesys)) - ;; ))) - (let ((case-fold-search nil)) - (if (search-forward - ";;;###coding system: " (+ (point-min) 3000) t) - (let ((start (point)) - (end (progn - (skip-chars-forward "^ \t\n\r") - (point)))) - (if (> end start) (buffer-substring start end)) - ))) - )))) (defcustom change-major-mode-with-file-name t