I'd like to use visual-line-mode in the *Messages* buffer. I can switch to that buffer and run M-x visual-line-mode, but I want to configure it automatically. I've tried adding this to my init.el, but it's not taking effect:

(add-hook 'messages-buffer-mode-hook #'visual-line-mode)

I've also tried this, hoping it would apply visual-line-mode to *Messages* and *Warnings*, but again, no luck:

(add-hook 'special-mode-hook #'visual-line-mode)

Maybe it's adding the hook after the messages buffer has already been initialized? Is there a correct way to do this?

1 Answer 1


None of those hooks will apply because the buffer (and its mode) has already been created long before your add-hook happens.

I suggest you add

(with-current-buffer "*Messages*"

to your ~/.emacs instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.