Framework extending window functions for Follow Mode (etc.)

The goal of this proposal is to make it possible and easy for Emacs Lisp code to be compatible with Follow Mode. For this, a new framework will be developed.



What prevents smooth working with Follow Mode is the use by lisp code of certain primitives which directly access window features. These primitives include (but may not be limited to):

The proposal

The idea is to add an optional argument to each of the above primitives. If non-nil, the argument means “should Follow Mode be active, please operate on the entire Follow Mode group of windows as if it were a single window; otherwise, please operate on the single window only”. If the argument is nil, it means “please operate on the single window supplied, even if Follow Mode is active”. The new argument will be called “group”.

In addition to the above, functionality is occasionally needed to give access to all the Follow Mode windows as a list (or a single window in a list). This function will be called

The mechanism

For each of the seven functions identified above, a permanent local buffer local variable will be created; this will be nil except when Follow Mode is active, when it will hold a function to execute instead of the standard functionality. These variables will be named “window-start-group-function”, etc. Each of the seven functions will recognise that Follow Mode is active by testing whether its …-group-function variable is a function. If so, it will call that function and return its result. Typically, this function will call the original primitive recursively.

When Follow Mode is started, these buffer local variables will get set to Follow Mode functions which perform the desired actions on the whole group of windows. When Follow Mode is terminated, these variables become nil again.


The necessary amenements to the Emacs Lisp manual will be mainly in the “Windows” section. In “Basic Windows” the concept “group of windows” will be defined, together with the documentaition of the new function selected-window-group. In the documentation of each of the pertinent seven functions, the extra argument “group” will be described, together with the use of the new variable “…-group-function”.