Created
April 30, 2010 01:54
-
-
Save bowbow99/384602 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; 文字コード指定を -*- coding: hoge -*- でもできるように | |
;;; .xyzzy にでも; 組み込み関数上書き注意報 | |
(defun ed::find-file-auto-encoding (filename) | |
(unwind-protect | |
(let ((encoding | |
(progn | |
(ignore-errors (insert-file-contents filename t nil 4096)) | |
(goto-char (point-min)) | |
(dolist (x *auto-encoding-alist* nil) | |
(when (string-matchp (car x) filename) | |
(return (funcall (cdr x)))))))) | |
(when (stringp encoding) | |
(setq encoding (gethash encoding *mime-charset-name-hash-table*))) | |
(if (char-encoding-p encoding) | |
encoding | |
(let ((params (ed::find-file-scan-params))) | |
(gethash (cdr (or (assoc "encoding" params :test #'string-equal) | |
(assoc "coding" params :test #'string-equal))) | |
*mime-charset-name-hash-table*)))) | |
(erase-buffer (selected-buffer)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment