Next: , Previous: Temp- and compile-buffers, Up: Usage of ECB

6.5 How the “other window” is determined by ECB

Normally all windows in an Emacs-frame are arranged in a cyclic order and window-selecting-commands like other-window or window-scrolling-commands like scroll-other-window choose simply the next1 window after the current window as “other window”.

6.5.1 “Other window”-basics in ECB

With a typical window-layout of ECB such a cyclic order of all windows in the ECB-frame does not make sense because it would be not very intuitive and against that what the user wants to “say” when calling other-window or scroll-other-window.

Therefore ECB divides the whole set of windows of the ECB-frame in several subsets:

Each of these subsets will be treated as a cyclic ordered subset, i.e. all windows in each of these subsets are ordered as the function walk-windows would visit the windows when the windows of a subset would be the only windows of a frame2.

6.5.2 Builtin “other window” behaviors of ECB

ECB now offers to specify the behavior of commands like other-window or scroll-other-window within the ECB-frame. This can be done with the option ecb-other-window-behavior. This option offers several builtin behaviors:

Regardless of the different behaviors above ECB handles the situation of an active minibuffer during a call to other-window or scroll-other-window like follows:

If the minibuffer-window is selected then ECB always chooses the window minibuffer-scroll-window points to (when this variable is set, otherwise the compile-window or the last selected edit-window is choosen) when the called command is called to choose the 1. next window (always true for scrolling another window or true when other-window called without prefix-arg or with prefix-arg equal 1). Otherwise the window ARG steps away is choosen (in case of other-window).

If there is an active minibuffer but the minibuffer-window is not selected then other-window and scroll-other-window behave like the original version.

6.5.3 User-defined “other window” behavior

In addition to the builtin “other window” behaviors ECB offers a user to completely define for himself how ECB should choose another window for scrolling it or selecting it. This can be done with the option ecb-other-window-behavior too because this option can also have a function-symbol as value:

Such a function gets seven arguments:

  1. A canonical list of all currently visible windows of the ecb-frame
  2. A canonical list of all currently visible edit-windows
  3. A canonical list of all currently visible ecb-windows
  4. The window-object of the compile-window if there is any.
  5. The minibuffer-window of the ECB-frame if there is an active minibuffer.
  6. The result of the function ecb-where-is-point - see the documentation of this function for details.
  7. An integer which indicates how many steps away from the current selected window the “other-window” is. Is nil when this function is called in another context than for other-window.

The function has to return a window-object which is then used as “other window” for the command other-window or for scrolling another window (e.g. with scroll-other-window). Such a function has to handle properly all situation for itself.

Here is an example for such a function:

   (defun ecb-get-other-window-smart (win-list
     "Implements the smart-setting of `ecb-other-window-behavior'."
     (if minibuf-win
         ;; if we have an active mini-buffer we delegate this to
         ;; `ecb-get-other-window-minibuf-active'
         (ecb-get-other-window-minibuf-active win-list
       ;; here we have no active minibuffer!
       (let ((nth-win (or nth-window 1)))
         (cond ((equal point-loc 'ecb)
                (ecb-next-listelem ecb-win-list (selected-window) nth-win))
               ((equal point-loc 'compile)
                (if (= nth-win 1)
                    (or (and ecb-last-edit-window-with-point
                             (window-live-p ecb-last-edit-window-with-point)
                        (car edit-win-list))
                  (ecb-next-listelem (append edit-win-list
                                             (list (selected-window)))
               (t ;; must be an edit-window
                (ecb-next-listelem (append edit-win-list
                                           (if (and comp-win
                                                    (= (length edit-win-list)
                                               (list comp-win)))

This example implements the builtin smart behavior described above.


[1] other-window allows to select ARG'th different window, i.e. the window ARG steps away from current window in the cyclic order of the windows

[2] other-window uses the same window-ordering as walk-windows