1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
;;; ecb-cycle.el --- cycle buffers through ecb windows.
;; Copyright (C) 2000 - 2005 Jesper Nordenberg,
;; Klaus Berndl,
;; Kevin A. Burton,
;; Free Software Foundation, Inc.
;; Author: Klaus Berndl <klaus.berndl@sdm.de>
;; Kevin A. Burton <burton@openprivacy.org>
;; Maintainer: Klaus Berndl <klaus.berndl@sdm.de>
;; Keywords: browser, code, programming, tools
;; Created: 2002
;; 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$
;;; Commentary:
;; NOTE: If you enjoy this software, please consider a donation to the EFF
;; (http://www.eff.org)
;;; History:
;; For the ChangeLog of this file see the CVS-repository. For a complete
;; history of the ECB-package see the file NEWS.
;;; TODO:
;;
;; - What is the pattern we should use for cycling through other windows?
;;
;; - ecb-cycle-through-X-buffers (select the next X buffer)
;; - ecb-cycle-switch-to-X-buffer (set the X buffer using completion)
;;
;; - How do we setup the menubar?
;;
;; - ECB
;; Cycle
;; - Forward Compilation Buffer
;; - Set Compilation Buffer
;;
;; - What do we use for key bindings?
;;
;; - We need an easier way to setup completion and a better way to get the
;; index.
;;
;; - If possible, try to put fit the buffer so that the end of buffer is at the
;; end of the window... if necessary.
;;; Code:
(eval-when-compile
(require 'silentcomp))
(require 'ecb-compilation)
(require 'ecb-layout)
(defgroup ecb-cycle nil
"Setting for cycling through misc ECB buffers."
:group 'ecb
:prefix "ecb-cycle-")
(defun ecb-cycle-through-compilation-buffers(&optional choose-buffer)
"Cycle through all compilation buffers currently open.
The choosen compilation buffer is displayed within the compilation window
`ecb-compile-window' \(if this window doesn't exist then an error is
displayed). If the currently opened buffer within the compilation window is
not a compilation buffer, we jump to the first compilation buffer. If not we
try to loop through all compilation buffers. If we hit the end we go back to
the beginning.
If CHOOSE-BUFFER is not nil then the user will be prompted for the
compilation-buffer to switch to.
Afterwards always the compile-window of ECB is selected."
(interactive "P")
(if (not (numberp ecb-compile-window-height))
(ecb-error "This command needs a persistent compile window!")
(if choose-buffer
(switch-to-buffer (completing-read "ECB compilation buffer: "
(ecb-compilation-get-buffers)))
(let* ((compilation-buffers (ecb-compilation-get-buffers))
;; This works even if ecb-compile-window is nil or not alive
;; (means temporally hidden) --> then current-buffer is the
;; buffer of the currently selected window!
(current-buffer (or (and (ecb-compile-window-live-p)
(window-buffer ecb-compile-window))
(current-buffer)))
(current-buffer-name (buffer-name current-buffer))
(current nil)
(index nil))
(when (null compilation-buffers)
(ecb-error "No compilation buffers available."))
(if (not (ecb-compilation-buffer-p current-buffer))
;;if the current buffer is not a compilation buffer, goto the first
;;compilation buffer.
(ecb-cycle-set-compilation-buffer 0 compilation-buffers)
;;else... we need to determine what buffer to display.
(setq current (assoc current-buffer-name compilation-buffers))
(setq index (cdr current))
(if (= (1+ index) (length compilation-buffers))
;;go back to the first buffer.
(ecb-cycle-set-compilation-buffer 0 compilation-buffers)
(ecb-cycle-set-compilation-buffer (1+ index)
compilation-buffers)))))))
(defun ecb-cycle-set-compilation-buffer(index compilation-buffers)
"Set the buffer in the compilation window."
(let ((buffer-name (car (nth index compilation-buffers))))
(switch-to-buffer buffer-name)))
(silentcomp-provide 'ecb-cycle)
;;; ecb-cycle.el ends here
|