Created
November 16, 2019 18:48
-
-
Save salewski/46d5c5a44a8a7c54eba18e6160b8c4f9 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
| ;; The variable ‘emacs-major-verseion’ and the variable ‘emacs-minor-version’ | |
| ;; both first existed in GNU Emacs 19.23. | |
| ;; | |
| ;; Since GNU Emacs 24.3, the function ‘toggle-read-only’ is obsolete; the | |
| ;; recommendation is to use the function ‘read-only-mode’ instead. Note that | |
| ;; ‘read-only-mode’ is, by default, set to "C-x C-q", but I’ve got 20+ years | |
| ;; of muscle memory in my hands that want to use "C-c r" to toggle the | |
| ;; "read-onlyness" of the buffer. | |
| ;; | |
| ;; See also the function ‘view-mode’ and the variable ‘view-read-only’; having | |
| ;; the latter set non-nil means buffers visiting files read-only do so in View | |
| ;; mode (note that its default value is nil). It also controls whether | |
| ;; ‘read-only-mode’ will enable view mode for buffers that you flag as | |
| ;; read-only by running ‘read-only-mode’ while visiting them. | |
| ;; | |
| ;; FIXME: Decide whether View mode is something we want to get used to. For | |
| ;; now, I’m leaving ‘view-read-only’ with its default value of nil, | |
| ;; which preserves the historical behavior. | |
| ;; | |
| ;(global-set-key [?\C-c ?r] 'toggle-read-only) | |
| (if (not (boundp 'emacs-major-version)) | |
| (display-warning '(:ads-dot-emacs) (format ".emacs: symbol ‘emacs-major-version’ not bound; omitting read-only keybinding")) | |
| (if (not (boundp 'emacs-minor-version)) | |
| (display-warning '(:ads-dot-emacs) (format ".emacs: symbol ‘emacs-minor-version’ not bound; omitting read-only keybinding")) | |
| (let ((wanted-fn-symbol (if (or (and (= emacs-major-version 24) | |
| (>= emacs-minor-version 3)) | |
| (> emacs-major-version 24)) | |
| 'read-only-mode ; GNU Emacs >= 24.3 | |
| 'toggle-read-only))) ; GNU Emacs < 24.3 | |
| (global-set-key [?\C-c ?r] wanted-fn-symbol)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment