Skip to content

Instantly share code, notes, and snippets.

@jamescherti
Last active August 23, 2024 22:08
Show Gist options
  • Save jamescherti/52e8fe8700ab394163bb99f2b8d456fd to your computer and use it in GitHub Desktop.
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
;; 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