Last active
February 2, 2020 20:52
-
-
Save treyharris/d0880c9b4f2f09ef9cf3a9f868250c43 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
(defcustom my-read-only-file-list '() | |
"Filenames or patterns that will be opened read-only." | |
:group 'my-customizations | |
:type '(repeat string) | |
) | |
;; This defun works if called via: | |
;; M-: (my-read-only-files)<RET> | |
;; it sets the buffer read-only iff the file is in my-read-only-file-list | |
;; but as of Emacs 26, it no longer happens after helm-find-file. | |
(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) | |
)) | |
) | |
;; If I describe-variable find-file-hook, I see this in the results | |
(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