Skip to content

Latest commit

 

History

History
55 lines (36 loc) · 2.78 KB

README.org

File metadata and controls

55 lines (36 loc) · 2.78 KB

auto-hide.el: Automatically hide function bodies

Overview

auto-hide is an Emacs package that automatically hides function bodies in various programming languages using tree-sitter, enhancing code readability. It was written in response to https://matklad.github.io/2024/10/14/missing-ide-feature.html, so you can look there for screenshots that give a rough idea of what it does.

It is a light wrapper around the built-in Hideshow package. It supports Rust, C++, Javascript and Python “out of the box”.

Requirements

Emacs 29.1 or later with tree-sitter support.

Installation

Install auto-hide by downloading the source and using M-x package-install-file, or through your preferred package manager.

For example, using elpaca, I install and configure it as follows:

(use-package auto-hide
  :ensure (:host github :repo "ultronozm/auto-hide.el"
                 :depth nil)
  :config
  (global-auto-hide-mode))

Customization

Customize auto-hide-language-config to add support for additional languages or modify existing configurations. To customize which major modes use auto-hide, adjust the auto-hide-modes variable.

Usage

After installing the package, you can enable it globally with:

(global-auto-hide-mode)

This activates the Hideshow package in the supported buffers and provides the following keybindings:

KeybindingCommandFunctionality
C-c @ tauto-hide-hide-allHide all function bodies in the current buffer
C-c @ sauto-hide-show-at-pointShow the function body at point
C-c @ dauto-hide-hide-at-pointHide the function body at point
C-c @ eauto-hide-toggle-at-pointToggle visibility of the function body at point

These shadow some related bindings in Hideshow, which contains other useful bindings, e.g.:

KeybindingCommandFunctionality
C-c @ C-ahs-show-allShow all

Auto-hide integrates with xref-find-definitions, automatically showing function bodies when jumping to definitions (typically via M-.). Pressing M-. repeatedly on the name of a function will toggle visibility of the function body. You can disable this feature by setting auto-hide-xref-integration to nil.