Mercurial > emacs
annotate lisp/isearchb.el @ 83578:d7ab14bae858
(Fdelete_frame): Only get kboard when MULTI_KBOARD defined.
(make_terminal_frame) [WINDOWSNT]: Initialize terminal.
author | Jason Rumney <jasonr@gnu.org> |
---|---|
date | Tue, 15 May 2007 23:05:27 +0000 |
parents | 11d72543a2ba |
children | 9355f9b7bbff |
rev | line source |
---|---|
55433
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
1 ;;; isearchb --- a marriage between iswitchb and isearch |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
2 |
75352
7be7c48035d9
Copyright notice change.
Richard M. Stallman <rms@gnu.org>
parents:
74624
diff
changeset
|
3 ;; Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc. |
55433
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
4 |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
5 ;; Author: John Wiegley <johnw@gnu.org> |
74624 | 6 ;; Maintainer: FSF |
55433
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
7 ;; Created: 16 Apr 2004 |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
8 ;; Version: 1.5 |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
9 ;; Keywords: lisp |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
10 ;; X-URL: http://www.newartisans.com/johnw/emacs.html |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
11 |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
12 ;; This file is part of GNU Emacs. |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
13 |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
14 ;; GNU Emacs is free software; you can redistribute it and/or modify |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
15 ;; it under the terms of the GNU General Public License as published by |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
16 ;; the Free Software Foundation; either version 2, or (at your option) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
17 ;; any later version. |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
18 |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
19 ;; GNU Emacs is distributed in the hope that it will be useful, |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
22 ;; GNU General Public License for more details. |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
23 |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
24 ;; You should have received a copy of the GNU General Public License |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
64091 | 26 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
27 ;; Boston, MA 02110-1301, USA. | |
55433
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
28 |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
29 ;;; Commentary: |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
30 |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
31 ;; This module allows you to switch to buffers even faster than with |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
32 ;; iswitchb! It is not intended to replace it, however, as it works |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
33 ;; well only with buffers whose names don't typically overlap. You'll |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
34 ;; have to try it first, and see how your mileage varies. |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
35 ;; |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
36 ;; The first way to use isearchb is by holding down a modifier key, in |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
37 ;; which case every letter you type while holding it searches for any |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
38 ;; buffer matching what you're typing (using the same ordering scheme |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
39 ;; employed by iswitchb). To use it this way, add to your .emacs: |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
40 ;; |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
41 ;; (isearchb-set-keybindings 'super) ; s-x s-y s-z now finds "xyz" |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
42 ;; |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
43 ;; The other way is by using a command that puts you into "search" |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
44 ;; mode, just like with isearch. I use C-z for this. The binding in |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
45 ;; my .emacs looks like: |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
46 ;; |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
47 ;; (define-key global-map [(control ?z)] 'isearchb-activate) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
48 ;; |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
49 ;; Now, after pressing C-z (for example), each self-inserting |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
50 ;; character thereafter will search for a buffer containing those |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
51 ;; characters. For instance, typing "C-z xyz" will switch to the |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
52 ;; first buffer containing "xyz". Once you press a non-self-inserting |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
53 ;; character (such as any control key sequence), the search will end. |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
54 ;; |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
55 ;; C-z after C-z toggles between the previously selected buffer and |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
56 ;; the current one. |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
57 ;; |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
58 ;; C-g aborts the search and returns you to your original buffer. |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
59 ;; |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
60 ;; TAB, after typing in a few characters (after C-z), will jump into |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
61 ;; iswitchb, using the prefix you've typed so far. This is handy when |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
62 ;; you realize that isearchb is not powerful enough to find the buffer |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
63 ;; you're looking for. |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
64 ;; |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
65 ;; C-s and C-r move forward and backward in the buffer list. If |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
66 ;; `isearchb-show-completions' is non-nil (the default), the list of |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
67 ;; possible completions is shown in the minibuffer. |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
68 ;; |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
69 ;; If `isearchb-idle-timeout' is set to a number, isearchb will quit |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
70 ;; after that many seconds of idle time. I recommend trying it set to |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
71 ;; one or two seconds. Then, if you switch to a buffer and wait for |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
72 ;; that amount of time, you can start typing without manually exiting |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
73 ;; isearchb. |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
74 |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
75 ;; TODO: |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
76 ;; C-z C-z is broken |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
77 ;; killing iswitchb.el and then trying to switch back is broken |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
78 ;; make sure TAB isn't broken |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
79 |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
80 (require 'iswitchb) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
81 |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
82 (defgroup isearchb nil |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
83 "Switch between buffers using a mechanism like isearch." |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
84 :group 'iswitchb) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
85 |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
86 (defcustom isearchb-idle-timeout nil |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
87 "*Number of idle seconds before isearchb turns itself off. |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
88 If nil, don't use a timeout." |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
89 :type '(choice (integer :tag "Seconds") |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
90 (const :tag "Disable" nil)) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
91 :group 'isearchb) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
92 |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
93 (defcustom isearchb-show-completions t |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
94 "*If non-nil, show possible completions in the minibuffer." |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
95 :type 'boolean |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
96 :group 'isearchb) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
97 |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
98 (defvar isearchb-start-buffer nil) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
99 (defvar isearchb-last-buffer nil) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
100 (defvar isearchb-idle-timer nil) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
101 |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
102 (defun isearchb-stop (&optional return-to-buffer ignore-command) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
103 "Called by isearchb to terminate a search in progress." |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
104 (remove-hook 'pre-command-hook 'isearchb-follow-char) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
105 (if return-to-buffer |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
106 (switch-to-buffer isearchb-start-buffer) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
107 (setq isearchb-last-buffer isearchb-start-buffer)) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
108 (when isearchb-idle-timer |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
109 (cancel-timer isearchb-idle-timer) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
110 (setq isearchb-idle-timer nil)) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
111 (if ignore-command |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
112 (setq this-command 'ignore |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
113 last-command 'ignore)) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
114 (message nil)) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
115 |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
116 (defun isearchb-iswitchb () |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
117 "isearchb's custom version of the `iswitchb' command. |
75510
2efde0c63664
(isearchb-iswitchb): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
75352
diff
changeset
|
118 Its purpose is to pass different call arguments to |
55433
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
119 `iswitchb-read-buffer'." |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
120 (interactive) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
121 (let* ((prompt "iswitch ") |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
122 (iswitchb-method 'samewindow) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
123 (buf (iswitchb-read-buffer prompt nil nil iswitchb-text t))) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
124 (if (eq iswitchb-exit 'findfile) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
125 (call-interactively 'find-file) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
126 (when buf |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
127 (if (get-buffer buf) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
128 ;; buffer exists, so view it and then exit |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
129 (iswitchb-visit-buffer buf) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
130 ;; else buffer doesn't exist |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
131 (iswitchb-possible-new-buffer buf)))))) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
132 |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
133 (defun isearchb () |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
134 "Switch to buffer matching a substring, based on chars typed." |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
135 (interactive) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
136 (unless (eq last-command 'isearchb) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
137 (setq iswitchb-text nil)) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
138 (unless iswitchb-text |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
139 (setq iswitchb-text "") |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
140 (iswitchb-make-buflist nil)) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
141 (if last-command-char |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
142 (setq iswitchb-rescan t |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
143 iswitchb-text (concat iswitchb-text |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
144 (char-to-string last-command-char)))) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
145 (iswitchb-set-matches) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
146 (let* ((match (car iswitchb-matches)) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
147 (buf (and match (get-buffer match)))) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
148 (if (null buf) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
149 (progn |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
150 (isearchb-stop t) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
151 (isearchb-iswitchb)) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
152 (switch-to-buffer buf) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
153 (if isearchb-show-completions |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
154 (message "isearchb: %s%s" iswitchb-text |
63042
925e8bd46083
(isearchb): Don't pass a spurious second argument to `iswitchb-completions'.
Juanma Barranquero <lekktu@gmail.com>
parents:
55461
diff
changeset
|
155 (iswitchb-completions iswitchb-text)) |
55433
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
156 (if (= 1 (length iswitchb-matches)) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
157 (message "isearchb: %s (only match)" iswitchb-text) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
158 (message "isearchb: %s" iswitchb-text)))))) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
159 |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
160 (defun isearchb-set-keybindings (modifier) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
161 "Setup isearchb on the given MODIFIER." |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
162 (dotimes (i 128) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
163 (if (eq 'self-insert-command |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
164 (lookup-key global-map (vector i))) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
165 (define-key global-map (vector (list modifier i)) 'isearchb)))) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
166 |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
167 (defun isearchb-follow-char () |
76566
11d72543a2ba
(isearchb-follow-char): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
75510
diff
changeset
|
168 "Function added to `post-command-hook' to handle the isearchb \"mode\"." |
55433
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
169 (let (keys) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
170 (if (not (and (memq last-command '(isearchb isearchb-activate)) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
171 (setq keys (this-command-keys)) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
172 (= 1 (length keys)))) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
173 (isearchb-stop) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
174 (cond |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
175 ((or (equal keys "\C-h") (equal keys "\C-?") |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
176 (equal keys [backspace]) (equal keys [delete])) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
177 (setq iswitchb-text |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
178 (substring iswitchb-text 0 (1- (length iswitchb-text)))) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
179 (if (= 0 (length iswitchb-text)) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
180 (isearchb-stop t t) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
181 (setq last-command-char nil) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
182 (setq this-command 'isearchb))) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
183 ((or (equal keys "\C-i") (equal keys [tab])) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
184 (setq this-command 'isearchb-iswitchb)) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
185 ((equal keys "\C-s") |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
186 (iswitchb-next-match) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
187 (setq last-command-char nil) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
188 (setq this-command 'isearchb)) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
189 ((equal keys "\C-r") |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
190 (iswitchb-prev-match) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
191 (setq last-command-char nil) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
192 (setq this-command 'isearchb)) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
193 ((equal keys "\C-g") |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
194 (ding) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
195 (isearchb-stop t t)) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
196 ((eq (lookup-key global-map keys) 'self-insert-command) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
197 (setq this-command 'isearchb))) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
198 (if (and isearchb-idle-timeout |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
199 (null isearchb-idle-timer)) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
200 (setq isearchb-idle-timer |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
201 (run-with-idle-timer isearchb-idle-timeout nil |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
202 'isearchb-stop)))))) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
203 |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
204 ;;;###autoload |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
205 (defun isearchb-activate () |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
206 "Active isearchb mode for subsequent alphanumeric keystrokes. |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
207 Executing this command again will terminate the search; or, if |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
208 the search has not yet begun, will toggle to the last buffer |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
209 accessed via isearchb." |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
210 (interactive) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
211 (cond |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
212 ((eq last-command 'isearchb) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
213 (isearchb-stop nil t)) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
214 ((eq last-command 'isearchb-activate) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
215 (if isearchb-last-buffer |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
216 (switch-to-buffer isearchb-last-buffer) |
63420
f4efcc094de0
(isearchb-activate): Follow error conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
63042
diff
changeset
|
217 (error "isearchb: There is no previous buffer to toggle to")) |
55433
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
218 (isearchb-stop nil t)) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
219 (t |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
220 (message "isearchb: ") |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
221 (setq iswitchb-text nil |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
222 isearchb-start-buffer (current-buffer)) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
223 (add-hook 'pre-command-hook 'isearchb-follow-char)))) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
224 |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
225 (provide 'isearchb) |
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
226 |
55461
34b5f4f934df
Changes from arch/CVS synchronization
Miles Bader <miles@gnu.org>
parents:
55433
diff
changeset
|
227 ;;; arch-tag: 9277523f-a624-4aa0-ba10-b89eeb7b6e99 |
55433
e0a9c86fa070
2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents:
diff
changeset
|
228 ;;; isearchb.el ends here |