Mercurial > emacs
comparison lisp/international/mule.el @ 24602:ca3a341bfd58
(auto-coding-alist-lookup): New function.
(set-auto-coding): Use auto-coding-alist-lookup.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 08 Apr 1999 22:27:44 +0000 |
parents | a95503af9112 |
children | 66a14155ad78 |
comparison
equal
deleted
inserted
replaced
24601:c22ae7f6afd9 | 24602:ca3a341bfd58 |
---|---|
901 | 901 |
902 (defvar set-auto-coding-for-load nil | 902 (defvar set-auto-coding-for-load nil |
903 "Non-nil means look for `load-coding' property instead of `coding'. | 903 "Non-nil means look for `load-coding' property instead of `coding'. |
904 This is used for loading and byte-compiling Emacs Lisp files.") | 904 This is used for loading and byte-compiling Emacs Lisp files.") |
905 | 905 |
906 (defun set-auto-coding (filename size) | 906 (defun auto-coding-alist-lookup (filename) |
907 "Return coding system for a file FILENAME of which SIZE bytes follow point. | 907 "Return the coding system specified by `auto-coding-alist' for FILENAME." |
908 These bytes should include at least the first 1k of the file | |
909 and the last 3k of the file, but the middle may be omitted. | |
910 | |
911 It checks FILENAME against the variable `auto-coding-alist'. | |
912 If FILENAME doesn't match any entries in the variable, | |
913 it checks for a `coding:' tag in the first one or two lines following | |
914 point. If no `coding:' tag is found, it checks for local variables | |
915 list in the last 3K bytes out of the SIZE bytes. | |
916 | |
917 The return value is the specified coding system, | |
918 or nil if nothing specified. | |
919 | |
920 The variable `set-auto-coding-function' (which see) is set to this | |
921 function by default." | |
922 (let ((alist auto-coding-alist) | 908 (let ((alist auto-coding-alist) |
923 (case-fold-search (memq system-type '(vax-vms windows-nt))) | 909 (case-fold-search (memq system-type '(vax-vms windows-nt))) |
924 coding-system) | 910 coding-system) |
925 (while (and alist (not coding-system)) | 911 (while (and alist (not coding-system)) |
926 (if (string-match (car (car alist)) filename) | 912 (if (string-match (car (car alist)) filename) |
927 (setq coding-system (cdr (car alist))) | 913 (setq coding-system (cdr (car alist))) |
928 (setq alist (cdr alist)))) | 914 (setq alist (cdr alist)))) |
915 coding-system)) | |
916 | |
917 (defun set-auto-coding (filename size) | |
918 "Return coding system for a file FILENAME of which SIZE bytes follow point. | |
919 These bytes should include at least the first 1k of the file | |
920 and the last 3k of the file, but the middle may be omitted. | |
921 | |
922 It checks FILENAME against the variable `auto-coding-alist'. | |
923 If FILENAME doesn't match any entries in the variable, | |
924 it checks for a `coding:' tag in the first one or two lines following | |
925 point. If no `coding:' tag is found, it checks for local variables | |
926 list in the last 3K bytes out of the SIZE bytes. | |
927 | |
928 The return value is the specified coding system, | |
929 or nil if nothing specified. | |
930 | |
931 The variable `set-auto-coding-function' (which see) is set to this | |
932 function by default." | |
933 (let ((coding-system (auto-coding-alist-lookup filename))) | |
929 | 934 |
930 (or coding-system | 935 (or coding-system |
931 (let* ((case-fold-search t) | 936 (let* ((case-fold-search t) |
932 (head-start (point)) | 937 (head-start (point)) |
933 (head-end (+ head-start (min size 1024))) | 938 (head-end (+ head-start (min size 1024))) |