comint-fold is a small Emacs global minor-mode which configures hideshow mode in comint buffers to allow folding (hiding and unhiding) blocks of input and associated output.
It can optionally bind the Tab key to fold such blocks (when prior to the prompt), and add a fringe indicator for folded blocks.
Use normal hideshow commands (like hs-show-all), or Tab, if comint-fold-remap-tab is set.
Not in a package repo. Simply package-vc-install or clone and:
(use-package comint-fold
:load-path "~/path/to/comint-fold/"
:config
(comint-fold-mode 1)
;; configure some modes specially; try first without this, many "just work"
(add-hook 'gdb-mode-hook
(comint-fold-configure-hook 0 (rx bol "(gdb)" (+ space))))
(add-hook 'ipy-mode-hook
(comint-fold-configure-hook 1 'ipy-prompt-regexp)))Normally it should just work for comint-derived shells. Prompts are identified using comint-prompt-regexp. Some comint-based modes do not configure this variable. See comint-fold-prompt-regexp for configuring these.
Some shells add an extra line or more before the prompt, and it can be nice to leave this line unhidden. See comint-fold-blank-lines. These two variables can be locally configured for a given mode at the same time by using the convenience function comint-fold-configure-hook to add to their hooks:
(add-hook 'some-comint-derived-mode-hook
(comint-fold-configure-hook num-extra-blanks 'prompt-regexp-var))Two additional custom variables control Tab rebinding and fringe indicators:
comint-fold-remap-tab [t]: if non-nil, remap theTabkey to toggle fold of the enclosing block when point is before the current active prompt position.comint-fold-fringe-indicator [top-left-angle]: an indicator bitmap (symbol) to place in the fringe when folded (if non-nil).