Last active
August 23, 2024 22:08
-
-
Save jamescherti/52e8fe8700ab394163bb99f2b8d456fd to your computer and use it in GitHub Desktop.
Emacs: Clear the contents of the *Messages* buffer if it is the current buffer
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
;; Description: Clear the contents of the *Messages* buffer if it is the current buffer. | |
;; Gits URL: https://gist.github.com/jamescherti/52e8fe8700ab394163bb99f2b8d456fd | |
;; License: MIT | |
;; Author: James Cherti | |
(defun my-clear-messages-buffer () | |
"Clear the contents of the *Messages* buffer if it is the current buffer." | |
(when (string= (buffer-name) "*Messages*") | |
(let ((was-read-only buffer-read-only)) | |
(when was-read-only | |
(read-only-mode -1)) | |
(erase-buffer) | |
(when was-read-only | |
(read-only-mode 1))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment