File: follow.el.html

follow-mode(var)/follow-mode(fun) is a minor mode that combines windows into one tall virtual window.

The feeling of a "virtual window" has been accomplished by the use of two major techniques:

* The windows always display adjacent sections of the buffer.
  This means that whenever one window is moved, all the
  others will follow. (Hence the name Follow mode.)

* Should point (cursor) end up outside a window, another
  window displaying that point is selected, if possible. This
  makes it possible to walk between windows using normal cursor
  movement commands.

Follow mode comes to its prime when a large screen and two side-by-side window are used. The user can, with the help of Follow mode, use two full-height windows as though they are one. Imagine yourself editing a large function, or section of text, and being able to use 144 lines instead of the normal 72... (your mileage may vary).

To test this package, make sure follow is loaded, or will be autoloaded when activated (see below). Then do the following:

* Find your favorite file (preferably a long one).

* Resize Emacs so that it will be wide enough for two full size
  columns. Delete the other windows and split the window with
  the commands C-x 1 C-x 3.

* Give the command:
M-x follow-mode <RETURN>

* Now the display should look something like (assuming the text "71"
  is on line 71):

+----------+----------+
|1 |73 |
|2 |74 |
|3 |75 |
                 ... ...
|71 |143 |
|72 |144 |
+----------+----------+

  As you can see, the right-hand window starts at line 73, the line
  immediately below the end of the left-hand window. As long as
  follow-mode(var)/follow-mode(fun) is active, the two windows will follow each other!

* Play around and enjoy! Scroll one window and watch the other.
  Jump to the beginning or end. Press Cursor down at the last
  line of the left-hand window. Enter new lines into the
  text. Enter long lines spanning several lines, or several
  windows.

* Should you find Follow mode annoying, just type
M-x follow-mode <RETURN>
  to turn it off.


The command follow-delete-other-windows-and-split maximizes the visible area of the current buffer.

I recommend adding it, and follow-mode(var)/follow-mode(fun), to hotkeys in the global key map. To do so, add the following lines (replacing "<f7>" and
"<f8>" with your favorite keys) to your init file:

(keymap-global-set "<f8>" #'follow-mode)
(keymap-global-set "<f7>" #'follow-delete-other-windows-and-split)


There exist two system variables that control the appearance of lines wider than the window containing them. The default is to truncate long lines whenever a window isn't as wide as the frame.

To make sure lines are never truncated, place the following lines in your Init file:

(setopt truncate-lines nil)
(setopt truncate-partial-width-windows nil)


One way to configure Follow mode is to create one or more functions that do whatever you would like to do. These functions are then added to a hook.

The keymap follow-mode-map contains key bindings activated by follow-mode(var)/follow-mode(fun).

Example:
(with-eval-after-load 'follow
  (keymap-set follow-mode-map "C-c a" #'your-favorite-function)
  (keymap-set follow-mode-map "C-c b" #'another-function))


Usage:

To activate, issue the command "M-x follow-mode" and press Return. To deactivate, do it again.

The following is a list of commands useful when follow-mode(var)/follow-mode(fun) is active.

follow-scroll-up C-c . C-v
Scroll text in a Follow mode window chain up.

follow-scroll-down C-c . v
Like follow-scroll-up, but in the other direction.

follow-delete-other-windows-and-split C-c . 1
Maximize the visible area of the current buffer,
and enter Follow mode. This is a very convenient
way to start Follow mode, hence we recommend that
this command be added to the global keymap.

follow-recenter C-c . C-l
Place point in the center of the middle window,
or a specified number of lines from either top or bottom.

follow-switch-to-buffer C-c . b
Switch buffer in all windows displaying the current buffer
in this frame.

follow-switch-to-buffer-all C-c . C-b
Switch buffer in all windows in the selected frame.

follow-switch-to-current-buffer-all
Show the current buffer in all windows on the current
frame and turn on follow-mode(var)/follow-mode(fun).

follow-first-window C-c . <
Select the first window in the frame showing the same buffer.

follow-last-window C-c . >
Select the last window in the frame showing the same buffer.

follow-next-window C-c . n
Select the next window in the frame showing the same buffer.

follow-previous-window C-c . p
Select the previous window showing the same buffer.


Well, it seems ok, but what if I really want to look at two different
positions in the text? Here are two simple methods to use:

1) Use multiple frames; follow mode only affects windows displayed
   in the same frame. (My apologies to you who can't use frames.)

2) Bind follow-mode(var)/follow-mode(fun) to key so you can turn it off whenever
   you want to view two locations. Of course, follow-mode(var)/follow-mode(fun) can
   be reactivated by hitting the same key again.

   Example from my ~/.emacs:
(keymap-global-set "<f8>" #'follow-mode)

Implementation:

The main method by which Follow mode aligns windows is via the function follow-pre-redisplay-function, which is run before each redisplay. This "fixes up" the alignment of other windows which are showing the same Follow mode buffer, on the same frame as the selected window. It does not try to deal with buffers other than the buffer of the selected frame, or windows on other frames.

Comint mode specially calls follow-comint-scroll-to-bottom on Follow mode buffers. This function scrolls the bottom-most window in a window chain and aligns the other windows accordingly. Follow mode adds a function to compilation-filter-hook to align compilation buffers.

Defined variables (18)

follow-active-menuThe menu visible when Follow mode is active.
follow-autoNon-nil activates Follow mode whenever a file is loaded.
follow-cache-command-listList of commands that don’t require recalculation.
follow-debugIf non-nil, emit Follow mode debugging messages.
follow-fixed-windowIf non-nil, the current window must not be scrolled.
follow-hide-ghost-cursorsWhen non-nil, Follow mode attempts to hide the obtrusive cursors
follow-inactive-menuThe menu visible when Follow mode is inactive.
follow-inside-post-command-hook-callNon-nil when inside Follow modes ‘post-command-hook’.
follow-internal-force-redisplayNon-nil when Follow mode should redisplay the windows.
follow-modeNon-nil if Follow mode is enabled.
follow-mode-hookNormal hook run by ‘follow-mode’.
follow-mode-line-textText shown in the mode line when Follow mode is active.
follow-mode-mapMinor mode keymap for Follow mode.
follow-mode-prefixPrefix key to use for follow commands in Follow mode.
follow-mode-prefix-keyPrefix key to use for follow commands in Follow mode.
follow-prev-bufferThe buffer current at the last call to ‘follow-adjust-window’ or nil.
follow-start-end-invalidWhen non-nil, indicates ‘follow-windows-start-end-cache’ is invalid.
follow-windows-start-end-cacheCache used by ‘follow-window-start’ and ‘follow-window-end’.

Defined functions (63)

follow--prefix-key(KEY)
follow--window-sorter(W1 W2)
follow-adjust-window(WIN)
follow-after-change(BEG END OLD-LEN)
follow-align-compilation-windows()
follow-all-followers(&optional WIN)
follow-avoid-tail-recenter(&rest REST)
follow-cache-valid-p(WINDOWS)
follow-calc-win-end(&optional WIN)
follow-calc-win-start(WINDOWS POS WIN)
follow-calculate-first-window-start-from-above(WINDOWS GUESS WIN START)
follow-calculate-first-window-start-from-below(WINDOWS GUESS &optional WIN START)
follow-comint-scroll-to-bottom(&optional WINDOW)
follow-debug-message(&rest ARGS)
follow-delete-other-windows-and-split(&optional ARG)
follow-end-of-buffer(&optional ARG)
follow-estimate-first-window-start(WINDOWS WIN START)
follow-find-file-hook()
follow-first-window()
follow-get-scrolled-point(DEST WINDOWS)
follow-last-window()
follow-maximize-region(WIN WINDOWS WIN-START-END)
follow-menu-filter(MENU)
follow-mode(&optional ARG)
follow-move-to-window-line(ARG)
follow-mwheel-scroll(EVENT)
follow-next-window()
follow-point-visible-all-windows-p(WIN-START-END)
follow-pos-visible(POS WIN WIN-START-END)
follow-pos-visible-in-window-p(&optional POS WINDOW PARTIALLY)
follow-post-command-hook()
follow-pre-redisplay-function(WINS)
follow-previous-window()
follow-recenter(&optional ARG)
follow-redisplay(&optional WINDOWS WIN PRESERVE-WIN)
follow-redraw()
follow-redraw-after-event(EVENT)
follow-scroll-bar-drag(EVENT)
follow-scroll-bar-scroll-down(EVENT)
follow-scroll-bar-scroll-up(EVENT)
follow-scroll-bar-toolkit-scroll(EVENT)
follow-scroll-down(&optional ARG)
follow-scroll-down-arg(ARG)
follow-scroll-down-window(&optional ARG)
follow-scroll-up(&optional ARG)
follow-scroll-up-arg(ARG)
follow-scroll-up-window(&optional ARG)
follow-select-if-end-visible(WIN-START-END)
follow-select-if-visible(DEST WIN-START-END)
follow-select-if-visible-from-first(DEST WINDOWS)
follow-set-window-start(WINDOW POS &optional NOFORCE)
follow-split-followers(WINDOWS &optional WIN)
follow-switch-to-buffer(BUFFER)
follow-switch-to-buffer-all(&optional BUFFER)
follow-switch-to-current-buffer-all()
follow-update-window-start(WIN)
follow-window-end(&optional WINDOW UPDATE)
follow-window-size-change(FRAME)
follow-window-start(&optional WINDOW)
follow-windows-aligned-p(WIN-START-END)
follow-windows-start-end(WINDOWS)
turn-off-follow-mode()
turn-on-follow-mode()

Defined faces (0)