Last active
March 6, 2017 05:47
-
-
Save Archenoth/935c8aadda4f90c2b995423176b983f0 to your computer and use it in GitHub Desktop.
Opening a UTF file with a BOM marker will make Emacs play "BOM BOM BOOOOM" before letting you see it
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 detect-bom (filePath) | |
| "Given a filepath, plays BOM BOM BOOOOOM if the file has a BOM" | |
| (with-temp-buffer | |
| (insert-file-contents-literally filePath) | |
| (let ((bom (decode-coding-string (buffer-substring-no-properties 1 4) 'utf-8))) | |
| (when (string= bom (string ?\uFEFF)) | |
| (play-sound-file "bombombom.wav"))))) | |
| (add-hook 'find-file-hook (lambda () (detect-bom buffer-file-name))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment