Last active
February 7, 2025 11:23
-
-
Save jamescherti/1552eeb16cb9643f9bd81d49117fe0b9 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
;;; auto-scroll-message-buffer.el --- Auto scroll the *Messages* buffer -*- lexical-binding: t; -*- | |
;; Gits URL: | |
;; License: MIT | |
;; Author: James Cherti | |
(defun my-auto-scroll-message-advice (&rest _) | |
"Go to point-max after a message in *Messages* buffer." | |
(walk-windows | |
(lambda (window) | |
(let ((window-buffer (window-buffer window))) | |
;; Only adjust point for windows showing the *Messages* buffer | |
(when window-buffer | |
(with-current-buffer window-buffer | |
(when (string= (buffer-name window-buffer) "*Messages*") | |
(goto-char (point-max)) | |
(beginning-of-line) | |
(set-window-point window (point-max))))))) | |
;; Exclude the minibuffer | |
nil | |
;; Apply to all frames | |
t)) | |
(defun my-toggle-auto-scroll-messages-buffer () | |
"Toggle automatic scrolling of the *Messages* buffer." | |
(interactive) | |
(if (advice-member-p #'my-auto-scroll-message-advice 'message) | |
(progn | |
(advice-remove 'message #'my-auto-scroll-message-advice) | |
(message "Auto-scrolling of *Messages* buffer disabled")) | |
(advice-add 'message :after #'my-auto-scroll-message-advice) | |
(message "Auto-scrolling of *Messages* buffer enabled"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment