Last active
August 29, 2015 14:14
-
-
Save tek-nishi/a444901b5cf07fe15d40 to your computer and use it in GitHub Desktop.
Set encoding new file for some extensions.
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
(defun my-set-encoding () | |
"新規ファイル生成時のみ、エンコードを強制する Thanks for Syohei YOSHIDA" | |
(let ((bufname (buffer-file-name))) | |
(when (not (file-exists-p buffer-file-name)) | |
(when (and bufname (string-match-p ".+\\.\\(cpp\\|c\\|hpp\\|h\\|mm\\)$" bufname)) | |
(set-buffer-file-coding-system 'utf-8-with-signature))))) | |
(add-hook 'find-file-hook 'my-set-encoding) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment