1 ;;; ecb-compatibility.el --- ECB-compatibility for other packages
3 ;; Copyright (C) 2000 - 2003 Jesper Nordenberg,
6 ;; Free Software Foundation, Inc.
8 ;; Author: Klaus Berndl <klaus.berndl@sdm.de>
9 ;; Maintainer: Klaus Berndl <klaus.berndl@sdm.de>
10 ;; Kevin A. Burton <burton@openprivacy.org>
11 ;; Keywords: browser, code, programming, tools
14 ;; This program is free software; you can redistribute it and/or modify it under
15 ;; the terms of the GNU General Public License as published by the Free Software
16 ;; Foundation; either version 2, or (at your option) any later version.
18 ;; This program is distributed in the hope that it will be useful, but WITHOUT
19 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20 ;; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
23 ;; You should have received a copy of the GNU General Public License along with
24 ;; GNU Emacs; see the file COPYING. If not, write to the Free Software
25 ;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 ;; $Id: ecb-compatibility.el,v 1.7 2004-12-10 16:34:19 berndl Exp $
31 ;; Contains compatibility-code for other-packages.
33 ;; Whenever commands of other packages are not fully compatible with ECB then
34 ;; this library should contain the necessary code to make it fully compatible
35 ;; - or at least working acceptable.
37 ;; This file is part of the ECB package which can be found at:
38 ;; http://ecb.sourceforge.net
41 (require 'silentcomp))
47 ;; To add compatibilty code for packages just do:
49 ;; 1. Add the needed advice(s) to `ecb-compatibility-advices'
50 ;; 2. Add the advice-code below.
52 ;; All advices of `ecb-compatibility-advices' will be autom. enabled when ECB
53 ;; starts and autom. disabled when ECB shuts down. No advice is enabled just
54 ;; by loading the ECB-library!
56 (defvar ecb-compatibility-advices '((bs-show . before)
57 (Electric-pop-up-window . around)
58 (electric-command-history . before)
59 (electric-buffer-list . before)
60 (electric-buffer-list . after))
61 "Contains all advices needed for package-compatibility.")
63 (defadvice bs-show (before ecb)
64 "Ensures `bs-show' works well when called from another window as an
65 edit-window. Does nothing if called in another frame as the `ecb-frame'."
66 (when (equal (selected-frame) ecb-frame)
67 (unless (ecb-point-in-edit-window)
68 (ecb-select-edit-window))
69 ;; now we handle if bs-show should always display in the compile-window
70 (let ((my-bs-buffer (get-buffer-create "*buffer-selection*")))
71 ;; ecb-compilation-buffer-p needs a living buffer!
72 (when (and (ecb-compilation-buffer-p my-bs-buffer)
73 ecb-compile-window-height)
74 (ecb-with-adviced-functions
75 (display-buffer (buffer-name my-bs-buffer)))))))
77 (defadvice Electric-pop-up-window (around ecb)
78 "Ensures that the electric-* commands \(e.g. `electric-buffer-list') work
79 well with ECB. If BUFFER is a \"compilation-buffer\" in the sense of
80 `ecb-compilation-buffer-p' then BUFFER will be displayed in the compile-window
81 of ECB - if there is any. If the compile-window is temporally hidden then the
82 BUFFER is displayed in an edit-window!"
83 (if (and ecb-minor-mode
84 (equal (selected-frame) ecb-frame))
85 (if (and (ecb-compilation-buffer-p (ad-get-arg 0))
86 (equal (ecb-compile-window-state) 'visible))
87 (pop-to-buffer (ad-get-arg 0))
88 (let ((ecb-compilation-buffer-names nil)
89 (ecb-compilation-major-modes nil)
90 (ecb-compilation-predicates nil))
91 (ecb-with-ecb-advice 'one-window-p 'around
95 (defadvice electric-command-history (before ecb)
96 "Ensures that the electric-* commands work well with ECB."
97 (when (and ecb-minor-mode
98 (equal (selected-frame) ecb-frame)
99 (ecb-point-in-ecb-window))
100 (ecb-select-edit-window)))
102 (defadvice electric-buffer-list (before ecb)
103 "Ensures that the electric-* commands work well with ECB."
104 (when (and ecb-minor-mode
105 (equal (selected-frame) ecb-frame)
106 (ecb-point-in-ecb-window))
107 (ecb-select-edit-window)))
109 (defadvice electric-buffer-list (after ecb)
110 "Ensures that the electric-* commands work well with ECB."
111 (if (get-buffer "*Buffer List*")
112 (bury-buffer (get-buffer "*Buffer List*"))))
114 ;; we disable the advices at load-time
115 (ecb-disable-advices ecb-compatibility-advices)
117 (silentcomp-provide 'ecb-compatibility)
119 ;;; ecb-compatibility.el ends here