Created
May 24, 2018 18:42
-
-
Save etherald/55576fac9409f2ee20bc9e5e6e82ce1f to your computer and use it in GitHub Desktop.
two emacs lisp functions to lock buffers
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
(defun lock-view () | |
"put all visible buffers in view mode" | |
(interactive) | |
(save-window-excursion | |
(mapcar (lambda (win) | |
(with-current-buffer (window-buffer win) | |
(unless buffer-read-only | |
(view-buffer (current-buffer))))) | |
(window-list)))) | |
(defun lock-buffers-visiting-directory (dir) | |
(interactive "DDirectory:") | |
(save-window-excursion | |
(dolist (buf (buffer-list)) | |
(when (and | |
(buffer-file-name buf) | |
(string-prefix-p dir (buffer-file-name buf))) | |
(with-current-buffer buf | |
(unless buffer-read-only | |
(view-buffer buf))))))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment