Skip to content

riscy/bifocal-mode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bifocal-mode

https://melpa.org/packages/bifocal-badge.svg https://stable.melpa.org/packages/bifocal-badge.svg

img/screenshot.png

Table of Contents

Description

In bifocal-mode, paging up causes a comint-mode buffer to be split in two windows with a larger window on top (the head) and a smaller input window preserved on the bottom (the tail). This helps with monitoring new output and entering text at the prompt (in the tail window), while reviewing previous output (in the head window). Paging down all the way causes the split to disappear.

Note if you’re not on the last line of a buffer, no split will appear.

bifocal-mode used to be called shx-split when it was part of the shx extensions.

Use M-x customize-group RET bifocal RET to see customization options.

This version is tested with Emacs 25.2.1

Install

From MELPA

Use M-x package-install RET bifocal RET to install bifocal from MELPA.

Manually

Download bifocal.el and add the following to your .emacs:

(add-to-list 'load-path "~/path/to/bifocal/")
(require 'bifocal)

Run

To enable bifocal-mode in every comint-mode buffer, use:

(bifocal-global-mode 1)

You can also use M-x bifocal-mode on a case-by-case basis, or just add hooks into the mode in question, for example:

(add-hook 'inferior-python-mode-hook #'bifocal-mode)

Key bindings

Key bindingDescription
<prior> (page-up)Scroll up; create a split if none exists.
<next> (page-down)Scroll down; remove the split if the bottom is reached.
<home>, M-<Scroll all the way up; create a split if none exists.
<end>, M->Scroll all the way down; remove the split.

For compatibility with evil-mode keybindings, you might add something like the following to your config:

(add-hook 'comint-mode-hook
          (define-key evil-normal-state-local-map (kbd "gg")  #'bifocal-home)
          (define-key evil-normal-state-local-map (kbd "G")   #'bifocal-end)
          (define-key evil-insert-state-local-map (kbd "C-u") #'bifocal-up)
          (define-key evil-normal-state-local-map (kbd "C-u") #'bifocal-up)
          (define-key evil-insert-state-local-map (kbd "C-d") #'bifocal-down)
          (define-key evil-normal-state-local-map (kbd "C-d") #'bifocal-down))

Customization

The following can be customized with M-x customize-group RET bifocal RET or by setting their values in your config:

bifocal-minimum-rows-before-splitting
The minimum window height before splitting the window is allowed.
bifocal-tail-size
The number of rows the tail window will have. This is also the number of lines to scroll by at a time.
bifocal-use-dedicated-windows
Whether to flag the head and tail as “dedicated” windows. The original settings are restored when the split is destroyed. The default is t which prevents splits from being clobbered as new buffers pop into view.

About

A minor mode enabling split-screen scrolling in any Emacs 'comint-mode' buffer (such as shell-mode, inferior-python-mode, etc.)

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors