From 8a59213176d8a103bc8fc3a586d05821631c391e Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Thu, 8 Apr 1999 22:27:44 +0000 Subject: [PATCH] (auto-coding-alist-lookup): New function. (set-auto-coding): Use auto-coding-alist-lookup. --- lisp/international/mule.el | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lisp/international/mule.el b/lisp/international/mule.el index dc8a2fa55e..9087aa1c93 100644 --- a/lisp/international/mule.el +++ b/lisp/international/mule.el @@ -903,6 +903,17 @@ and the contents of `file-coding-system-alist'.") "Non-nil means look for `load-coding' property instead of `coding'. This is used for loading and byte-compiling Emacs Lisp files.") +(defun auto-coding-alist-lookup (filename) + "Return the coding system specified by `auto-coding-alist' for FILENAME." + (let ((alist auto-coding-alist) + (case-fold-search (memq system-type '(vax-vms windows-nt))) + coding-system) + (while (and alist (not coding-system)) + (if (string-match (car (car alist)) filename) + (setq coding-system (cdr (car alist))) + (setq alist (cdr alist)))) + coding-system)) + (defun set-auto-coding (filename size) "Return coding system for a file FILENAME of which SIZE bytes follow point. These bytes should include at least the first 1k of the file @@ -919,13 +930,7 @@ or nil if nothing specified. The variable `set-auto-coding-function' (which see) is set to this function by default." - (let ((alist auto-coding-alist) - (case-fold-search (memq system-type '(vax-vms windows-nt))) - coding-system) - (while (and alist (not coding-system)) - (if (string-match (car (car alist)) filename) - (setq coding-system (cdr (car alist))) - (setq alist (cdr alist)))) + (let ((coding-system (auto-coding-alist-lookup filename))) (or coding-system (let* ((case-fold-search t) -- 2.20.1