Last active
September 20, 2019 18:22
-
-
Save treyharris/efd1fe33d7ea8d1a345e3a7d0b1e60b5 to your computer and use it in GitHub Desktop.
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
;; Already defined elsewhere, but including in this Gist for context | |
(defgroup my-customizations nil | |
"Custom variables introduces in the user init file." | |
) | |
(defcustom my-read-only-file-list '() | |
"Filenames or patterns that will be opened read-only." | |
:group 'my-customizations | |
:type '(repeat string) | |
) | |
(defun my-read-only-files () | |
"Check if current buffer is in the set of files we want to be | |
loaded read-only, and if so, make it read-only." | |
(dolist (pattern my-read-only-file-list) | |
(if (string-match (expand-file-name pattern) buffer-file-name) | |
(read-only-mode) | |
)) | |
) | |
(add-hook 'find-file-hook 'my-read-only-files) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment