Skip to content

jamescherti/be-quiet.el

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

be-quiet.el - Emacs, be quiet!

Build Status License

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.

Installation

Emacs: Install with straight (Emacs version < 30)

To install be-quiet with straight.el:

  1. It if hasn't already been done, add the straight.el bootstrap code to your init file.
  2. Add the following code to the Emacs init file:
(use-package be-quiet
  :ensure t
  :straight (be-quiet
             :type git
             :host github
             :repo "jamescherti/be-quiet.el"))

Alternative installation: use-package and :vc (Built-in feature in Emacs version >= 30)

To install be-quiet with use-package and :vc (Emacs >= 30):

(use-package be-quiet
  :ensure t
  :vc (:url "https://github.com/jamescherti/be-quiet.el"
       :rev :newest))

Alternative installation 2: Doom Emacs

Here is how to install be-quiet on Doom Emacs:

  1. Add to the ~/.doom.d/packages.el file:
(package! be-quiet
  :recipe
  (:host github :repo "jamescherti/be-quiet.el"))
  1. Add to ~/.doom.d/config.el:
(after! be-quiet
  ;; TODO: Add setq options here
  )
  1. Run the doom sync command:
doom sync

Usage

be-quiet (macro)

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-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.

be-quiet-advice-add (function)

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))

be-quiet-funcall (function)

Use be-quiet-funcall when you want to invoke a function while suppressing all output, including messages and printed text. For instance, to call message without displaying anything:

(be-quiet-funcall 'message "You won't see this")

Unlike be-quiet, which is a macro and captures output in a temporary buffer for later inspection, be-quiet-funcall is a regular function that discards all output entirely. Use it when you do not need to capture or inspect the suppressed output.

Frequently asked question

Identifying Functions to Silence in Emacs

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")

What is the difference between be-quiet and shut-up?

The be-quiet package offers the same core functionality as shut-up, but with several enhancements:

  • Provides new functions: be-quiet-advice-add and be-quiet-advice-remove
  • Ensures internal helper functions are properly marked as internal
  • Fixes byte-compiler warnings and other issues and improves docstrings for clarity and completeness
  • Fix bug: Kill the temporary buffer created by the be-quiet macro when be-quiet-disable is non-nil (unlike shut-up, which leaves the buffer behind when shut-up-ignore is non-nil)
  • Fix bug: Do not set inhibit-message to t when be-quiet-disable is non-nil (unlike shut-up, which sets it regardless of the value of shut-up-ignore)
  • Replaced buffer-name with buffer-live-p to ensure that the be-quiet buffer is still valid before performing operations like kill-buffer.

License

  • Copyright (C) 2024-2025 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.

Links

Other Emacs packages by the same author:

  • minimal-emacs.d: This repository hosts a minimal Emacs configuration designed to serve as a foundation for your vanilla Emacs setup and provide a solid base for an enhanced Emacs experience.
  • compile-angel.el: Speed up Emacs! This package guarantees that all .el files are both byte-compiled and native-compiled, which significantly speeds up Emacs.
  • outline-indent.el: An Emacs package that provides a minor mode that enables code folding and outlining based on indentation levels for various indentation-based text files, such as YAML, Python, and other indented text files.
  • easysession.el: Easysession is lightweight Emacs session manager that can persist and restore file editing buffers, indirect buffers/clones, Dired buffers, the tab-bar, and the Emacs frames (with or without the Emacs frames size, width, and height).
  • vim-tab-bar.el: Make the Emacs tab-bar Look Like Vim’s Tab Bar.
  • elispcomp: A command line tool that allows compiling Elisp code directly from the terminal or from a shell script. It facilitates the generation of optimized .elc (byte-compiled) and .eln (native-compiled) files.
  • tomorrow-night-deepblue-theme.el: The Tomorrow Night Deepblue Emacs theme is a beautiful deep blue variant of the Tomorrow Night theme, which is renowned for its elegant color palette that is pleasing to the eyes. It features a deep blue background color that creates a calming atmosphere. The theme is also a great choice for those who miss the blue themes that were trendy a few years ago.
  • Ultyas: A command-line tool designed to simplify the process of converting code snippets from UltiSnips to YASnippet format.
  • dir-config.el: Automatically find and evaluate .dir-config.el Elisp files to configure directory-specific settings.
  • flymake-bashate.el: A package that provides a Flymake backend for the bashate Bash script style checker.
  • flymake-ansible-lint.el: An Emacs package that offers a Flymake backend for ansible-lint.
  • inhibit-mouse.el: A package that disables mouse input in Emacs, offering a simpler and faster alternative to the disable-mouse package.
  • enhanced-evil-paredit.el: An Emacs package that prevents parenthesis imbalance when using evil-mode with paredit. It intercepts evil-mode commands such as delete, change, and paste, blocking their execution if they would break the parenthetical structure.
  • stripspace.el: Ensure Emacs Automatically removes trailing whitespace before saving a buffer, with an option to preserve the cursor column.
  • persist-text-scale.el: Ensure that all adjustments made with text-scale-increase and text-scale-decrease are persisted and restored across sessions.
  • pathaction.el: Execute the pathaction command-line tool from Emacs. The pathaction command-line tool enables the execution of specific commands on targeted files or directories. Its key advantage lies in its flexibility, allowing users to handle various types of files simply by passing the file or directory as an argument to the pathaction tool. The tool uses a .pathaction.yaml rule-set file to determine which command to execute. Additionally, Jinja2 templating can be employed in the rule-set file to further customize the commands.

Sponsor this project

 

Contributors 9