Created
June 29, 2012 13:55
-
-
Save DeaR/3018087 to your computer and use it in GitHub Desktop.
encodingマジックコメントで-dos等を何とかしてみた #xyzzy
This file contains hidden or 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
(defun find-file-buffer-encoding (arg) | |
"エンコーディングの自動判定" | |
(let ((encoding (gethash (substitute-string arg "-\\(dos\\|mac\\|unix\\)$" "" :case-fold t) | |
*mime-charset-name-hash-table*)) | |
(eol (cond ((string-matchp "-dos$" arg) | |
*eol-crlf*) | |
((string-matchp "-mac$" arg) | |
*eol-cr*) | |
((string-matchp "-unix$" arg) | |
*eol-lf*)))) | |
(when encoding | |
(revert-buffer (if (and *find-file-auto-encoding-use-utf8n* | |
(eq encoding *encoding-utf8*)) | |
*encoding-utf8n* | |
encoding))) | |
(when eol | |
(set-buffer-eol-code eol)))) | |
(pushnew '("coding" . find-file-buffer-encoding) *auto-mode-parameter-alist* :test #'equal) | |
(pushnew '("encoding" . find-file-buffer-encoding) *auto-mode-parameter-alist* :test #'equal) | |
(defun find-file-buffer-eol (arg) | |
"改行コードの自動判定" | |
(let ((eol (cond ((or (string-equal "dos" arg) | |
(string-equal "crlf" arg)) | |
*eol-crlf*) | |
((or (string-equal "mac" arg) | |
(string-equal "cr" arg)) | |
*eol-cr*) | |
((or (string-equal "unix" arg) | |
(string-equal "lf" arg)) | |
*eol-lf*)))) | |
(when eol | |
(set-buffer-eol-code eol)))) | |
(pushnew '("eol" . find-file-buffer-eol) *auto-mode-parameter-alist* :test #'equal) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ついでにeolマジックコメントも追加してあったりもする