Last active
August 15, 2023 16:01
-
-
Save farynaio/f9d60dab0ad5fbb1cd13a1129c862e9b to your computer and use it in GitHub Desktop.
Prevent opening native and straight files in editable mode.
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
(defvar aok/read-only-folders | |
'("/usr/share/emacs" "~/.emacs.d/straight") | |
"Files in these folders will be opened in read-only mode.") | |
(defun aok/file-set-read-only-if-listed () | |
"Set current file buffer as `read-only' if it's in `aok/read-only-folders'." | |
(when (seq-some (lambda (i) (string-prefix-p (expand-file-name i) buffer-file-name)) aok/read-only-folders) | |
(read-only-mode 1))) | |
(add-hook 'find-file-hook 'aok/file-set-read-only-if-listed) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment