Created
May 4, 2011 10:02
-
-
Save ymorimo/955020 to your computer and use it in GitHub Desktop.
Set xattr after saving UTF-8 files in Emacs
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
(when (eq system-type 'darwin) | |
(defvar my-set-xattr-utf-8-modes '(text-mode org-mode ruby-mode js2-mode css-mode)) | |
(defun my-set-xattr-if-utf-8() | |
(when (and (memq major-mode my-set-xattr-utf-8-modes) | |
(string-match "^utf-8" (prin1-to-string buffer-file-coding-system))) | |
(call-process "xattr" nil 0 nil "-w" "com.apple.TextEncoding" "UTF-8;134217984" buffer-file-name))) | |
(add-hook 'after-save-hook 'my-set-xattr-if-utf-8)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment