szermatt / diff-fold

An Emacs minor mode to show/hide hunks and file in diff-mode

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

diff-fold test

An Emacs minor mode for diff-mode that allows hiding and showing (folding) files and hunks. The resulting behavior is quite similar to magit.

Prerequisites

Diff-fold requires at least Emacs 26.

Installation

To install add it to your elisp path,

(require diff-fold)

then turn it on for all diff buffers with:

(add-hook 'diff-mode-hook 'turn-on-diff-fold)

By default, the minor mode binds hiding/showing behavior to TAB and shift-TAB in diff-fold-mode-map.

diff-fold plays well with diff-font-lock-prettify, available under Emacs 27.

Diff Mode in read-only mode

If you use diff-mode in read-only mode, with diff-default-read-only set to t, you'll want to add your own shortcuts directly to diff-mode-shared-map.

Setup Example

Full setup, with use-package and straight:

(use-package diff-mode
  :hook ((diff-mode . turn-on-diff-fold)))

(use-package diff-fold
  :straight (:type git :repo "https://github.com/szermatt/diff-fold.git")
  :bind (:map diff-mode-shared-map
              ("H" . diff-fold-hide-all-files)
              ("h" . diff-fold-toggle)
              ("S" . diff-fold-show-all)
              ("TAB" . diff-fold-toggle)
              ("S-TAB" . diff-fold-toggle-file)
              ("<backtab>" . diff-fold-toggle-file)))

Testing

Install Cask and run tests with:

cask exec ert-runner

License

This project is licensed under the GPLv2 - see the license file for details

About

An Emacs minor mode to show/hide hunks and file in diff-mode

License:GNU General Public License v2.0


Languages

Language:Emacs Lisp 99.0%Language:Makefile 1.0%