;;; ecb-layout.el --- layout for ECB ;; Copyright (C) 2000 - 2003 Jesper Nordenberg, ;; Klaus Berndl, ;; Kevin A. Burton, ;; Free Software Foundation, Inc. ;; Author: Jesper Nordenberg ;; Klaus Berndl ;; Kevin A. Burton ;; Maintainer: Klaus Berndl ;; Kevin A. Burton ;; Keywords: browser, code, programming, tools ;; Created: 2000 ;; This program is free software; you can redistribute it and/or modify it under ;; the terms of the GNU General Public License as published by the Free Software ;; Foundation; either version 2, or (at your option) any later version. ;; This program is distributed in the hope that it will be useful, but WITHOUT ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ;; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ;; details. ;; You should have received a copy of the GNU General Public License along with ;; GNU Emacs; see the file COPYING. If not, write to the Free Software ;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ;; $Id: ecb-layout.el,v 1.243 2004/12/01 14:19:39 berndl Exp $ ;;; Commentary: ;; ;; Contains functions for settings the ECB layout. ;; ;; This file is part of the ECB package which can be found at: ;; http://ecb.sourceforge.net ;; This file has been re-implemented by Klaus Berndl . ;; What has been done: ;; Completely rewritten the layout mechanism for better customizing, adding ;; new layouts, better redrawing and more straightforward code. ;; 1. Now all user-layouting is done by customizing the new option ;; `ecb-layout-name' or by the command `ecb-change-layout'. The function ;; `ecb-redraw-layout' (formally known as 'ecb-set-layout) can still be ;; called interactively. But it just redraws the layout specified in ;; `ecb-layout-name'. All changes to the layout must be made by customizing ;; this new option. Please read the very detailed comment of ;; `ecb-layout-name'! ;; 2. Adding new layouts is now much easier and more straightforward: We have ;; now a main core-layout function (`ecb-redraw-layout-full') which is the ;; "environment" for the specific "layout-functions". The core function ;; does first some layout independent actions, then calls the ;; "layout-function" for the name which has been set in `ecb-layout-name' ;; and after that it does some layout independent actions again (see the ;; comments in this function). See the macro `ecb-layout-define' and the ;; command `ecb-create-new-layout'! ;; ;; Background-info: For each layout-type (ecb-windows left, right, top and ;; left-right) there is one function: ;; 'ecb-delete-window-ecb-windows-[left|right|top|leftright]'. ;; These functions follow these guide-lines: ;; - Preconditions for these functions: ;; + the edit-area is splitted - at least in two edit-windows ;; + The function gets two arguments: The window to delete (if nil then the ;; current window has to be deleted) and the list of all current ;; edit-windows. ;; + These functions are always(!) called with deactivated advices of ;; `delete-window' function. ;; + These functions can only use `delete-window' of the set of maybe ;; adviced window functions, because of a bug in advice.el only one ;; functionīs advice can be deactivated within a advice itself! ;; - What must they do: Doing the appropriate action (e.g. ;; `ecb-delete-window-ecb-windows-left' must delete the window. This action ;; must be done appropriate for the current ECB-layout type (see ;; postconditions) ;; - Postcondition of these functions: ;; + The named edit-window must be deleted and all ecb-windows in the ;; ecb-frame must have the layout like before the delete. ;; + If the current window has been deleted then point must reside after ;; deletion in the next edit-window in a circular meaning (i.e. if the ;; last edit-window has been deleted, point must stay afterwards in the ;; first edit-window). If a window unequal the current window has been ;; deleted point must stay in the window before deletion at the same ;; place. ;; ;; New adviced intelligent window-functions as replacement for these originals: ;; - `other-window' ;; - `delete-window' ;; - `delete-other-windows' ;; - `delete-windows-on' ;; - `split-window-horizontally' ;; - `split-window-vertically' ;; - `split-window' ;; - `display-buffer' ;; - `switch-to-buffer' ;; - `switch-to-buffer-other-window' ;; - `other-window-for-scrolling' ;; - `balance-windows' ;; The behavior of the adviced functions is: ;; - All these function behaves exactly like their corresponding original ;; functions but they always act as if the edit-window(s) of ECB would be the ;; only window(s) of the ECB-frame. So the edit-window(s) of ECB seems to be ;; a normal Emacs-frame to the user. ;; - If a durable compile-window is used all buffers for which ;; `ecb-compilation-buffer-p' returns not nil are handled in the ;; compile-window! ;; ;; IMPORTANT: A note for programming Elisp for packages which work during ;; activated ECB (for ECB itself too :-): ECB offers three macros for easy ;; temporally (regardless of the settings in `ecb-advice-window-functions'!) ;; using all original-functions, all adviced functions or only some adviced ;; functions: ;; - `ecb-with-original-functions' ;; - `ecb-with-adviced-functions' ;; - `ecb-with-some-adviced-functions' ;; ;;; History ;; ;; For the ChangeLog of this file see the CVS-repository. For a complete ;; history of the ECB-package see the file NEWS. ;;; Code: (eval-when-compile (require 'silentcomp)) (require 'ecb-util) (require 'ecb-speedbar) (require 'ecb-compilation) (require 'ecb-create-layout) ;; XEmacs (silentcomp-defvar scrollbars-visible-p) (silentcomp-defun window-displayed-height) (silentcomp-defvar pre-display-buffer-function) (silentcomp-defvar split-width-threshold) (silentcomp-defvar split-width-threshold) (silentcomp-defun popup-menu-and-execute-in-window) (silentcomp-defvar modeline-map) (silentcomp-defun modeline-menu) ;; for the display-buffer stuff of XEmacs (silentcomp-defun last-nonminibuf-frame) (silentcomp-defun check-argument-type) (silentcomp-defun buffer-dedicated-frame) (silentcomp-defun display-buffer-1) (silentcomp-defun frame-property) (silentcomp-defun window-leftmost-p) (silentcomp-defun window-rightmost-p) (silentcomp-defun window-parent) (silentcomp-defun window-previous-child) (silentcomp-defun window-next-child) (silentcomp-defun window-pixel-edges) (silentcomp-defun window-pixel-height) (silentcomp-defun record-buffer) (silentcomp-defun push-window-configuration) (silentcomp-defun set-frame-property) (silentcomp-defvar temp-buffer-shrink-to-fit) ;; Emacs (silentcomp-defvar scroll-bar-mode) ;; only Emacs 21 has this (silentcomp-defvar window-size-fixed) (silentcomp-defun fit-window-to-buffer) (silentcomp-defvar temp-buffer-resize-mode) (silentcomp-defun temp-buffer-resize-mode) ;; Emacs 21 (silentcomp-defvar grep-window-height) (eval-when-compile ;; to avoid compiler grips (require 'cl)) (defvar ecb-layouts-reload-needed t) (defun ecb-load-layouts () "Load all defined layouts" (when ecb-layouts-reload-needed (require 'ecb-layout-defs) (if (file-readable-p ecb-create-layout-file) (load-file ecb-create-layout-file)) (setq ecb-layouts-reload-needed nil))) (defgroup ecb-layout nil "Settings for the screen-layout of the Emacs code browser." :group 'ecb :prefix "ecb-") (defgroup ecb-compilation nil "Settings for the compile window of ECB." :group 'ecb-layout :prefix "ecb-") (defconst ecb-layout-option-set-function (function (lambda (symbol value) (set symbol value) ;; we must check this because otherwise the layout would be drawn ;; if we have changed the initial value regardless if ECB is ;; activated or not. (when (and (boundp 'ecb-minor-mode) ecb-minor-mode (frame-live-p ecb-frame)) (let ((curr-frame (selected-frame))) (unwind-protect (progn (select-frame ecb-frame) (ecb-redraw-layout-full)) (select-frame curr-frame))))))) (defcustom ecb-select-edit-window-on-redraw nil "*Select the first edit window on `ecb-redraw-layout'." :group 'ecb-layout :type 'boolean) (defcustom ecb-new-ecb-frame nil "*Create a new frame at activation time of ECB." :group 'ecb-layout :group 'ecb-most-important :type 'boolean) (defcustom ecb-activate-before-new-frame-created-hook nil "*Hook run before the new ECB-frame is created. This has only an effect if `ecb-new-ecb-frame' is not nil \(otherwise this hook is not evaluated)." :group 'ecb-layout :type 'hook) (defvar ecb-last-selected-layout nil "Name of that layout which was current direct before switching to another layout.") (defcustom ecb-layout-name "left8" "*Select a window layout of ECB. Value is any arbitrary string. There are four different types of layouts: left, right, top and left-right, which means the location of the ECB-tree-windows in the ECB-frame. Currently there are 20 predefined layouts; names see below. You can savely try out any of them by changing this value and saving it only for the current session. If you are sure which layout you want you can save it for future sessions. To get a picture of the layout for name call `ecb-show-layout-help'. Currently available layouts: + Left layouts: left1 left2 left3 left4 left5 left6 left7 left8 left9 left10 left11 left12 left13 left14 left15 + Right layouts: right1 + Top layouts: top1 top2 + Left-right layouts: leftright1 leftright2 leftright3 Regardless of the settings you define here: If you have destroyed or changed the ECB-screen-layout by any action you can always go back to this layout with `ecb-redraw-layout'" :group 'ecb-layout :group 'ecb-most-important :initialize 'custom-initialize-default :set (function (lambda (symbol value) (ecb-load-layouts) (if (fboundp (intern (format "ecb-layout-function-%s" value))) (progn (setq ecb-last-selected-layout ecb-layout-name) (funcall ecb-layout-option-set-function symbol value)) (ecb-error "There is no layout with name %s available!" value)))) :type 'string) (defun ecb-enable-temp-buffer-shrink-to-fit (arg) "Enables `temp-buffer-resize-mode' \(GNU Emacs) rsp. `temp-buffer-shrink-to-fit' \(XEmacs) when a comile-window is used. When the compile-window is disabled or when ECB is deactivated then the old state of these modes/variables is restored." (if arg (progn ;; store old value if not already done (or (get 'ecb-enable-temp-buffer-shrink-to-fit 'ecb-old-temp-buffer-shrink-to-fit) (put 'ecb-enable-temp-buffer-shrink-to-fit 'ecb-old-temp-buffer-shrink-to-fit (cons 'stored (if ecb-running-xemacs temp-buffer-shrink-to-fit temp-buffer-resize-mode)))) ;; now we activate temp-buffer-shrinking (if ecb-running-xemacs (setq temp-buffer-shrink-to-fit t) (temp-buffer-resize-mode 1)) ) ;; reset to the original value (and (get 'ecb-enable-temp-buffer-shrink-to-fit 'ecb-old-temp-buffer-shrink-to-fit) (if ecb-running-xemacs (setq temp-buffer-shrink-to-fit (cdr (get 'ecb-enable-temp-buffer-shrink-to-fit 'ecb-old-temp-buffer-shrink-to-fit))) (temp-buffer-resize-mode (if (cdr (get 'ecb-enable-temp-buffer-shrink-to-fit 'ecb-old-temp-buffer-shrink-to-fit)) 1 -1)))) (put 'ecb-enable-temp-buffer-shrink-to-fit 'ecb-old-temp-buffer-shrink-to-fit nil))) (defcustom ecb-compile-window-height nil "*Height of the durable compilation-window of ECB. If you want a compilation window shown at the bottom of the ECB-layout then set here the height of it \(Default is a height of 5). If you redraw the current layout with `ecb-redraw-layout' then the compilation window (if any) has the height you set here. If the number is less than 1.0 the height is a fraction of the frame height. If you do not set a durable compilation window then doing a compilation or displaying temp-buffers \(e.g. *Help*-buffers) splits temporally the edit window vertically if the edit window is not splitted already or uses another edit window temporally for compilation output if the edit window is already splitted. This is the recommended value for this option because this is the standard-behavior of Emacs. Beware: If you set a durable compilation window then ECB displays all buffers for which `ecb-compilation-buffer-p' returns not nil in that durable compilation window. If a buffer which should being displayed there is not displayed there then try to modify the options `ecb-compilation-buffer-names', `ecb-compilation-major-modes' or `ecb-compilation-predicates' \(in this sequence). See also the options `ecb-compile-window-temporally-enlarge' and `ecb-enlarged-compilation-window-max-height' and also the command `ecb-toggle-compile-window-height'! ECB offers the functionality of such a durable compile-window regardless if the special ECB-windows are visible or not \(see the command `ecb-toggle-ecb-windows'). Regardless of the settings you define here: If you have destroyed or changed the ECB-screen-layout by any action you can always go back to this layout with `ecb-redraw-layout'" :group 'ecb-compilation :group 'ecb-most-important :initialize 'custom-initialize-default ;; we can not use here ' ecb-layout-option-set-function' because here we ;; must call `ecb-redraw-layout-full' with NO-ECB-WINDOWS depending on the ;; value of `ecb-windows-hidden'! Same for `ecb-compile-window-width'. If ;; this is necessary for other options too then we should ;; `ecb-layout-option-set-function' to a function with an additional ;; parameter which decides if ecb-window-hidden should be used for ;; NO-ECB-WINDOWS or not. :set (function (lambda (symbol value) (ecb-set-window-size-fixed nil) (set symbol value) ;; we must check this because otherwise the layout would be ;; drawn if we have changed the initial value regardless if ;; ECB is activated or not. (when (and (boundp 'ecb-minor-mode) ecb-minor-mode (frame-live-p ecb-frame)) (ecb-enable-temp-buffer-shrink-to-fit value) (let ((curr-frame (selected-frame))) (unwind-protect (progn (select-frame ecb-frame) (ecb-redraw-layout-full nil nil nil ecb-windows-hidden)) (select-frame curr-frame)))))) :type '(radio (const :tag "No compilation window" nil) (number :tag "Window height" :value 6))) (defcustom ecb-compile-window-width 'frame "*Width of the compile-window. Possible values are 'frame and 'edit-window. With 'frame the compile-window looks like: ------------------------------------------------------- | | | | Directories | | | | | |--------------| edit-window(s) | | | | | Methods | | | | | ------------------------------------------------------- | | | Compilation | | | ------------------------------------------------------- With 'edit-window the compile-window looks like: ------------------------------------------------------- | | | | Directories | | | | | |--------------| edit-window(s) | | | | | Methods | | | | | | |--------------------------------------- | | | | | Compilation | | | | ------------------------------------------------------- This option takes only effect if `ecb-compile-window-height' is not nil!" :group 'ecb-compilation :group 'ecb-most-important :initialize 'custom-initialize-default :set (function (lambda (symbol value) (ecb-set-window-size-fixed nil) (set symbol value) ;; we must check this because otherwise the layout would be ;; drawn if we have changed the initial value regardless if ;; ECB is activated or not. (when (and (boundp 'ecb-minor-mode) ecb-minor-mode (frame-live-p ecb-frame)) (let ((curr-frame (selected-frame))) (unwind-protect (progn (select-frame ecb-frame) (ecb-redraw-layout-full nil nil nil ecb-windows-hidden)) (select-frame curr-frame)))))) :type '(radio (const :tag "Width of ECB-frame" :value frame) (const :tag "Width of edit-window" :value edit-window))) (defcustom ecb-change-layout-preserves-compwin-state t "*Changing the layout preserves the state of the compile-window. This is for example useful if the user toggles between several layouts \(see `ecb-toggle-layout') and wants to preserve the hidden-state of the compile-window." :group 'ecb-compilation :type 'boolean) (defcustom ecb-compile-window-temporally-enlarge 'after-display "*Let Emacs temporally enlarge the compile-window of the ECB-layout. This option has only an effect if `ecb-compile-window-height' is not nil! The following values are possible: - 'after-display: After displaying a \"compilation-buffer\" \(in the sense of `ecb-compilation-buffer-p'!) in the compile-window of ECB. For the max. height of the enlarged compile-window see the option `ecb-enlarged-compilation-window-max-height'. - 'after-selection: selecting the `ecb-compile-window' auto. enlarges it and de-selecting \(means leaving `ecb-compile-window') auto. shrinks it. Enlarging and shrinking the `ecb-compile-window' is done with `ecb-toggle-compile-window-height'. See also the documentation of this function! - 'both: The combination of 'after-display and 'after-selection. - nil: ECB fixes always the height of the `ecb-compile-window' at the value of `ecb-compile-window-height'. To restore the ECB-layout after such a buffer-enlarge just call `ecb-toggle-compile-window-height' or `ecb-redraw-layout'." :group 'ecb-compilation :type '(radio (const :tag "After displaying a buffer in the compile-window" :value after-display) (const :tag "After selecting the compile window" :value after-selection) (const :tag "Both of them" :value both) (const :tag "Never" :value nil))) (defcustom ecb-maximize-ecb-window-after-selection nil "*If not nil maximize current tree-window after selection. When selecting another not-tree-window after such an automatic maximizing all tree-windows of current layout are displayed again. But a tree-window is not maximized if either a node has been selected via primary- oder secondarc mouse-button or the popup-menu of that tree-buffer has been opened." :group 'ecb-layout :type 'boolean) ;; A value of never makes no sense because it is not much effort to prevent ;; all interactive shrinking commands (incl. mouse-commands) from shrinking it ;; below ecb-compile-window-height and it is also not worth. IMHO preventing ;; in non-interactive calls and allowing interactively is the best choice. ;; Allowing always is also possible and easy to implement. (defcustom ecb-compile-window-prevent-shrink-below-height t "*Allow the compile-window to be shrunken below its height. A non nil value means ECB prevents the compile-window from being shrunken below the threshold of `ecb-compile-window-height' by displaying temp-buffers \(e.g. *Help* etc.) or after running compilations or greps. But interactively it is always allowed to shrink it to every height! If nil then ECB does nothing to prevent being shrunken below the value of `ecb-compile-window-height'. Default is t." :group 'ecb-compilation :type 'boolean) (defcustom ecb-enlarged-compilation-window-max-height 'best "*The max height of the compile-window after enlarging it. The max height of the compilation window after enlarged by `ecb-toggle-compile-window-height'. The following values are allowed: 'best: ECB fits the height of the compile-window exactly to the size of its current contents but never shrinks below the value of `ecb-compile-window-height' or enlarges over the half of the frame-height of the ECB-frame. The values of the options `compilation-window-height' and `temp-buffer-max-height' are taken into account dependent of the current `major-mode' of the buffer in the compile-window: If `compilation-mode' then `compilation-window-height' is used otherwise `temp-buffer-max-height'. 'half: 1/2 the frame-height of the ECB-frame Any number: Max height in lines. If the number is less than 1.0 the height is a fraction of the frame height \(e.g. 0.33 results in a max-height of 1/3 the frame-height)." :group 'ecb-compilation :type '(radio (const :tag "Compute best height" :value best) (const :tag "1/2 the frame height)" :value half) (number :tag "Height" :value 0.3))) (defcustom ecb-scroll-other-window-scrolls-compile-window nil "*`scroll-other-window' scrolls always the compile-window. For all details about the scroll-behavior of `scroll-other-window' see the advice documentation of `other-window-for-scrolling'." :group 'ecb-compilation :type 'boolean) (defcustom ecb-ignore-special-display 'compile-window "*Ignore special-display-handling. This means, that all values of `special-display-function', `special-display-buffer-names' and `special-display-regexps' are ignored - only when durable compile window is used - i.e. if `ecb-compile-window-height' is not nil - this is the default value. - always when ECB is active - that means no special-display-handling of buffers when ECB is active - never, i.e. special-dislay-handling depends on the values of the options `special-display-function', `special-display-buffer-names' and `special-display-regexps'." :group 'ecb-layout :type '(radio (const :tag "When a durable compile-window is used" :value compile-window) (const :tag "Always" :value always) (const :tag "Never" nil))) (defsubst ecb-ignore-special-display () (or (equal ecb-ignore-special-display 'always) (and (equal ecb-ignore-special-display 'compile-window) ecb-compile-window-height))) (defcustom ecb-ignore-display-buffer-function 'always "*Adviced `display-buffer' ignores `display-buffer-function'. This means, that the adviced version of `display-buffer' \(see `ecb-advice-window-functions') ignores the value of `display-buffer-function' when called for the `ecb-frame'. If this variable should not be ignored then the function of `display-buffer-function' is completely responsible which window is used for the buffer to display - no smart ECB-logic will help to deal best with the ECB-window-layout! You can define if and when `display-buffer-function' should be ignored: - only when durable compile window is used - i.e. if `ecb-compile-window-height' is not nil - always when ECB is active - that means ignore when ECB is active otherwise not - this is the default value - never, the adviced version of `display-buffer' always uses the value of `display-buffer-function' if the value is a function." :group 'ecb-layout :type '(radio (const :tag "When a durable compile-window is used" :value compile-window) (const :tag "Always" :value always) (const :tag "Never" nil))) (defsubst ecb-ignore-display-buffer-function () (or (equal ecb-ignore-display-buffer-function 'always) (and (equal ecb-ignore-display-buffer-function 'compile-window) ecb-compile-window-height))) (defcustom ecb-split-edit-window-after-start 'before-deactivation "*Sets how and if the edit window should be splitted after ECB-start. But be aware: This option determines only if and how the edit-window should be splitted at start-time of ECB. There are five different values allowed for this option: - nil: Do not split the edit-area of ECB after activation, i.e. there will be only one edit-window after starting ECB. - 'horizontal: Split the edit-area in 2 edit-windows side by side. - 'vertical: Split the edit-area in 2 edit-windows, one above the other. - 'before-activation: Split the edit-area as before the ECB-start, i.e. the edit-area will have after start a window-layout as the whole frame had before the start of ECB. - 'before-deactivation: Split the edit-area into a window-layout ECB had in its edit-area direct before the ECB-deactivation. This value preserves the full state between activations of ECB, i.e. the visibility of the ECB-windows, the visibility of a compile-window and also the full split-state of the edit-area. But this can only be done if important layout-options have not been changed in the meanwhile. These are the options `ecb-layout-name', `ecb-compile-window-height', `ecb-compile-window-width', `ecb-windows-width' and `ecb-windows-height'. Default value is 'before-deactivation. Some remarks to the value 'before-activation: If this value has been set then ECB needs four permanent adivces even when ECB is deactivated: `split-window', `delete-window', `delete-other-windows' and `set-window-configuration'. But these advices do not change any behavior of these functions but only storing in an internal ECB-variable the facts that a window has been splitted or deleted etc. In addition to this these advices are 100% error-save, means the functionality of the original functions will be performed in every\(!) case even if within the advice an error occurs \(but normally there can no errors occur in these advices because they are very simple). Conclusion: If you want really all ECB-advices being disabled after deactivating ECB then you have to set this option to other values then 'before-activation. But setting this variable to this value is really completely save." :group 'ecb-layout :type '(radio (const :tag "Split as before ECB-start" :value before-activation) (const :tag "Split as before last ECB-deactivation" :value before-deactivation) (const :tag "Split horizontally" :value horizontal) (const :tag "Split vertically" :value vertical) (const :tag "Do not split" :value nil))) (defcustom ecb-windows-width 0.33 "*The width of the ECB windows in columns for left- and right layouts. If the number is less than 1.0 the width is a fraction of the frame width." :group 'ecb-layout :initialize 'custom-initialize-default :set ecb-layout-option-set-function :type 'number) (defcustom ecb-windows-height 0.33 "*The height of the ECB windows in lines for top layouts. If the number is less than 1.0 the width is a fraction of the frame height." :group 'ecb-layout :initialize 'custom-initialize-default :set ecb-layout-option-set-function :type 'number) (defcustom ecb-fix-window-size nil "*Fix size of the ECB-windows/buffers even after frame-resizing. The fix type \(valid values are nil, t, width and height) can either be set on a layout-basis \(means a different value for each layout) or one value can be set for all layouts. In the latter case there is an additional value 'auto which choose autom. the senseful fix-type depending on the current layout-type: For top-layouts the fix-type 'height and for all other layout-types the fix-type 'width. For a detailed description of the valid values see documentation of `window-size-fixed' which is newly introduced in GNU Emacs 21 and is only available there. Therefore this option takes only effect with GNU Emacs 21. Note1: Manually resizing the ECB-windows via `enlarge-window', `shrink-window', `mouse-drag-vertical-line' and `mouse-drag-mode-line' is still possible even if the window-sizes are fixed for frame-resizing! Note2: The description of `window-size-fixed' in the elisp-info-manual is more detailed than the description offered by \[C-h v]! Note3: With current Emacs 21.2.X there seems to be no distinction between 'width, 'height and t. Therefore this option takes no effect \(means all ecb-windows have always unfixed sizes) if `ecb-compile-window-height' is not nil. Per default no window-size fixing has been done." :group 'ecb-directories :initialize 'custom-initialize-default :set (function (lambda (sym value) (set sym value) (ecb-set-window-size-fixed (ecb-get-window-fix-type ecb-layout-name)))) :type '(radio (choice :tag "Fix type for all layouts" :menu-tag "Fix type for all layouts" (const :tag "Automatic" :value auto) (const :tag "Fix only width" :value width) (const :tag "Fix only height" :value height) (const :tag "Fix both" :value t) (const :tag "No fixing" :value nil)) (repeat :tag "With these layouts" (cons (string :tag "Layout name") (choice :tag "Fix type" :menu-tag "Fix type for all layouts" (const :tag "Fix only width" :value width) (const :tag "Fix only height" :value height) (const :tag "Fix both" :value t) (const :tag "No fixing" :value nil)))))) (defun ecb-get-window-fix-type (layout-name) "Determine which value of `window-size-fixed' we must set in all ecb-buffers of layout LAYOUT-NAME." (if (symbolp ecb-fix-window-size) (if (equal ecb-fix-window-size 'auto) (if (equal (ecb-get-layout-type ecb-layout-name) 'top) 'height 'width) ecb-fix-window-size) (cdr (assoc layout-name ecb-fix-window-size)))) (defun ecb-set-window-size-fixed (fix) "Set the buffer-local value of `window-size-fixed' in each visible ecb-window to FIX. If `ecb-compile-window-height' is not nil then set always nil!" (when ecb-running-emacs-21 (let ((l (ecb-canonical-ecb-windows-list))) (dolist (w l) (save-excursion (set-buffer (window-buffer w)) (setq window-size-fixed (if ecb-compile-window-height nil fix))))))) (defmacro ecb-do-with-unfixed-ecb-buffers (&rest body) "Evaluate BODY with unfixed size of all current-visible ecb-buffers and ensure that at the end \(either after finishing of BODY or after an error occurs during BODY) all now current visible ecb-buffers get the value of their buffer-local `window-size-fixed' from the setting in `ecb-fix-window-size'." `(unwind-protect (progn (ecb-set-window-size-fixed nil) ,@body) (ecb-set-window-size-fixed (ecb-get-window-fix-type ecb-layout-name)))) (defcustom ecb-other-window-behavior 'smart "*The behavior of ECB concerning getting an \"other window\". This has an effect if either `other-window' or `other-window-for-scrolling' is adviced by ECB, see `ecb-advice-window-functions'. The following settings are possible: 'all: ECB will cycle through all windows of the ECB-frame or scroll simply the next window in the ECB-frame, means it behaves like the original `other-window' rsp. the original `other-window-for-scrolling'. 'only-edit: ECB will only cycle through the edit-windows of ECB or only scroll another edit-window. If the selected window is not an edit-window then it behaves like with value 'all. 'edit-and-compile: Like 'only-edit plus the compile window if any. If the selected window is neither an edit-window nor the compile-window then it behaves like with value 'all. 'smart: With this setting ECB tries to choose the `other-window'-destination or the \"other window\" to scroll in a smart and intuitive way: If point is in one of the edit-windows and if the edit-area is splitted then always the \"next\" edit-window is choosen \(whereas the next edit-window of the last edit-window is the first edit-window)- if the edit-area is unsplitted then the compile-window is used if there is one. In the context of an `other-window'-call the ARG of `other-window' will be taken into account. If one of the special ecb-windows is selected then always the \"next\" ecb-window is choosen \(whereas the next ecb-window of the last ecb-window is the first ecb-window). In the context of an `other-window'-call the ARG of `other-window' will be taken into account. If there is only one ecb-window then ECB considers also the edit-windows! If the compile-window is selected then always the last selected edit-window will be used unless `other-window' has been called with a prefix-argument unequal 1. If there is an active minibuffer: Regardless of the allowed values 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. In addition to the allowed values above the value of this option can also be a function: This 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. 5. The result of the function `ecb-where-is-point' - see the documentation of this function for details. 6. 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 then 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'). This function has to handle all properly situations for itself. `ecb-get-other-window-smart' is an example for such a function." :group 'ecb-layout :group 'ecb-most-important :type '(radio (const :tag "Smart" :value smart) (const :tag "All windows" all) (const :tag "Only edit windows" only-edit) (const :tag "Edit + compile window" edit-and-compile) (function :tag "User defined" :value ignore))) (defcustom ecb-advice-window-functions '(other-window delete-window delete-other-windows delete-windows-on split-window-horizontally split-window-vertically split-window switch-to-buffer switch-to-buffer-other-window display-buffer other-window-for-scrolling balance-windows) "*Advice functions to be more intelligent if used with ECB. You can choose the following functions to be adviced by ECB so they behave as if the edit-window\(s) of ECB would be the only windows\(s) of the ECB-frame: - `other-window' For this one see also the option `ecb-other-window-behavior'! - `delete-window' - `delete-other-windows' - `delete-windows-on' - `split-window-horizontally' - `split-window-vertically' - `split-window' If this is enabled then `split-window-vertically' and `split-window-horizontally' are autom. enabled too! - `switch-to-buffer' - `switch-to-buffer-other-window' - `display-buffer' Especially if `ecb-compile-window-height' is not nil it is strongly recommended not to disable this advice! - `other-window-for-scrolling': If this advice is enabled then the behavior of the following functions depends on `ecb-other-window-behavior': - `scroll-other-window' - `scroll-other-window-down' - `beginning-of-buffer-other-window' - `end-of-buffer-other-window' - `balance-windows': Only the edit-windows of the ecb-frame are balanced. For working most conveniently with ECB it is the best to advice all these functions, because then all the standard shortcuts of these functions are also usable with ECB without doing anything else. Also other packages can interact best with ECB if these functions are all adviced. If these adviced functions are called in another frame than the ECB-frame they behave all exactly like the not adviced versions! But please read also the following: Normally all packages should work correct with ECB and itīs adviced functions but if there occur problems with a package cause of some of these adviced functions ECB offers the following fall-back solution: 1. Deactivate in `ecb-advice-window-functions' all the adviced-functions which make problems with other packages. 2. For every of the advice-able functions ECB offers a interactively function named \"ecb-\" which does exactly the same as the adviced version of . Use \"ecb-\" instead the original one to get the proper ECB behavior even if the function is not adviced anymore. 3. You can bind in `ecb-activate-hook' the standard-shortcut of to \"ecb-\" and rebind it in `ecb-deactivate-hook' to . 4. Now you have the best of both worlds: The problematic package works and you have the ECB-behavior of as if it would be adviced. Here is an example: Suppose you must deactivating the advice for `switch-to-buffer-other-window'. Then you deactivate this function with this option and you can use `ecb-switch-to-buffer-other-window' instead. Bind the shortcut you normally use for `switch-to-buffer-other-window' to `ecb-switch-to-buffer-other-window' \(use `ecb-activate-hook' for this) and rebind it to the original function in the `ecb-deactivate-hook'." :group 'ecb-layout :initialize 'custom-initialize-set :set (function (lambda (symbol value) (when (member 'split-window value) (add-to-list 'value 'split-window-vertically) (add-to-list 'value 'split-window-horizontally)) (set symbol value) (when (and (boundp 'ecb-minor-mode) ecb-minor-mode) (ecb-activate-adviced-functions value)))) :type '(set (const :tag "other-window" :value other-window) (const :tag "delete-window" :value delete-window) (const :tag "delete-other-windows" :value delete-other-windows) (const :tag "delete-windows-on" :value delete-windows-on) (const :tag "split-window-horizontally" :value split-window-horizontally) (const :tag "split-window-vertically" :value split-window-vertically) (const :tag "split-window" :value split-window) (const :tag "switch-to-buffer" :value switch-to-buffer) (const :tag "switch-to-buffer-other-window" :value switch-to-buffer-other-window) (const :tag "display-buffer" :value display-buffer) (const :tag "other-window-for-scrolling" :value other-window-for-scrolling) (const :tag "balance-windows" :value balance-windows))) (defcustom ecb-advice-window-functions-signal-error nil "*Signal an error if an adviced function can not do its job. If not nil then an error is signaled if one of the adviced functions \(see `ecb-advice-window-functions') can not do its job. So for example if the user tries to split the compile-window or an ecb-tree-window or if one tries to switch to another buffer in one of the ecb-tree-windows. For details see the documentation of each of the adviced functions to get info when an error is signaled. If this option is nil then no error is signaled but the called adviced function does simply nothing. Default is nil but it can also be useful to signal errors - so you see when call a function in a situation which is not supported by this function." :group 'ecb-layout :type 'boolean) (defcustom ecb-layout-always-operate-in-edit-window '(switch-to-buffer) "*Adviced window functions work always in the edit-window. If we are in an ECB special buffer (methods, directories, etc), and any of the adviced windowing functions is called interactively \(see `ecb-advice-window-functions'), we will select first an edit-window according to the value of `ecb-mouse-click-destination'. This is useful if you have any functions that use such functions and you don't want them to fail with an error complaining that the current buffer can not be split, or something similar. Because this may not be desirable in all situations and for all adviced functions this can be enabled separately for every advicable function \(see also `ecb-advice-window-functions'). If the symbol of an adviced function is contained in the value of this option, then the edit-window is first selected otherwise either an error is reported or some other special reaction (depends on `ecb-advice-window-functions-signal-error'); see the documentation of the adviced functions for this. For `other-window', `other-window-for-scrolling', `display-buffer' and `switch-to-buffer-other-window' this makes no sense, therefore you can not enable this for them. Per default this is only enabled for `switch-to-buffer'." :group 'ecb-layout :type '(set (const :tag "delete-window" :value delete-window) (const :tag "delete-other-windows" :value delete-other-windows) (const :tag "split-window-horizontally" :value split-window-horizontally) (const :tag "split-window-vertically" :value split-window-vertically) (const :tag "split-window" :value split-window) (const :tag "display-buffer" :value display-buffer) (const :tag "switch-to-buffer" :value switch-to-buffer))) (defun ecb-canonical-ecb-windows-list (&optional winlist) "Return a list of all current visible special dedicated ECB-windows \(starting from the left-most top-most window) in the order `other-window' would walk through these windows." (let ((windows-list (or winlist (ecb-canonical-windows-list)))) (delete nil (mapcar (function (lambda (elem) (if (and (not (member elem ecb-layout-temporary-dedicated-windows)) (window-dedicated-p elem)) elem))) windows-list)))) (defun ecb-canonical-edit-windows-list (&optional winlist) "Return a list of all current edit-windows \(starting from the left-most top-most window) in the order `other-window' would walk through these windows. These are all windows in the `ecb-frame' which are not identical to the compile-window and not identical to one of the visible ECB-windows." (let ((comp-win-state (ecb-compile-window-state)) (windows-list (or winlist (ecb-canonical-windows-list)))) (delete nil (mapcar (function (lambda (elem) (if (and (or (member elem ecb-layout-temporary-dedicated-windows) (not (window-dedicated-p elem))) (or (not (equal comp-win-state 'visible)) (not (equal elem ecb-compile-window)))) elem))) windows-list)))) (defcustom ecb-layout-window-sizes nil "*Specifies the sizes of the ECB windows for each layout. The easiest way \(and also the strongly recommended way) to change this variable is to change the window sizes by dragging the window borders using the mouse and then store the window sizes by calling the command `ecb-store-window-sizes'. Next time the layout is redrawn the values stored in this option will be used. If `ecb-store-window-sizes' is used then the windows sizes are stored per default as fractions of current frame-width and -height of the ecb-frame, so the stored values will \"work\" for other frame sizes too. But if you call `ecb-store-window-sizes' with a prefix-argument then the fixed values of current width and height are stored! If this option is set \"by hand\" \(i.e. not by `ecb-store-window-sizes') then the following is important: - It is recommended to use fractions of frame-width and -height!. - The order of the sequence of the inserted window sizes must be the same as `other-window' \(the not-adviced version!) would walk!" :group 'ecb-layout :initialize 'custom-initialize-default :set ecb-layout-option-set-function :type '(repeat (cons :tag "Window layout" (string :tag "Layout name") (repeat :tag "Window sizes" (cons (choice :tag "Width" :menu-tag "Width" :value 0.0 (const :tag "Default value" :value nil) (number :tag "Custom size")) (choice :tag "Height" :menu-tag "Height" (const :tag "Default value" :value nil) (number :tag "Custom size"))))))) (defcustom ecb-redraw-layout-quickly nil "If non-nil, we will attempt to redraw the layout quickly. Please read also carefully the documentation of `ecb-redraw-layout'." :type 'boolean :group 'ecb-layout) (defcustom ecb-toggle-layout-sequence '("left9" "left14") "*Toggle sequence for layout toggling with `ecb-toggle-layout'. Every element of this list has to be a valid layout-name \(a string) i.e. either one of the predefined layouts or one of the user-defined layouts \(see `ecb-create-new-layout'). You can add here as many layouts as you want but to use this option most effective you should not add more than 2 or 3 layouts so every layout can be accessed very fast by toggling with `ecb-toggle-layout'. It is also senseful to add layouts which have the same principal outline, i.e. all their tree-buffers are on the same side of the frame and the tree-buffer-\"column\" \(or -\"row\") has identical size for the layouts. Recommended values are for example: - \(\"left10\" \"left15\"), toggles between methods and directories/history - \(\"left10\" \"left13\"), toggles between methods and directories - \(\"left10\" \"left14\"), toggles between methods and history - \(\"left10\" \"left13\" \"left14\"), toggles between methods, history and directories See also option `ecb-show-sources-in-directories-buffer'. This option makes only sense if the value is a list with more than 1 element!" :group 'ecb-layout :type '(repeat (string :tag "Layout name.")) :initialize 'custom-initialize-default :set (function (lambda (symbol value) (ecb-load-layouts) (dolist (name value) (if (and (boundp 'ecb-minor-mode) ecb-minor-mode (not (fboundp (intern (format "ecb-layout-function-%s" name))))) (ecb-error "There is no layout available with name %s!" name))) (set symbol value)))) (defcustom ecb-hide-ecb-windows-before-hook nil "*Hook run direct before the ECB windows will be hidden. Hiding is done either by `ecb-toggle-ecb-windows' or `ecb-hide-ecb-windows'. This means that at runtime of this hook all the ECB-tree-windows of current layout are visible. IMPORTANT: Showing the hidden ECB-windows is internally done by calling `ecb-redraw-layout' and therefore also the hooks `ecb-redraw-layout-before-hook' and `ecb-redraw-layout-after-hook' are evaluated. The hook-sequence is analogous to that described in `ecb-show-ecb-windows-before-hook'." :group 'ecb-layout :type 'hook) (defcustom ecb-hide-ecb-windows-after-hook nil "*Hooks run direct after the ECB windows have been hidden. Hiding was done either by `ecb-toggle-ecb-windows' or `ecb-hide-ecb-windows'. IMPORTANT: Showing the hidden ECB-windows is internally done by calling `ecb-redraw-layout' and therefore also the hooks `ecb-redraw-layout-before-hook' and `ecb-redraw-layout-after-hook' are evaluated. The hook-sequence is analogous to that described in `ecb-show-ecb-windows-after-hook'." :group 'ecb-layout :type 'hook) (defcustom ecb-show-ecb-windows-before-hook nil "*Hooks run direct before the ECB windows will be shown. Showing is done either by `ecb-toggle-ecb-windows' or `ecb-show-ecb-windows'. This means that at runtime of this hook the ECB-windows are still hidden. IMPORTANT: Showing the hidden ECB-windows is internally done by calling `ecb-redraw-layout' and therefore also the hooks `ecb-redraw-layout-before-hook' and `ecb-redraw-layout-after-hook' are evaluated. So there is the following sequence of hooks during the process of showing the hidden ECB-windows: 1. `ecb-show-ecb-windows-before-hook' 2. `ecb-redraw-layout-before-hook' 3.