bifocal-mode
bifocal-mode copied to clipboard
A minor mode enabling split-screen scrolling in any Emacs 'comint-mode' buffer (such as shell-mode, inferior-python-mode, etc.)
#+TITLE: bifocal-mode #+OPTIONS: toc:3 author:t creator:nil num:nil #+AUTHOR: Chris Rayner #+EMAIL: [email protected]
[[https://melpa.org/#/bifocal][https://melpa.org/packages/bifocal-badge.svg]] [[https://stable.melpa.org/#/bifocal][https://stable.melpa.org/packages/bifocal-badge.svg]]
[[file:img/screenshot.png]]
- Table of Contents :TOC_3_gh:noexport:
- [[#description][Description]]
- [[#install][Install]]
- [[#from-melpa][From MELPA]]
- [[#manually][Manually]]
- [[#run][Run]]
- [[#key-bindings][Key bindings]]
- [[#customization][Customization]]
-
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 [[https://github.com/riscy/shx-for-emacs][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 [[https://melpa.org/][MELPA]]. *** Manually Download ~bifocal.el~ and add the following to your ~.emacs~: #+begin_src elisp (add-to-list 'load-path "~/path/to/bifocal/") (require 'bifocal) #+end_src
-
Run To enable ~bifocal-mode~ in every ~comint-mode~ buffer, use:
#+begin_src elisp (bifocal-global-mode 1) #+end_src
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:
#+begin_src elisp (add-hook 'inferior-python-mode-hook #'bifocal-mode) #+end_src
-
Key bindings | Key binding | Description | |----------------------+---------------------------------------------------------| | ~
~ (page-up) | Scroll up; create a split if none exists. | | ~ ~ (page-down) | Scroll down; remove the split if the bottom is reached. | | ~ ~, ~M-<~ | Scroll all the way up; create a split if none exists. | | ~ ~, ~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:
#+begin_src elisp (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)) #+end_src
-
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.