diff options
| author | Richard M. Stallman | 1999-04-08 22:27:44 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1999-04-08 22:27:44 +0000 |
| commit | 8a59213176d8a103bc8fc3a586d05821631c391e (patch) | |
| tree | 9980dd13d5e7003bf59223d955e95783c7b4dbac | |
| parent | c352d9595152bb5682690a101ea294b7c5d4a8b4 (diff) | |
| download | emacs-8a59213176d8a103bc8fc3a586d05821631c391e.tar.gz emacs-8a59213176d8a103bc8fc3a586d05821631c391e.zip | |
(auto-coding-alist-lookup): New function.
(set-auto-coding): Use auto-coding-alist-lookup.
| -rw-r--r-- | lisp/international/mule.el | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/lisp/international/mule.el b/lisp/international/mule.el index dc8a2fa55ef..9087aa1c933 100644 --- a/lisp/international/mule.el +++ b/lisp/international/mule.el | |||
| @@ -903,6 +903,17 @@ and the contents of `file-coding-system-alist'.") | |||
| 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 auto-coding-alist-lookup (filename) | ||
| 907 | "Return the coding system specified by `auto-coding-alist' for FILENAME." | ||
| 908 | (let ((alist auto-coding-alist) | ||
| 909 | (case-fold-search (memq system-type '(vax-vms windows-nt))) | ||
| 910 | coding-system) | ||
| 911 | (while (and alist (not coding-system)) | ||
| 912 | (if (string-match (car (car alist)) filename) | ||
| 913 | (setq coding-system (cdr (car alist))) | ||
| 914 | (setq alist (cdr alist)))) | ||
| 915 | coding-system)) | ||
| 916 | |||
| 906 | (defun set-auto-coding (filename size) | 917 | (defun set-auto-coding (filename size) |
| 907 | "Return coding system for a file FILENAME of which SIZE bytes follow point. | 918 | "Return coding system for a file FILENAME of which SIZE bytes follow point. |
| 908 | These bytes should include at least the first 1k of the file | 919 | These bytes should include at least the first 1k of the file |
| @@ -919,13 +930,7 @@ or nil if nothing specified. | |||
| 919 | 930 | ||
| 920 | The variable `set-auto-coding-function' (which see) is set to this | 931 | The variable `set-auto-coding-function' (which see) is set to this |
| 921 | function by default." | 932 | function by default." |
| 922 | (let ((alist auto-coding-alist) | 933 | (let ((coding-system (auto-coding-alist-lookup filename))) |
| 923 | (case-fold-search (memq system-type '(vax-vms windows-nt))) | ||
| 924 | coding-system) | ||
| 925 | (while (and alist (not coding-system)) | ||
| 926 | (if (string-match (car (car alist)) filename) | ||
| 927 | (setq coding-system (cdr (car alist))) | ||
| 928 | (setq alist (cdr alist)))) | ||
| 929 | 934 | ||
| 930 | (or coding-system | 935 | (or coding-system |
| 931 | (let* ((case-fold-search t) | 936 | (let* ((case-fold-search t) |