summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorKenichi Handa <handa@m17n.org>1997-08-22 01:22:49 +0000
committerKenichi Handa <handa@m17n.org>1997-08-22 01:22:49 +0000
commit87aba78889cca651736f6744665fa3b566318bb2 (patch)
tree5b94451b226a38908ddb6d7aa8ff26f36d139cdf /lisp
parent8b8f9e2868199235bc0ce5b0d4a19b9eeafca2ed (diff)
downloademacs-87aba78889cca651736f6744665fa3b566318bb2.tar.gz
(make-coding-system): Doc-string fixed.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/international/mule.el31
1 files changed, 30 insertions, 1 deletions
diff --git a/lisp/international/mule.el b/lisp/international/mule.el
index 6af3b5ddd62..b3bb51a6439 100644
--- a/lisp/international/mule.el
+++ b/lisp/international/mule.el
@@ -388,7 +388,7 @@ FLAGS specifies more precise information of each TYPE.
code of the coding system.
If TYPE is 4 (private), FLAGS should be a cons of CCL programs,
- for encoding and decoding. See the documentation of CCL for more detail."
+ for decoding and encoding. See the documentation of CCL for more detail."
;; At first, set a value of `coding-system' property.
(let ((coding-spec (make-vector 5 nil))
@@ -610,6 +610,35 @@ LIST is a list of coding-categories ordered by priority."
;;; FILE I/O
+(defun auto-file-coding-system (head-lines)
+ "Return coding system for a file which has HEAD-LINES at the head.
+HEAD-LINES is a string of the first two lines of the file.
+This checks for a -*- coding tag in the buffers's text,
+and return the specified coding system.
+
+The variable `auto-file-coding-system' (which see) is set to this
+function by default."
+ (let ((limit (string-match "\n" head-lines))
+ (coding-system nil))
+ (if limit
+ (when (string-match "^#!" head-lines)
+ ;; If the file begins with "#!" (exec interpreter magic),
+ ;; look for coding frobs in the first two lines. You cannot
+ ;; necessarily put them in the first line of such a file
+ ;; without screwing up the interpreter invocation.
+ (setq limit (string-match "\n" head-lines limit))
+ (or limit
+ (setq limit (length head-lines))))
+ (setq limit (length head-lines)))
+ (when (and (string-match "-\\*-[ \t]*coding:[ \t]*\\([^ ;]+\\)" head-lines)
+ (< (match-beginning 1) limit))
+ (setq coding-system
+ (intern (substring head-lines (match-beginning 1) (match-end 1))))
+ (if (coding-system-p coding-system)
+ coding-system))))
+
+(setq auto-file-coding-system-function 'auto-file-coding-system)
+
;; Set buffer-file-coding-system of the current buffer after some text
;; is inserted.
(defun after-insert-file-set-buffer-file-coding-system (inserted)