The be-quiet
Emacs package helps manage and minimize unwanted output in your Emacs environment. It is useful in contexts where controlling or suppressing verbosity is required.
To install the be-quiet
using straight.el
:
- If you haven't already done so, add the straight.el bootstrap code to your init file.
- Add the following code to your Emacs init file:
(use-package be-quiet
:ensure t
:straight (be-quiet
:type git
:host github
:repo "jamescherti/be-quiet.el"))
The simplest way to use the be-quiet
macro is as follows:
(be-quiet
(message "You will not see this message")
(message "You will also not see this message"))
The be-quiet
macro silences specific function calls while allowing you to capture their output. For example:
(let (output) (be-quiet (message "Foo")
(setq output (be-quiet-current-output)))
(message "This was the last message: %s" output))
In this example, the message "Foo" is silenced, but its output is captured and stored in the variable output.
To prevent certain functions from generating output, use the be-quiet-advice-add
function.
For instance, to disable the message "Indentation setup for shell type bash" when sh-set-shell
is called:
(be-quiet-advice-add #'sh-set-shell)
In this example, calling the sh-set-shell
function will execute as usual without displaying any messages.
Here is another example to prevent recentf
from showing messages during saving and cleanup:
(with-eval-after-load "recentf"
(be-quiet-advice-add #'recentf-save-list)
(be-quiet-advice-add #'recentf-cleanup))
In non-interactive sessions, you can further reduce output by using be-quiet-silence-emacs, which adjusts some global Emacs settings:
(when noninteractive
(setq dired-use-ls-dired nil)
(remove-hook 'find-file-hook 'vc-find-file-hook))
You can assign a regular expression to the variable debug-on-message
by adding the following line early in your Emacs init files. This will cause Emacs to invoke the debugger when a matching message is displayed during Emacs startup:
(setq debug-on-message "Regular expression")
- Copyright (C) 2024 James Cherti
- Copyright (C) 2013-2014 Johan Andersson
- Copyright (C) 2014-2015 Sebastian Wiesner
The be-quiet
package is based on the shut-up package, originally developed by Johan Andersson and Sebastian Wiesner. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program.