annotate lisp/packages/iswitchb.el @ 203:850242ba4a81 r20-3b28

Import from CVS: tag r20-3b28
author cvs
date Mon, 13 Aug 2007 10:02:21 +0200
parents a2f645c6b9f8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1 ;;; iswitchb.el --- switch between buffers using substrings
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
2
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
3 ;; Copyright (C) 1996, 1997 Free Software Foundation, Inc.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
4
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
5 ;; Author: Stephen Eglen <stephen@cns.ed.ac.uk>
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
6 ;; Maintainer: Stephen Eglen <stephen@cns.ed.ac.uk>
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
7 ;; Keywords: extensions
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
8 ;; location: http://www.cogs.susx.ac.uk/users/stephene/emacs
203
850242ba4a81 Import from CVS: tag r20-3b28
cvs
parents: 195
diff changeset
9 ;; RCS: $Id: iswitchb.el,v 1.2 1997/10/12 01:39:45 steve Exp $
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
10
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
11 ;; This file is part of GNU Emacs.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
12
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
15 ;; the Free Software Foundation; either version 2, or (at your option)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
16 ;; any later version.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
17
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
21 ;; GNU General Public License for more details.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
22
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
26 ;; Boston, MA 02111-1307, USA.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
27
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
28 ;;; Installation:
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
29
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
30 ;; To get the functions in this package bound to keys, do
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
31 ;; (iswitchb-default-keybindings)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
32
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
33 ;;; Commentary:
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
34
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
35 ;; As you type in a substring, the list of buffers currently matching
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
36 ;; the substring are displayed as you type. The list is ordered so
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
37 ;; that the most recent buffers visited come at the start of the list.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
38 ;; The buffer at the start of the list will be the one visited when
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
39 ;; you press return. By typing more of the substring, the list is
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
40 ;; narrowed down so that gradually the buffer you want will be at the
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
41 ;; top of the list. Alternatively, you can use C-s an C-r to rotate
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
42 ;; buffer names in the list until the one you want is at the top of
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
43 ;; the list. Completion is also available so that you can see what is
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
44 ;; common to all of the matching buffers as you type.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
45
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
46 ;; This code is similar to a couple of other packages. Michael R Cook
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
47 ;; <mcook@cognex.com wrote a similar buffer switching package, but
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
48 ;; does exact matching rather than substring matching on buffer names.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
49 ;; I also modified a couple of functions from icomplete.el to provide
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
50 ;; the completion feedback in the minibuffer.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
51
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
52 ;;; Example
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
53
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
54 ;;If I have two buffers called "123456" and "123", with "123456" the
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
55 ;;most recent, when I use iswitchb, I first of all get presented with
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
56 ;;the list of all the buffers
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
57 ;;
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
58 ;; iswitch {123456,123}
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
59 ;;
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
60 ;; If I then press 2:
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
61 ;; iswitch 2[3]{123456,123}
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
62 ;;
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
63 ;; The list in {} are the matching buffers, most recent first (buffers
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
64 ;; visible in the current frame are put at the end of the list by
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
65 ;; default). At any time I can select the item at the head of the
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
66 ;; list by pressing RET. I can also bring the put the first element
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
67 ;; at the end of the list by pressing C-s, or put the last element at
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
68 ;; the head of the list by pressing C-r. The item in [] indicates
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
69 ;; what can be added to my input by pressing TAB. In this case, I
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
70 ;; will get "3" added to my input. So, press TAB:
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
71 ;; iswitch 23{123456,123}
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
72 ;;
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
73 ;; At this point, I still have two matching buffers.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
74 ;; If I want the first buffer in the list, I simply press RET. If I
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
75 ;; wanted the second in the list, I could press C-s to move it to the
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
76 ;; top of the list and then RET to select it.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
77 ;;
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
78 ;;However, If I type 4, I only have one match left:
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
79 ;; iswitch 234[123456] [Matched]
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
80 ;;
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
81 ;;Since there is only one matching buffer left, it is given in [] and we
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
82 ;;see the text [Matched] afterwards. I can now press TAB or RET to go
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
83 ;;to that buffer.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
84 ;;
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
85 ;; If however, I now type "a":
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
86 ;; iswitch 234a [No match]
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
87 ;; There are no matching buffers. If I press RET or TAB, I can be
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
88 ;; prompted to create a new buffer called "234a".
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
89 ;;
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
90 ;; Of course, where this function comes in really useful is when you
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
91 ;; can specify the buffer using only a few keystrokes. In the above
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
92 ;; example, the quickest way to get to the "123456" buffer would be
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
93 ;; just to type 4 and then RET (assuming there isnt any newer buffer
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
94 ;; with 4 in its name).
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
95
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
96 ;; To see a full list of all matching buffers in a separate buffer,
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
97 ;; hit ? or press TAB when there are no further completions to the
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
98 ;; substring.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
99
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
100 ;; The buffer at the head of the list can be killed by pressing C-k.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
101 ;; If the buffer needs saving, you will be queried before the buffer
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
102 ;; is killed.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
103
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
104 ;; If you find that the file you are after is not in a buffer, you can
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
105 ;; press C-x C-f to immediately drop into find-file.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
106
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
107 ;;
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
108 ;; See the doc string of iswitchb for full keybindings and features.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
109 ;; (describe-function 'iswitchb)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
110
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
111 ;;; Customisation
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
112
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
113 ;; See the User Variables section below for easy ways to change the
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
114 ;; functionality of the program. These are accessible using the
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
115 ;; custom package.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
116 ;; To modify the keybindings, use the hook provided. For example:
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
117 ;;(add-hook 'iswitchb-define-mode-map-hook
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
118 ;; 'iswitchb-my-keys)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
119 ;;
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
120 ;;(defun iswitchb-my-keys ()
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
121 ;; "Add my keybings for iswitchb."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
122 ;; (define-key iswitchb-mode-map " " 'iswitchb-next-match)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
123 ;; )
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
124 ;;
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
125 ;; Seeing all the matching buffers.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
126 ;;
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
127 ;; If you have many matching buffers, they may not all fit onto one
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
128 ;; line of the minibuffer. In this case, you should use rsz-mini
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
129 ;; (resize-minibuffer-mode). You can also limit iswitchb so that it
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
130 ;; only shows a certain number of lines -- see the documentation for
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
131 ;; `iswitchb-minibuffer-setup-hook'.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
132
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
133
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
134 ;; Changing the list of buffers.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
135
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
136 ;; By default, the list of current buffers is most recent first,
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
137 ;; oldest last, with the exception that the buffers visible in the
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
138 ;; current frame are put at the end of the list. A hook exists to
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
139 ;; allow other functions to order the list. For example, if you add:
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
140 ;;
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
141 ;; (add-hook 'iswitchb-make-buflist-hook 'iswitchb-summaries-to-end)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
142 ;;
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
143 ;; then all buffers matching "Summary" are moved to the end of the
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
144 ;; list. (I find this handy for keeping the INBOX Summary and so on
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
145 ;; out of the way.) It also moves buffers matching "output\*$" to the
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
146 ;; end of the list (these are created by AUC TeX when compiling.)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
147 ;; Other functions could be made available which alter the list of
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
148 ;; matching buffers (either deleting or rearranging elements.)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
149
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
150 ;; Font-Lock
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
151
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
152 ;; If you have font-lock loaded, the first matching buffer is
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
153 ;; highlighted. To switch this off, set (setq iswitchb-use-fonts nil)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
154 ;; I don't use font-lock that much, so I've hardcoded the faces. If
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
155 ;; this is too harsh, let me know. Colouring of the matching buffer
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
156 ;; name was suggested by Carsten Dominik (dominik@strw.leidenuniv.nl)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
157
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
158 ;;; Comparison with iswitch-buffer
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
159
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
160 ;; This package is a rewrite of iswitch-buffer, using the minibuffer
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
161 ;; rather than the echo area. The advantages of using the minibuffer
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
162 ;; are several:
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
163 ;; o minibuffer has more powerful editing facilities
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
164 ;; o doesnt interfere with other packages that use the echo area
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
165 ;; o *Messages* buffer doesnt get filled up with all of the messages that
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
166 ;; go to the modeline
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
167 ;; o cursor is in the minibuffer, which somehow looks right.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
168 ;; o minibuffer can be resized dynamically to show all the possible matching
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
169 ;; buffers rather than just the first line's worth (using rsz-mini).
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
170 ;;
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
171 ;; Disadvantages:
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
172 ;; o cant change the prompt to indicate status of searching (eg whether
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
173 ;; regexp searching is currently on).
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
174
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
175
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
176 ;;; TODO
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
177 ;; Could this selection also be used for other buffer selection
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
178 ;; routines, such as append-to-buffer and kill-buffer?
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
179
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
180 ;; Pressing Tab key twice (without completion) does not scroll the
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
181 ;; list of buffers.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
182
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
183 ;;; Acknowledgements
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
184
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
185 ;; Thanks to Jari Aalto <jari.aalto@poboxes.com> for help with the
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
186 ;; first version of this package, iswitch-buffer. Thanks also to many
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
187 ;; others for testing earlier versions.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
188
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
189 ;;; Code:
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
190
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
191 ;; Set up the custom library.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
192 ;; taken from http://www.dina.kvl.dk/~abraham/custom/
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
193 (eval-and-compile
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
194 (condition-case ()
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
195 (require 'custom)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
196 (error nil))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
197 (if (and (featurep 'custom) (fboundp 'custom-declare-variable))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
198 nil ;; We've got what we needed
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
199 ;; We have the old custom-library, hack around it!
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
200 (defmacro defgroup (&rest args)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
201 nil)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
202 (defmacro defcustom (var value doc &rest args)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
203 (` (defvar (, var) (, value) (, doc))))))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
204
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
205 ;;; User Variables
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
206 ;;
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
207 ;; These are some things you might want to change.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
208
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
209 (defgroup iswitchb nil
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
210 "switch between buffers using substrings."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
211 :group 'extensions
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
212 ;; These links are to be added in later versions of custom and
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
213 ;; so are currently commented out.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
214 :link '(emacs-commentary-link :tag "Commentary" "iswitchb.el")
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
215 :link '(emacs-library-link :tag "Lisp File" "iswitchb.el")
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
216 )
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
217
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
218
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
219 (defcustom iswitchb-case case-fold-search
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
220 "*Non-nil if searching of buffer names should ignore case."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
221 :type 'boolean
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
222 :group 'iswitchb)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
223
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
224 (defcustom iswitchb-buffer-ignore
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
225 '("^ ")
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
226 "*List of regexps or functions matching buffer names to ignore.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
227 For example, traditional behavior is not to list buffers whose names begin
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
228 with a space, for which the regexp is `^ '. See the source file for
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
229 example functions that filter buffernames."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
230 :type '(repeat regexp)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
231 :group 'iswitchb)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
232
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
233
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
234 ;;; Examples for setting the value of iswitchb-buffer-ignore
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
235 ;(defun -c-mode (name)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
236 ; "Ignore all c mode buffers -- example function for iswitchb."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
237 ; (save-excursion
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
238 ; (set-buffer name)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
239 ; (string-match "^C$" mode-name)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
240
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
241 ;(setq iswitchb-buffer-ignore '("^ " ignore-c-mode))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
242 ;(setq iswitchb-buffer-ignore '("^ " "\\.c$" "\\.h$"))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
243
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
244 (defcustom iswitchb-default-method 'always-frame
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
245 "*How to switch to new buffer when using `iswitchb-buffer'.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
246 Possible values:
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
247 `samewindow' Show new buffer in same window
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
248 `otherwindow' Show new buffer in another window (same frame)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
249 `display' Display buffer in another window without switching to it
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
250 `otherframe' Show new buffer in another frame
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
251 `maybe-frame' If a buffer is visible in another frame, prompt to ask if you
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
252 you want to see the buffer in the same window of the current
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
253 frame or in the other frame.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
254 `always-frame' If a buffer is visible in another frame, raise that
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
255 frame. Otherwise, visit the buffer in the same window."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
256 :type '(choice (const :tag "samewindow" samewindow)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
257 (const :tag "otherwindow" otherwindow)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
258 (const :tag "display" display)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
259 (const :tag "otherframe" otherframe)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
260 (const :tag "maybe-frame" maybe-frame)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
261 (const :tag "always-frame" always-frame))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
262 :group 'iswitchb)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
263
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
264
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
265 (defcustom iswitchb-regexp nil
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
266 "*Non-nil means that `iswitchb' will do regexp matching.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
267 Value can be toggled within `iswitchb'."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
268 :type 'boolean
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
269 :group 'iswitchb)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
270
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
271
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
272 (defcustom iswitchb-newbuffer t
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
273 "*Non-nil means create new buffer if no buffer matches substring.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
274 See also `iswitchb-prompt-newbuffer'."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
275 :type 'boolean
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
276 :group 'iswitchb)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
277
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
278
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
279 (defcustom iswitchb-prompt-newbuffer t
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
280 "*Non-nil means prompt user to confirm before creating new buffer.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
281 See also `iswitchb-newbuffer'."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
282 :type 'boolean
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
283 :group 'iswitchb)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
284
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
285
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
286 (defcustom iswitchb-define-mode-map-hook nil
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
287 "*Hook to define keys in `iswitchb-mode-map' for extra keybindings."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
288 :type 'hook
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
289 :group 'iswitchb)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
290
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
291
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
292
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
293 (defcustom iswitchb-use-fonts t
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
294 "*Non-nil means use fonts for showing first match."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
295 :type 'boolean
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
296 :group 'iswitchb)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
297
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
298
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
299 (defcustom iswitchb-make-buflist-hook nil
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
300 "*Hook to run when list of matching buffers is created."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
301 :type 'hook
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
302 :group 'iswitchb)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
303
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
304
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
305
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
306 (defvar iswitchb-method nil
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
307 "*Stores the method for viewing the selected buffer.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
308 Its value is one of `samewindow', `otherwindow', `display', `otherframe',
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
309 `maybe-frame' or `always-frame'. See `iswitchb-default-method' for
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
310 details of values.")
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
311
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
312 (defvar iswitchb-all-frames 'visible
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
313 "*Argument to pass to `walk-windows' when finding visible buffers.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
314 See documentation of `walk-windows' for useful values.")
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
315
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
316
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
317
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
318 ;; Do we need the variable iswitchb-use-mycompletion?
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
319
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
320
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
321 ;;; Internal Variables
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
322 (defvar iswitchb-minibuffer-setup-hook nil
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
323 "Iswitchb-specific customization of minibuffer setup.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
324
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
325 This hook is run during minibuffer setup iff `iswitchb' will be active.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
326 It is intended for use in customizing iswitchb for interoperation
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
327 with other packages. For instance:
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
328
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
329 \(add-hook 'iswitchb-minibuffer-setup-hook
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
330 \(function
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
331 \(lambda ()
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
332 \(make-local-variable 'resize-minibuffer-window-max-height)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
333 \(setq resize-minibuffer-window-max-height 3))))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
334
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
335 will constrain rsz-mini to a maximum minibuffer height of 3 lines when
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
336 iswitchb is running. Copied from `icomplete-minibuffer-setup-hook'.")
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
337
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
338 (defvar iswitchb-eoinput 1
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
339 "Point where minibuffer input ends and completion info begins.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
340 Copied from `icomplete-eoinput'.")
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
341 (make-variable-buffer-local 'iswitchb-eoinput)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
342
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
343
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
344 (defvar iswitchb-buflist nil
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
345 "Stores the current list of buffers that will be searched through.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
346 The list is ordered, so that the most recent buffers come first,
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
347 although by default, the buffers visible in the current frame are put
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
348 at the end of the list. Created by `iswitchb-make-buflist'.")
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
349
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
350 ;; todo -- is this necessary?
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
351
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
352 (defvar iswitchb-use-mycompletion nil
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
353 "Non-nil means use `iswitchb-buffer' completion feedback.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
354 Should only be set to t by iswitchb functions, so that it doesn't
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
355 interfere with other minibuffer usage.")
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
356
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
357 (defvar iswitchb-change-word-sub nil
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
358 "Private variable used by `iswitchb-word-matching-substring'.")
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
359
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
360
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
361 (defvar iswitchb-common-match-string nil
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
362 "Stores the string that is common to all matching buffers.")
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
363
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
364
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
365 (defvar iswitchb-rescan nil
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
366 "Non-nil means we need to regenerate the list of matching buffers.")
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
367
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
368 (defvar iswitchb-text nil
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
369 "Stores the users string as it is typed in.")
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
370
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
371 (defvar iswitchb-matches nil
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
372 "List of buffers currenly matching `iswitchb-text'.")
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
373
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
374 (defvar iswitchb-mode-map nil
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
375 "Keymap for `iswitchb-buffer'.")
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
376
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
377 (defvar iswitchb-history nil
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
378 "History of buffers selected using `iswitchb-buffer'.")
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
379
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
380 (defvar iswitchb-exit nil
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
381 "Flag to monitor how `iswitchb-buffer' exits.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
382 If equal to `takeprompt', we use the prompt as the buffer name to be
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
383 selected.")
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
384
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
385 (defvar iswitchb-buffer-ignore-orig nil
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
386 "Stores original value of `iswitchb-buffer-ignore'.")
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
387
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
388 (defvar iswitchb-xemacs (string-match "XEmacs" (emacs-version))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
389 "Non-nil if we are running XEmacs. Otherwise, assume we are running Emacs.")
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
390
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
391
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
392 ;;; FUNCTIONS
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
393
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
394
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
395 ;;; ISWITCHB KEYMAP
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
396 (defun iswitchb-define-mode-map ()
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
397 "Set up the keymap for `iswitchb-buffer'."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
398 (interactive)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
399 (let (map)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
400 ;; generated every time so that it can inheret new functions.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
401 ;;(or iswitchb-mode-map
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
402
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
403 (setq map (copy-keymap minibuffer-local-map))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
404 (define-key map "?" 'iswitchb-completion-help)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
405 (define-key map "\C-s" 'iswitchb-next-match)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
406 (define-key map "\C-r" 'iswitchb-prev-match)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
407 (define-key map "\t" 'iswitchb-complete)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
408 (define-key map "\C-j" 'iswitchb-select-buffer-text)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
409 (define-key map "\C-t" 'iswitchb-toggle-regexp)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
410 (define-key map "\C-x\C-f" 'iswitchb-find-file)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
411 ;;(define-key map "\C-a" 'iswitchb-toggle-ignore)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
412 (define-key map "\C-c" 'iswitchb-toggle-case)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
413 (define-key map "\C-k" 'iswitchb-kill-buffer)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
414 (setq iswitchb-mode-map map)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
415 (run-hooks 'iswitchb-define-mode-map-hook)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
416 ))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
417
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
418
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
419
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
420 ;;; MAIN FUNCTION
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
421 (defun iswitchb ()
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
422 "Switch to buffer matching a substring.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
423 As you type in a string, all of the buffers matching the string are
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
424 displayed. When you have found the buffer you want, it can then be
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
425 selected. As you type, most keys have their normal keybindings,
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
426 except for the following:
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
427 \\<iswitchb-mode-map>
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
428
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
429 RET Select the buffer at the front of the list of matches. If the
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
430 list is empty, possibly prompt to create new buffer.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
431
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
432 \\[iswitchb-select-buffer-text] Select the current prompt as the buffer.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
433 If no buffer is found, prompt for a new one.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
434
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
435 \\[iswitchb-next-match] Put the first element at the end of the list.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
436 \\[iswitchb-prev-match] Put the last element at the start of the list.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
437 \\[iswitchb-complete] Complete a common suffix to the current string that
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
438 matches all buffers. If there is only one match, select that buffer.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
439 If there is no common suffix, show a list of all matching buffers
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
440 in a separate window.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
441 \\[iswitchb-toggle-regexp] Toggle rexep searching.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
442 \\[iswitchb-toggle-case] Toggle case-sensitive searching of buffer names.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
443 \\[iswitchb-completion-help] Show list of matching buffers in separate window.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
444 \\[iswitchb-find-file] Exit iswitchb and drop into find-file.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
445 \\[iswitchb-kill-buffer] Kill buffer at head of buffer list."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
446 ;;\\[iswitchb-toggle-ignore] Toggle ignoring certain buffers (see \
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
447 ;;`iswitchb-buffer-ignore')
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
448
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
449 (let
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
450 (
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
451 prompt
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
452 buf-sel
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
453 iswitchb-final-text
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
454 (minibuffer-confirm-incomplete nil) ;XEmacs todo: prevent `;confirm'
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
455 (icomplete-mode nil) ;; prevent icomplete starting up
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
456 ;; can only use fonts if they have been bound.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
457 (iswitchb-use-fonts (and iswitchb-use-fonts
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
458 (boundp 'font-lock-comment-face)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
459 (boundp 'font-lock-function-name-face)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
460 )
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
461
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
462 (iswitchb-define-mode-map)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
463 (setq iswitchb-exit nil)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
464 (setq iswitchb-rescan t)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
465 (setq iswitchb-text "")
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
466 (iswitchb-set-matches)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
467 (setq prompt (format "iswitch "))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
468 (iswitchb-make-buflist)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
469 (let
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
470 ((minibuffer-local-completion-map iswitchb-mode-map))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
471 ;; prompt the user for the buffer name
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
472 (setq iswitchb-final-text (completing-read prompt
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
473 ;;nil
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
474 '(("dummy".1))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
475 ;;("2".2) ("3".3))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
476 nil nil
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
477 nil;init string
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
478 'iswitchb-history)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
479
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
480 ;;(message "chosen text %s" iswitchb-final-text)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
481 ;; Choose the buffer name: either the text typed in, or the head
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
482 ;; of the list of matches
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
483
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
484 (cond ( (eq iswitchb-exit 'findfile)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
485 (call-interactively 'find-file))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
486
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
487 (t
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
488 (if (or
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
489 (eq iswitchb-exit 'takeprompt)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
490 (null iswitchb-matches))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
491 (setq buf-sel iswitchb-final-text)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
492 ;; else take head of list
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
493 (setq buf-sel (car iswitchb-matches)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
494
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
495 ;; Or possibly choose the default buffer
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
496 (if (equal iswitchb-final-text "")
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
497 (setq buf-sel (car iswitchb-matches)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
498
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
499 ;; View the buffer
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
500 (message "go to buf %s" buf-sel)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
501 ;; Check buf-sel is non-nil.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
502 (if buf-sel
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
503 (if (get-buffer buf-sel)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
504 ;; buffer exists, so view it and then exit
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
505 (iswitchb-visit-buffer buf-sel)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
506 ;; else buffer doesnt exist
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
507 (iswitchb-possible-new-buffer buf-sel)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
508 ))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
509
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
510 ))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
511
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
512
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
513 ;;; COMPLETION CODE
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
514
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
515 (defun iswitchb-set-common-completion ()
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
516 "Find common completion of `iswitchb-text' in `iswitchb-matches'.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
517 The result is stored in `iswitchb-common-match-string'."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
518
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
519 (let* (val)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
520 (setq iswitchb-common-match-string nil)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
521 (if (and iswitchb-matches
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
522 (stringp iswitchb-text)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
523 (> (length iswitchb-text) 0))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
524 (if (setq val (iswitchb-find-common-substring
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
525 iswitchb-matches iswitchb-text))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
526 (setq iswitchb-common-match-string val)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
527 val
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
528 ))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
529
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
530
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
531 (defun iswitchb-complete ()
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
532 "Try and complete the current pattern amongst the buffer names."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
533 (interactive)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
534 (let (res)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
535 (cond ((not iswitchb-matches)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
536 (iswitchb-completion-help)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
537 )
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
538
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
539 ((eq 1 (length iswitchb-matches))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
540 ;; only one choice, so select it.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
541 (exit-minibuffer))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
542
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
543 (t
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
544 ;; else there could be some completions
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
545
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
546 (setq res (iswitchb-find-common-substring
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
547 iswitchb-matches iswitchb-text))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
548 (if (and (not (memq res '(t nil)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
549 (not (equal res iswitchb-text)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
550 ;; found something to complete, so put it in the minibuff.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
551 (progn
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
552 (setq iswitchb-rescan nil)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
553 (delete-region (point-min) (point))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
554 (insert res))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
555 ;; else nothing to complete
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
556 (iswitchb-completion-help)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
557 )
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
558 )
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
559 )))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
560
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
561
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
562
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
563 ;;; TOGGLE FUNCTIONS
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
564
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
565 (defun iswitchb-toggle-case ()
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
566 "Toggle the value of `iswitchb-case'."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
567 (interactive)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
568 (setq iswitchb-case (not iswitchb-case))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
569 ;; ask for list to be regenerated.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
570 (setq iswitchb-rescan t)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
571 )
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
572
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
573 (defun iswitchb-toggle-regexp ()
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
574 "Toggle the value of `iswitchb-regexp'."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
575 (interactive)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
576 (setq iswitchb-regexp (not iswitchb-regexp))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
577 ;; ask for list to be regenerated.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
578 (setq iswitchb-rescan t)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
579 )
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
580
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
581
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
582 (defun iswitchb-toggle-ignore ()
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
583 "Toggle ignoring buffers specified with `iswitchb-buffer-ignore'."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
584 (interactive)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
585 (if iswitchb-buffer-ignore
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
586 (progn
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
587 (setq iswitchb-buffer-ignore-orig iswitchb-buffer-ignore)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
588 (setq iswitchb-buffer-ignore nil)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
589 )
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
590 ;; else
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
591 (setq iswitchb-buffer-ignore iswitchb-buffer-ignore-orig)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
592 )
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
593 ;; ask for list to be regenerated.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
594 (setq iswitchb-rescan t)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
595 )
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
596
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
597
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
598 (defun iswitchb-select-buffer-text ()
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
599 "Select the buffer named by the prompt.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
600 If no buffer exactly matching the prompt exists, maybe create a new one."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
601 (interactive)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
602 (setq iswitchb-exit 'takeprompt)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
603 (exit-minibuffer))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
604
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
605
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
606
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
607 (defun iswitchb-find-file ()
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
608 "Drop into find-file from buffer switching."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
609 (interactive)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
610 (setq iswitchb-exit 'findfile)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
611 (exit-minibuffer))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
612
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
613 (defun iswitchb-next-match ()
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
614 "Put first element of `iswitchb-matches' at the end of the list."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
615 (interactive)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
616 (let ((next (cadr iswitchb-matches)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
617 (setq iswitchb-buflist (iswitchb-chop iswitchb-buflist next))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
618 (setq iswitchb-rescan t)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
619 ))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
620
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
621 (defun iswitchb-prev-match ()
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
622 "Put last element of `iswitchb-matches' at the front of the list."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
623 (interactive)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
624 (let ((prev (car (last iswitchb-matches))))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
625 (setq iswitchb-buflist (iswitchb-chop iswitchb-buflist prev))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
626 (setq iswitchb-rescan t)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
627 ))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
628
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
629
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
630
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
631
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
632 (defun iswitchb-chop (list elem)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
633 "Remove all elements before ELEM and put them at the end of LIST."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
634 (let ((ret nil)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
635 (next nil)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
636 (sofar nil))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
637 (while (not ret)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
638 (setq next (car list))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
639 (if (equal next elem)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
640 (setq ret (append list (nreverse sofar)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
641 ;; else
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
642 (progn
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
643 (setq list (cdr list))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
644 (setq sofar (cons next sofar)))))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
645 ret))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
646
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
647
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
648
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
649
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
650 ;;; CREATE LIST OF ALL CURRENT BUFFERS
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
651
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
652
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
653 (defun iswitchb-make-buflist ()
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
654 "Set `iswitchb-buflist' to the current list of buffers.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
655 Currently visible buffers are put at the end of the list.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
656 The hook `iswitchb-make-buflist-hook' is run after the list has been
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
657 created to allow the user to further modify the order of the buffer names
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
658 in this list."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
659 (setq iswitchb-buflist
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
660 (let* ((iswitchb-current-buffers (iswitchb-get-buffers-in-frames))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
661 (buflist
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
662 (delq nil
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
663 (mapcar
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
664 (lambda (x)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
665 (let ((b-name (buffer-name x)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
666 (if (not
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
667 (or
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
668 (iswitchb-ignore-buffername-p b-name)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
669 (memq b-name iswitchb-current-buffers)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
670 b-name)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
671 (buffer-list)))))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
672 (nconc buflist iswitchb-current-buffers)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
673 (run-hooks 'iswitchb-make-buflist-hook)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
674 buflist)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
675
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
676 (defun iswitchb-to-end (lst)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
677 "Move the elements from LST to the end of BUFLIST."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
678 (mapcar
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
679 (lambda (elem)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
680 (setq buflist (delq elem buflist)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
681 lst)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
682 (nconc buflist lst))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
683
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
684
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
685
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
686 (defun iswitchb-get-buffers-in-frames (&optional current)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
687 "Return the list of buffers that are visible in the current frame.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
688 If optional argument `current' is given, restrict searching to the
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
689 current frame, rather than all frames, regardless of value of
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
690 `iswitchb-all-frames'."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
691 (let ((iswitchb-bufs-in-frame nil))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
692 (walk-windows 'iswitchb-get-bufname nil
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
693 (if current
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
694 nil
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
695 iswitchb-all-frames))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
696 iswitchb-bufs-in-frame))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
697
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
698
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
699 (defun iswitchb-get-bufname (win)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
700 "Used by `iswitchb-get-buffers-in-frames' to walk through all windows."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
701 (let ((buf (buffer-name (window-buffer win))))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
702 (if (not (member buf iswitchb-bufs-in-frame))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
703 ;; Only add buf if it is not already in list.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
704 ;; This prevents same buf in two different windows being
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
705 ;; put into the list twice.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
706 (setq iswitchb-bufs-in-frame
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
707 (cons buf iswitchb-bufs-in-frame)))))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
708
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
709
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
710 ;;; FIND MATCHING BUFFERS
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
711
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
712
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
713 (defun iswitchb-set-matches ()
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
714 "Set `iswitchb-matches' to the list of buffers matching prompt."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
715 (if iswitchb-rescan
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
716 (setq iswitchb-matches
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
717 (let* ((buflist iswitchb-buflist)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
718 )
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
719 (iswitchb-get-matched-buffers iswitchb-text iswitchb-regexp
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
720 buflist)))))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
721
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
722 (defun iswitchb-get-matched-buffers (regexp
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
723 &optional string-format buffer-list)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
724 "Return buffers matching REGEXP.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
725 If STRING-FORMAT is non-nil, consider REGEXP as string.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
726 BUFFER-LIST can be list of buffers or list of strings."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
727 (let* ((case-fold-search iswitchb-case)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
728 ;; need reverse since we are building up list backwards
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
729 (list (reverse buffer-list))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
730 (do-string (stringp (car list)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
731 name
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
732 ret
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
733 )
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
734 (mapcar
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
735 (lambda (x)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
736
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
737 (if do-string
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
738 (setq name x) ;We already have the name
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
739 (setq name (buffer-name x)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
740
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
741 (cond
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
742 ((and (or (and string-format (string-match regexp name))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
743 (and (null string-format)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
744 (string-match (regexp-quote regexp) name)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
745
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
746 ;; todo (not (iswitchb-ignore-buffername-p name))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
747 )
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
748 (setq ret (cons name ret))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
749 )))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
750 list)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
751 ret
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
752 ))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
753
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
754
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
755
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
756
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
757 (defun iswitchb-ignore-buffername-p (bufname)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
758 "Return t if the buffer BUFNAME should be ignored."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
759 (let ((data (match-data))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
760 (re-list iswitchb-buffer-ignore)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
761 ignorep
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
762 nextstr
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
763 )
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
764 (while re-list
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
765 (setq nextstr (car re-list))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
766 (cond
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
767 ((stringp nextstr)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
768 (if (string-match nextstr bufname)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
769 (progn
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
770 (setq ignorep t)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
771 (setq re-list nil))))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
772 ((fboundp nextstr)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
773 (if (funcall nextstr bufname)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
774 (progn
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
775 (setq ignorep t)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
776 (setq re-list nil))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
777 ))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
778 )
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
779 (setq re-list (cdr re-list)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
780 (store-match-data data)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
781
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
782 ;; return the result
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
783 ignorep)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
784 )
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
785
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
786
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
787
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
788 (defun iswitchb-word-matching-substring (word)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
789 "Return part of WORD before 1st match to `iswitchb-change-word-sub'.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
790 If `iswitchb-change-word-sub' cannot be found in WORD, return nil."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
791 (let ((case-fold-search iswitchb-case))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
792 (let ((m (string-match iswitchb-change-word-sub word)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
793 (if m
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
794 (substring word m)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
795 ;; else no match
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
796 nil))))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
797
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
798
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
799
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
800
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
801
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
802
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
803 (defun iswitchb-find-common-substring (lis subs)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
804 "Return common string following SUBS in each element of LIS."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
805 (let (res
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
806 alist
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
807 iswitchb-change-word-sub
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
808 )
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
809 (setq iswitchb-change-word-sub
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
810 (if iswitchb-regexp
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
811 subs
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
812 (regexp-quote subs)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
813 (setq res (mapcar 'iswitchb-word-matching-substring lis))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
814 (setq res (delq nil res)) ;; remove any nil elements (shouldnt happen)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
815 (setq alist (mapcar 'iswitchb-makealist res)) ;; could use an OBARRAY
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
816
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
817 ;; try-completion returns t if there is an exact match.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
818 (let ((completion-ignore-case iswitchb-case))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
819
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
820 (try-completion subs alist)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
821 )))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
822
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
823
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
824 (defun iswitchb-makealist (res)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
825 "Return dotted pair (RES . 1)."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
826 (cons res 1))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
827
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
828 ;; from Wayne Mesard <wmesard@esd.sgi.com>
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
829 (defun iswitchb-rotate-list (lis)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
830 "Destructively removes the last element from LIS.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
831 Return the modified list with the last element prepended to it."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
832 (if (<= (length lis) 1)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
833 lis
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
834 (let ((las lis)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
835 (prev lis))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
836 (while (consp (cdr las))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
837 (setq prev las
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
838 las (cdr las)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
839 (setcdr prev nil)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
840 (cons (car las) lis))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
841 ))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
842
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
843
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
844 (defun iswitchb-completion-help ()
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
845 "Show possible completions in a *Buffer Completions* buffer."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
846 ;; we could allow this buffer to be used to select match, but I think
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
847 ;; choose-completion-string will need redefining, so it just inserts
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
848 ;; choice with out any previous input.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
849 (interactive)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
850 (setq iswitchb-rescan nil)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
851 (let ((completion-setup-hook nil) ;disable fancy highlight/selection.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
852 )
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
853 (with-output-to-temp-buffer "*Buffer Completions*"
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
854 (if iswitchb-xemacs
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
855
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
856 ;; XEmacs extents are put on by default, doesn't seem to be
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
857 ;; any way of switching them off.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
858 (display-completion-list (if iswitchb-matches
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
859 iswitchb-matches
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
860 iswitchb-buflist)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
861 :help-string "iswitchb "
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
862 :activate-callback
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
863 '(lambda (x y z)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
864 (message "doesnt work yet, sorry!")))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
865 ;; else running Emacs
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
866 (display-completion-list (if iswitchb-matches
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
867 iswitchb-matches
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
868 iswitchb-buflist))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
869 ))))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
870
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
871
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
872 ;;; KILL CURRENT BUFFER
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
873
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
874 (defun iswitchb-kill-buffer ()
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
875 "Kill the buffer at the head of `iswtichb-matches'."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
876 (interactive)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
877 (let ( (enable-recursive-minibuffers t)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
878 buf)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
879
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
880 (setq buf (car iswitchb-matches))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
881 ;; check to see if buf is non-nil.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
882 (if buf
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
883 (progn
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
884 (kill-buffer buf)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
885
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
886 ;; Check if buffer exists. XEmacs gnuserv.el makes alias
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
887 ;; for kill-buffer which does not return t if buffer is
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
888 ;; killed, so we can't rely on kill-buffer return value.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
889 (if (get-buffer buf)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
890 ;; buffer couldn't be killed.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
891 (setq iswitchb-rescan t)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
892 ;; else buffer was killed so remove name from list.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
893 (setq iswitchb-buflist (delq buf iswitchb-buflist)))))))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
894
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
895
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
896 ;;; VISIT CHOSEN BUFFER
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
897 (defun iswitchb-visit-buffer (buffer)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
898 "Visit buffer named BUFFER according to `iswitchb-method'."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
899 (let* (win newframe)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
900 (cond
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
901 ((eq iswitchb-method 'samewindow)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
902 (switch-to-buffer buffer))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
903
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
904 ((memq iswitchb-method '(always-frame maybe-frame))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
905 (cond
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
906 ((and (setq win (iswitchb-window-buffer-p buffer))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
907 (or (eq iswitchb-method 'always-frame)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
908 (y-or-n-p "Jump to frame? ")))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
909 (setq newframe (window-frame win))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
910 (raise-frame newframe)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
911 (select-frame newframe)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
912 (select-window win)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
913 (if (not iswitchb-xemacs)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
914 ;; reposition mouse to make frame active. not needed in XEmacs
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
915 ;; This line came from the other-frame defun in Emacs.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
916 (set-mouse-position (selected-frame) (1- (frame-width)) 0))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
917 )
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
918 (t
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
919 ;; No buffer in other frames...
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
920 (switch-to-buffer buffer)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
921 )))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
922
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
923
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
924
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
925 ((eq iswitchb-method 'otherwindow)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
926 (switch-to-buffer-other-window buffer))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
927
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
928 ((eq iswitchb-method 'display)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
929 (display-buffer buffer))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
930
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
931 ((eq iswitchb-method 'otherframe)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
932 (progn
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
933 (switch-to-buffer-other-frame buffer)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
934 (if (not iswitchb-xemacs)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
935 (set-mouse-position (selected-frame) (1- (frame-width)) 0))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
936 )
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
937 ) )))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
938
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
939 (defun iswitchb-possible-new-buffer (buf)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
940 "Possibly create and visit a new buffer called BUF."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
941
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
942 (let ((newbufcreated))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
943 (if (and iswitchb-newbuffer
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
944 (or
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
945 (not iswitchb-prompt-newbuffer)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
946
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
947 (and iswitchb-prompt-newbuffer
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
948 (y-or-n-p
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
949 (format
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
950 "No buffer matching `%s', create one? "
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
951 buf)))))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
952 ;; then create a new buffer
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
953 (progn
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
954 (setq newbufcreated (get-buffer-create buf))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
955 (if (fboundp 'set-buffer-major-mode)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
956 (set-buffer-major-mode newbufcreated))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
957 (iswitchb-visit-buffer newbufcreated))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
958
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
959 ;; else wont create new buffer
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
960 (message (format "no buffer matching `%s'" buf))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
961 )))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
962
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
963 (defun iswitchb-window-buffer-p (buffer)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
964 "Return window pointer if BUFFER is visible in another frame.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
965 If BUFFER is visible in the current frame, return nil."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
966 (interactive)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
967 (let ((blist (iswitchb-get-buffers-in-frames 'current)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
968 ;;If the buffer is visible in current frame, return nil
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
969 (if (memq buffer blist)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
970 nil
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
971 ;; maybe in other frame...
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
972 (get-buffer-window buffer 'visible)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
973 )))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
974
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
975 ;;;###autoload
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
976 (defun iswitchb-default-keybindings ()
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
977 "Set up default keybindings for `iswitchb-buffer'.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
978 Call this function to override the normal bindings."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
979 (interactive)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
980 (global-set-key (read-kbd-macro "C-x b") 'iswitchb-buffer)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
981 (global-set-key (read-kbd-macro "C-x 4 b") 'iswitchb-buffer-other-window)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
982 (global-set-key (read-kbd-macro "C-x 4 C-o") 'iswitchb-display-buffer)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
983 (global-set-key (read-kbd-macro "C-x 5 b") 'iswitchb-buffer-other-frame))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
984
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
985
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
986
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
987 ;;;###autoload
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
988 (defun iswitchb-buffer ()
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
989 "Switch to another buffer.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
990
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
991 The buffer name is selected interactively by typing a substring. The
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
992 buffer is displayed according to `iswitchb-default-method' -- the
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
993 default is to show it in the same window, unless it is already visible
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
994 in another frame.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
995 For details of keybindings, do `\\[describe-function] iswitchb'."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
996 (interactive)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
997 (setq iswitchb-method iswitchb-default-method)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
998 (iswitchb-entry))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
999
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1000
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1001 ;;;###autoload
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1002 (defun iswitchb-buffer-other-window ()
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1003 "Switch to another buffer and show it in another window.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1004 The buffer name is selected interactively by typing a substring.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1005 For details of keybindings, do `\\[describe-function] iswitchb'."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1006 (interactive)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1007 (setq iswitchb-method 'otherwindow)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1008 (iswitchb-entry))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1009
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1010
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1011
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1012 ;;;###autoload
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1013 (defun iswitchb-display-buffer ()
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1014 "Display a buffer in another window but don't select it.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1015 The buffer name is selected interactively by typing a substring.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1016 For details of keybindings, do `\\[describe-function] iswitchb'."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1017 (interactive)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1018 (setq iswitchb-method 'display)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1019 (iswitchb-entry))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1020
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1021
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1022
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1023 ;;;###autoload
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1024 (defun iswitchb-buffer-other-frame ()
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1025 "Switch to another buffer and show it in another frame.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1026 The buffer name is selected interactively by typing a substring.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1027 For details of keybindings, do `\\[describe-function] iswitchb'."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1028 (interactive)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1029 (setq iswitchb-method 'otherframe)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1030 (iswitchb-entry))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1031
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1032
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1033
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1034 (defun iswitchb-entry ()
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1035 "Simply fall into `iswitchb' -- the main function."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1036 (iswitchb))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1037
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1038
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1039
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1040
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1041
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1042 ;;; XEmacs hack for showing default buffer
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1043
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1044 ;; The first time we enter the minibuffer, Emacs puts up the default
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1045 ;; buffer to switch to, but XEmacs doesnt -- presumably there is a
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1046 ;; subtle difference in the two versions of post-command-hook. The
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1047 ;; default is shown for both whenever we delete all of our text
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1048 ;; though, indicating its just a problem the first time we enter the
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1049 ;; function. To solve this, we use another entry hook for emacs to
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1050 ;; show the default the first time we enter the minibuffer.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1051
203
850242ba4a81 Import from CVS: tag r20-3b28
cvs
parents: 195
diff changeset
1052 (defun iswitchb-init-XEmacs-trick ()
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1053 "Display default buffer when first entering minibuffer.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1054 This is a hack for XEmacs, and should really be handled by `iswitchb-exhibit'."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1055 (if (iswitchb-entryfn-p)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1056 (progn
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1057 (iswitchb-exhibit)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1058 (goto-char (point-min)))))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1059
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1060
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1061 ;; add this hook for XEmacs only.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1062 (if iswitchb-xemacs
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1063 (add-hook 'iswitchb-minibuffer-setup-hook
203
850242ba4a81 Import from CVS: tag r20-3b28
cvs
parents: 195
diff changeset
1064 'iswitchb-init-XEmacs-trick))
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1065
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1066
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1067 ;;; XEmacs / backspace key
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1068 ;; For some reason, if the backspace key is pressed in xemacs, the
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1069 ;; line gets confused, so I've added a simple key definition to make
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1070 ;; backspace act like the normal delete key.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1071
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1072 (defun iswitchb-xemacs-backspacekey ()
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1073 "Bind backspace to `backward-delete-char'."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1074 (define-key iswitchb-mode-map '[backspace] 'backward-delete-char)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1075 (define-key iswitchb-mode-map '[(meta backspace)] 'backward-kill-word)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1076 )
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1077
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1078
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1079 (if iswitchb-xemacs
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1080 (add-hook 'iswitchb-define-mode-map-hook
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1081 'iswitchb-xemacs-backspacekey))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1082
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1083
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1084
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1085 ;;; ICOMPLETE TYPE CODE
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1086
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1087 (defun iswitchb-exhibit ()
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1088 "Find matching buffers and display a list in the minibuffer.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1089 Copied from `icomplete-exhibit' with two changes:
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1090 1. It prints a default buffer name when there is no text yet entered.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1091 2. It calls my completion routine rather than the standard completion."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1092
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1093 (if iswitchb-use-mycompletion
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1094 (let ((contents (buffer-substring (point-min)(point-max)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1095 (buffer-undo-list t))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1096 (save-excursion
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1097 (goto-char (point-max))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1098 ; Register the end of input, so we
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1099 ; know where the extra stuff
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1100 ; (match-status info) begins:
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1101 (if (not (boundp 'iswitchb-eoinput))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1102 ;; In case it got wiped out by major mode business:
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1103 (make-local-variable 'iswitchb-eoinput))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1104 (setq iswitchb-eoinput (point))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1105 ;; Update the list of matches
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1106 (setq iswitchb-text contents)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1107 (iswitchb-set-matches)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1108 (setq iswitchb-rescan t)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1109 (iswitchb-set-common-completion)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1110
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1111 ;; Insert the match-status information:
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1112 (insert-string
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1113 (iswitchb-completions
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1114 contents
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1115 minibuffer-completion-table
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1116 minibuffer-completion-predicate
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1117 (not minibuffer-completion-confirm)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1118 ))))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1119
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1120
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1121
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1122 (defun iswitchb-completions
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1123 (name candidates predicate require-match)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1124 "Return the string that is displayed after the user's text.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1125 Modified from `icomplete-completions'."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1126
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1127 (let ((comps iswitchb-matches)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1128 ; "-determined" - only one candidate
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1129 (open-bracket-determined (if require-match "(" "["))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1130 (close-bracket-determined (if require-match ")" "]"))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1131 ;"-prospects" - more than one candidate
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1132 (open-bracket-prospects "{")
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1133 (close-bracket-prospects "}")
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1134 first
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1135 )
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1136
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1137 (if (and iswitchb-use-fonts comps)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1138 (progn
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1139 (setq first (car comps))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1140 (setq first (format "%s" first))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1141 (put-text-property 0 (length first) 'face
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1142 (if (eq (length comps) 1)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1143 'font-lock-comment-face
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1144 'font-lock-function-name-face)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1145 first)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1146 (setq comps (cons first (cdr comps)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1147 ))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1148
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1149 (cond ((null comps) (format " %sNo match%s"
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1150 open-bracket-determined
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1151 close-bracket-determined))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1152
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1153 ((null (cdr comps)) ;one match
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1154 (concat (if (and (> (length (car comps))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1155 (length name)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1156 (concat open-bracket-determined
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1157 ;; when there is one match, show the
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1158 ;; matching buffer name in full
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1159 (car comps)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1160 close-bracket-determined)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1161 "")
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1162 (if (not iswitchb-use-fonts) " [Matched]")
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1163 ))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1164 (t ;multiple matches
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1165 (let* (
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1166 ;;(most (try-completion name candidates predicate))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1167 (most nil)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1168 (most-len (length most))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1169 most-is-exact
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1170 first
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1171 (alternatives
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1172 (apply
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1173 (function concat)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1174 (cdr (apply
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1175 (function nconc)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1176 (mapcar '(lambda (com)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1177 (if (= (length com) most-len)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1178 ;; Most is one exact match,
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1179 ;; note that and leave out
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1180 ;; for later indication:
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1181 (progn
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1182 (setq most-is-exact t)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1183 ())
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1184 (list ","
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1185 (substring com
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1186 most-len))))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1187 comps))))))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1188
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1189 (concat
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1190
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1191 ;; put in common completion item -- what you get by
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1192 ;; pressing tab
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1193 (if (> (length iswitchb-common-match-string) (length name))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1194 (concat open-bracket-determined
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1195 (substring iswitchb-common-match-string
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1196 (length name))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1197 close-bracket-determined)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1198 )
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1199 ;; end of partial matches...
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1200
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1201 ;; think this bit can be ignored.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1202 (and (> most-len (length name))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1203 (concat open-bracket-determined
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1204 (substring most (length name))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1205 close-bracket-determined))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1206
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1207 ;; list all alternatives
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1208 open-bracket-prospects
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1209 (if most-is-exact
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1210 (concat "," alternatives)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1211 alternatives)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1212 close-bracket-prospects)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1213 )))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1214
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1215 (defun iswitchb-minibuffer-setup ()
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1216 "Set up minibuffer for `iswitchb-buffer'.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1217 Copied from `icomplete-minibuffer-setup-hook'."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1218 (if (iswitchb-entryfn-p)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1219 (progn
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1220
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1221 (make-local-variable 'iswitchb-use-mycompletion)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1222 (setq iswitchb-use-mycompletion t)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1223 (make-local-hook 'pre-command-hook)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1224 (add-hook 'pre-command-hook
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1225 'iswitchb-pre-command
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1226 nil t)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1227 (make-local-hook 'post-command-hook)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1228 (add-hook 'post-command-hook
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1229 'iswitchb-post-command
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1230 nil t)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1231
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1232 (run-hooks 'iswitchb-minibuffer-setup-hook)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1233 )
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1234 ))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1235
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1236
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1237 (defun iswitchb-pre-command ()
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1238 "Run before command in `iswitchb-buffer'."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1239 (iswitchb-tidy))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1240
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1241
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1242 (defun iswitchb-post-command ()
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1243 "Run after command in `iswitchb-buffer'."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1244 (iswitchb-exhibit)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1245 )
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1246
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1247
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1248
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1249 (defun iswitchb-tidy ()
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1250 "Remove completions display, if any, prior to new user input.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1251 Copied from `icomplete-tidy'."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1252
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1253 (if (and (boundp 'iswitchb-eoinput)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1254 iswitchb-eoinput)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1255
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1256 (if (> iswitchb-eoinput (point-max))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1257 ;; Oops, got rug pulled out from under us - reinit:
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1258 (setq iswitchb-eoinput (point-max))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1259 (let ((buffer-undo-list buffer-undo-list )) ; prevent entry
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1260 (delete-region iswitchb-eoinput (point-max))))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1261
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1262 ;; Reestablish the local variable 'cause minibuffer-setup is weird:
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1263 (make-local-variable 'iswitchb-eoinput)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1264 (setq iswitchb-eoinput 1)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1265
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1266
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1267 (defun iswitchb-entryfn-p ()
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1268 "Return non-nil if `this-command' shows we are using `iswitchb-buffer'."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1269 (and (symbolp this-command) ; ignore lambda functions
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1270 (memq this-command
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1271 '(iswitchb-buffer
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1272 iswitchb-buffer-other-frame
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1273 iswitchb-display-buffer
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1274 iswitchb-buffer-other-window))))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1275
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1276
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1277
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1278
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1279 (defun iswitchb-summaries-to-end ()
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1280 "Move the summaries to the end of the list.
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1281 This is an example function which can be hooked on to
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1282 `iswitchb-make-buflist-hook'. Any buffer matching the regexps
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1283 `Summary' or `output\*$'are put to the end of the list."
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1284 (let ((summaries (delq nil (mapcar
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1285 (lambda (x)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1286 (if (or
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1287 (string-match "Summary" x)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1288 (string-match "output\\*$" x))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1289 x))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1290 buflist)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1291 )))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1292
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1293 (iswitchb-to-end summaries)))
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1294
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1295
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1296
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1297 ;;; HOOKS
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1298 (add-hook 'minibuffer-setup-hook 'iswitchb-minibuffer-setup)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1299
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1300 (provide 'iswitchb)
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1301
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents:
diff changeset
1302 ;;; iswitchb.el ends here