annotate lisp/utils/speedbar.el @ 172:a38aed19690b

Added tag r20-3b12 for changeset 929b76928fce
author cvs
date Mon, 13 Aug 2007 09:47:55 +0200
parents 85ec50267440
children 6075d714658b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1 ;;; speedbar --- quick access to files and tags -*-byte-compile-warnings:nil;-*-
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
3 ;; Copyright (C) 1996, 1997 Eric M. Ludlam
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
4 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
5 ;; Author: Eric M. Ludlam <zappo@gnu.ai.mit.edu>
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
6 ;; Version: 0.5
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
7 ;; Keywords: file, tags, tools
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
8 ;; X-RCS: $Id: speedbar.el,v 1.2 1997/06/29 23:13:33 steve Exp $
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
9 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
10 ;; This program is free software; you can redistribute it and/or modify
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
13 ;; any later version.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
14 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
15 ;; This program is distributed in the hope that it will be useful,
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
18 ;; GNU General Public License for more details.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
19 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
20 ;; You should have received a copy of the GNU General Public License
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
21 ;; along with this program; if not, you can either send email to this
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
22 ;; program's author (see below) or write to:
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
23 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
24 ;; The Free Software Foundation, Inc.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
25 ;; 675 Mass Ave.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
26 ;; Cambridge, MA 02139, USA.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
27 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
28 ;; Please send bug reports, etc. to zappo@gnu.ai.mit.edu.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
29 ;;
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
30
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
31 ;;; Commentary:
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
32 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
33 ;; The speedbar provides a frame in which files, and locations in
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
34 ;; files are displayed. These items can be clicked on with mouse-2
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
35 ;; in order to make the last active frame display that file location.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
36 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
37 ;; To use speedbar, add this to your .emacs file:
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
38 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
39 ;; (autoload 'speedbar-frame-mode "speedbar" "Popup a speedbar frame" t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
40 ;; (autoload 'speedbar-get-focus "speedbar" "Jump to speedbar frame" t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
41 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
42 ;; If you want to choose it from a menu or something, do this:
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
43 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
44 ;; (define-key-after (lookup-key global-map [menu-bar tools])
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
45 ;; [speedbar] '("Speedbar" . speedbar-frame-mode) [calendar])
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
46 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
47 ;; If you want to access speedbar using only the keyboard, do this:
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
48 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
49 ;; (define-key global-map [f4] 'speedbar-get-focus)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
50 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
51 ;; This will let you hit f4 (or whatever key you choose) to jump
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
52 ;; focus to the speedbar frame. Pressing RET or e to jump to a file
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
53 ;; or tag will move you back to the attached frame. The command
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
54 ;; `speedbar-get-fucus' will also create a speedbar frame if it does
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
55 ;; not exist.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
56 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
57 ;; Once a speedbar frame is active, it takes advantage of idle time
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
58 ;; to keep it's contents updated. The contents is usually a list of
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
59 ;; files in the directory of the currently active buffer. When
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
60 ;; applicable, tags in the active file can be expanded.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
61 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
62 ;; To add new supported files types into speedbar, use the function
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
63 ;; `speedbar-add-supported-extension' If speedbar complains that the
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
64 ;; file type is not supported, that means there is no built in
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
65 ;; support from imenu, and the etags part wasn't set up correctly. You
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
66 ;; may add elements to `speedbar-supported-extension-expressions' as long
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
67 ;; as it is done before speedbar is loaded.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
68 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
69 ;; To prevent speedbar from following you into certain directories
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
70 ;; use the function `speedbar-add-ignored-path-regexp' too add a new
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
71 ;; regular expression matching a type of path. You may add list
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
72 ;; elements to `speedbar-ignored-path-expressions' as long as it is
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
73 ;; done before speedbar is loaded.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
74 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
75 ;; To add new file types to imenu, see the documentation in the
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
76 ;; file imenu.el that comes with emacs. To add new file types which
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
77 ;; etags supports, you need to modify the variable
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
78 ;; `speedbar-fetch-etags-parse-list'.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
79 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
80 ;; If the updates are going too slow for you, modify the variable
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
81 ;; `speedbar-update-speed' to a longer idle time before updates.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
82 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
83 ;; If you navigate directories, you will probably notice that you
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
84 ;; will navigate to a directory which is eventually replaced after
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
85 ;; you go back to editing a file (unless you pull up a new file.)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
86 ;; The delay time before this happens is in
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
87 ;; `speedbar-navigating-speed', and defaults to 10 seconds.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
88 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
89 ;; XEmacs users may want to change the default timeouts for
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
90 ;; `speedbar-update-speed' to something longer as XEmacs doesn't have
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
91 ;; idle timers, the speedbar timer keeps going off arbitrarilly while
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
92 ;; you're typing. It's quite pesky.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
93 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
94 ;; Users of emacs previous to to v 19.31 (when idle timers
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
95 ;; where introduced) will not have speedbar updating automatically.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
96 ;; Use "r" to refresh the display after changing directories.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
97 ;; Remember, do not interrupt the stealthy updates or you display may
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
98 ;; not be completely refreshed.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
99 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
100 ;; See optional file `speedbspec.el' for additional configurations
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
101 ;; which allow speedbar to create specialized lists for special modes
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
102 ;; that are not file-related.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
103 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
104 ;; See optional file `speedbcfg.el' for interactive buffers
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
105 ;; allowing simple configuration of colors and features of speedbar.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
106 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
107 ;; AUC-TEX users: The imenu tags for AUC-TEX mode don't work very
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
108 ;; well. Use the imenu keywords from tex-mode.el for better results.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
109 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
110 ;; This file requires the library package assoc (association lists)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
111
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
112 ;;; Speedbar updates can be found at:
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
113 ;; ftp://ftp.ultranet.com/pub/zappo/speedbar*.tar.gz
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
114 ;;
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
115
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
116 ;;; Change log:
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
117 ;; 0.1 Initial Revision
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
118 ;; 0.2 Fixed problem with x-pointer-shape causing future frames not
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
119 ;; to be created.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
120 ;; Fixed annoying habit of `speedbar-update-contents' to make
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
121 ;; it possible to accidentally kill the speedbar buffer.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
122 ;; Clicking directory names now only changes the contents of
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
123 ;; the speedbar, and does not cause a dired mode to appear.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
124 ;; Clicking the <+> next to the directory does cause dired to
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
125 ;; be run.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
126 ;; Added XEmacs support, which means timer support moved to a
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
127 ;; platform independant call.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
128 ;; Added imenu support. Now modes are supported by imenu
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
129 ;; first, and etags only if the imenu call doesn't work.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
130 ;; Imenu is a little faster than etags, and is more emacs
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
131 ;; friendly.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
132 ;; Added more user control variables described in the commentary.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
133 ;; Added smart recentering when nodes are opened and closed.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
134 ;; 0.3 x-pointer-shape fixed for emacs 19.35, so I put that check in.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
135 ;; Added invisible codes to the beginning of each line.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
136 ;; Added list aproach to node expansion for easier addition of new
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
137 ;; types of things to expand by
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
138 ;; Added multi-level path name support
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
139 ;; Added multi-level tag name support.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
140 ;; Only mouse-2 is now used for node expansion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
141 ;; Added keys e + - to edit expand, and contract node lines
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
142 ;; Added longer legal file regexp for all those modes which support
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
143 ;; imenu. (pascal, fortran90, ada, pearl)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
144 ;; Added pascal support to etags from Dave Penkler <dave_penkler@grenoble.hp.com>
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
145 ;; Fixed centering algorithm
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
146 ;; Tried to choose background independent colors. Made more robust.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
147 ;; Rearranged code into a more logical order
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
148 ;; 0.3.1 Fixed doc & broken keybindings
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
149 ;; Added mode hooks.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
150 ;; Improved color selection to be background mode smart
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
151 ;; `nil' passed to `speedbar-frame-mode' now toggles the frame as
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
152 ;; advertised in the doc string
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
153 ;; 0.4a Added modified patch from Dan Schmidt <dfan@lglass.com> allowing a
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
154 ;; directory cache to be maintained speeding up revisiting of files.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
155 ;; Default raise-lower behavior is now off by default.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
156 ;; Added some menu items for edit expand and contract.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
157 ;; Pre 19.31 emacsen can run without idle timers.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
158 ;; Added some patch information from Farzin Guilak <farzin@protocol.com>
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
159 ;; adding xemacs specifics, and some etags upgrades.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
160 ;; Added ability to set a faces symbol-value to a string
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
161 ;; representing the desired foreground color. (idea from
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
162 ;; Farzin Guilak, but implemented differently)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
163 ;; Fixed problem with 1 character buttons.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
164 ;; Added support for new Imenu marker technique.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
165 ;; Added `speedbar-load-hooks' for things to run only once on
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
166 ;; load such as updating one of the many lists.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
167 ;; Added `speedbar-supported-extension-expressions' which is a
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
168 ;; list of extensions that speedbar will tag. This variable
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
169 ;; should only be updated with `speedbar-add-supported-extension'
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
170 ;; Moved configure dialog support to a separate file so
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
171 ;; speedbar is not dependant on eieio to run
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
172 ;; Fixed list-contraction problem when the item was at the end
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
173 ;; of a sublist.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
174 ;; Fixed XEmacs multi-frame timer selecting bug problem.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
175 ;; Added `speedbar-ignored-modes' which is a list of major modes
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
176 ;; speedbar will not follow when it is displayed in the selected frame
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
177 ;; 0.4 When the file being edited is not in the list, and is a file
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
178 ;; that should be in the list, the speedbar cache is replaced.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
179 ;; Temp buffers are now shown in the attached frame not the
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
180 ;; speedbar frame
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
181 ;; New variables `speedbar-vc-*' and `speedbar-stealthy-function-list'
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
182 ;; added. `speedbar-update-current-file' is now a member of
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
183 ;; the stealthy list. New function `speedbar-check-vc' will
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
184 ;; examine each file and mark it if it is checked out. To
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
185 ;; add new version control types, override the function
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
186 ;; `speedbar-this-file-in-vc' and `speedbar-vc-check-dir-p'.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
187 ;; The stealth list is interruptible so that long operations
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
188 ;; do not interrupt someones editing flow. Other long
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
189 ;; speedbar updates will be added to the stealthy list in the
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
190 ;; future should interesting ones be needed.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
191 ;; Added many new functions including:
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
192 ;; `speedbar-item-byte-compile' `speedbar-item-load'
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
193 ;; `speedbar-item-copy' `speedbar-item-rename' `speedbar-item-delete'
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
194 ;; and `speedbar-item-info'
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
195 ;; If the user kills the speedbar buffer in some way, the frame will
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
196 ;; be removed.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
197 ;; 0.4.1 Bug fixes
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
198 ;; <mark.jeffries@nomura.co.uk> added `speedbar-update-flag',
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
199 ;; XEmacs fixes for menus, and tag sorting, and quit key.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
200 ;; Modeline now updates itself based on window-width.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
201 ;; Frame is cached when closed to make pulling it up again faster.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
202 ;; Speedbars window is now marked as dedicated.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
203 ;; Added bindings: <grossjoh@charly.informatik.uni-dortmund.de>
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
204 ;; Long directories are now span multiple lines autmoatically
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
205 ;; Added `speedbar-directory-button-trim-method' to specify how to
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
206 ;; sorten the directory button to fit on the screen.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
207 ;; 0.4.2 Add one level of full-text cache.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
208 ;; Add `speedbar-get-focus' to switchto/raise the speedbar frame.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
209 ;; Editing thing-on-line will auto-raise the attached frame.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
210 ;; Bound `U' to `speedbar-up-directory' command.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
211 ;; Refresh will now maintain all subdirectories that were open
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
212 ;; when the refresh was requested. (This does not include the
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
213 ;; tags, only the directories)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
214 ;; 0.4.3 Bug fixes
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
215 ;; 0.4.4 Added `speedbar-ignored-path-expressions' and friends.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
216 ;; Configuration menu items not displayed if dialog-mode not present
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
217 ;; Speedbar buffer now starts with a space, and is not deleted
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
218 ;; ewhen the speedbar frame is closed. This prevents the invisible
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
219 ;; frame from preventing buffer switches with other buffers.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
220 ;; Fixed very bad bug in the -add-[extension|path] functions.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
221 ;; Added `speedbar-find-file-in-frame' which will always pop up a frame
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
222 ;; that is already display a buffer selected in the speedbar buffer.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
223 ;; Added S-mouse2 as "power click" for always poping up a new frame.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
224 ;; and always rescanning with imenu (ditching the imenu cache), and
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
225 ;; always rescanning directories.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
226 ;; 0.4.5 XEmacs bugfixes and enhancements.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
227 ;; Window Title simplified.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
228 ;; 0.4.6 Fixed problems w/ dedicated minibuffer frame.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
229 ;; Fixed errors reported by checkdoc.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
230 ;; 0.5 Mode-specific contents added. Controlled w/ the variable
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
231 ;; `speedbar-mode-specific-contents-flag'. See speedbspec
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
232 ;; for info on enabling this feature.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
233 ;; `speedbar-load-hook' name change and pointer check against
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
234 ;; major-mode. Suggested by Sam Steingold <sds@ptc.com>
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
235 ;; Quit auto-selects the attached frame.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
236 ;; Ranamed `speedbar-do-updates' to `speedbar-update-flag'
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
237 ;; Passes checkdoc.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
238
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
239 ;;; TODO:
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
240 ;; 1) More functions to create buttons and options
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
241 ;; 2) filtering algoritms to reduce the number of tags/files displayed.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
242 ;; 3) Timeout directories we haven't visited in a while.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
243 ;; 4) Remeber tags when refreshing the display. (Refresh tags too?)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
244 ;; 5) More 'special mode support.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
245 ;; 6) Smart way to auto-expand instead of directory switch
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
246
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
247 ;;; Code:
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
248 (require 'assoc)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
249 (require 'easymenu)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
250
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
251 (defvar speedbar-xemacsp (string-match "XEmacs" emacs-version)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
252 "Non-nil if we are running in the XEmacs environment.")
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
253
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
254 (defvar speedbar-initial-expansion-list
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
255 '(speedbar-directory-buttons speedbar-default-directory-list)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
256 "List of functions to call to fill in the speedbar buffer.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
257 Whenever a top level update is issued all functions in this list are
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
258 run. These functions will always get the default directory to use
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
259 passed in as the first parameter, and a 0 as the second parameter.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
260 The 0 indicates the uppermost indentation level. They must assume
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
261 that the cursor is at the position where they start inserting
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
262 buttons.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
263
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
264 (defvar speedbar-stealthy-function-list
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
265 '(speedbar-update-current-file speedbar-check-vc)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
266 "List of functions to periodically call stealthily.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
267 Each function must return nil if interrupted, or t if completed.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
268 Stealthy functions which have a single operation should always return
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
269 t. Functions which take a long time should maintain a state (where
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
270 they are in their speedbar related calculations) and permit
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
271 interruption. See `speedbar-check-vc' as a good example.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
272
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
273 (defvar speedbar-mode-specific-contents-flag t
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
274 "*Non-nil means speedbar will show specail-mode contents.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
275 This permits some modes to create customized contents for the speedbar
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
276 frame.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
277
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
278 (defvar speedbar-special-mode-expansion-list nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
279 "Mode specific list of functions to call to fill in speedbar.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
280 Some modes, such as Info or RMAIL, do not relate quite as easily into
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
281 a simple list of files. When this variable is non-nil and buffer-local,
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
282 then these functions are used, creating specialized contents. These
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
283 functions are called each time the speedbar timer is called. This
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
284 allows a mode to update it's contents regularly.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
285
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
286 Each function is called with the default and frame belonging to
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
287 speedbar, and with one parameter; the buffer requesting
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
288 the speedbar display.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
289
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
290 (defvar speedbar-load-hook nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
291 "Hooks run when speedbar is loaded.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
292
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
293 (defvar speedbar-desired-buffer nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
294 "Non-nil when speedbar is showing buttons specific a special mode.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
295 In this case it is the originating buffer.")
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
296
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
297 (defvar speedbar-show-unknown-files nil
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
298 "*Non-nil show files we can't expand with a ? in the expand button.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
299 nil means don't show the file in the list.")
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
300
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
301 ;; Xemacs timers aren't based on idleness. Therefore tune it down a little
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
302 ;; or suffer mightilly!
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
303 (defvar speedbar-update-speed (if speedbar-xemacsp 5 1)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
304 "*Idle time in seconds needed before speedbar will update itself.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
305 Updates occur to allow speedbar to display directory information
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
306 relevant to the buffer you are currently editing.")
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
307 (defvar speedbar-navigating-speed 10
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
308 "*Idle time to wait after navigation commands in speedbar are executed.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
309 Navigation commands included expanding/contracting nodes, and moving
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
310 between different directories.")
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
311
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
312 (defvar speedbar-frame-parameters (list
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
313 ;; Xemacs fails to delete speedbar
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
314 ;; if minibuffer is off.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
315 ;(cons 'minibuffer
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
316 ; (if speedbar-xemacsp t nil))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
317 ;; The above behavior seems to have fixed
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
318 ;; itself somewhere along the line.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
319 ;; let me know if any problems arise.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
320 '(minibuffer . nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
321 '(width . 20)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
322 '(scroll-bar-width . 10)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
323 '(border-width . 0)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
324 '(unsplittable . t) )
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
325 "*Parameters to use when creating the speedbar frame.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
326 Parameters not listed here which will be added automatically are
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
327 `height' which will be initialized to the height of the frame speedbar
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
328 is attached to. To add more frame defaults, `cons' new alist members
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
329 onto this variable through the `speedbar-load-hook'")
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
330
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
331 (defvar speedbar-use-imenu-flag (stringp (locate-library "imenu"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
332 "*Non-nil means use imenu for file parsing. nil to use etags.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
333 XEmacs doesn't support imenu, therefore the default is to use etags
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
334 instead. Etags support is not as robust as imenu support.")
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
335
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
336 (defvar speedbar-sort-tags nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
337 "*If Non-nil, sort tags in the speedbar display. (Etags only)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
338 See imenu.el source for how imenu does sorting.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
339
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
340 (defvar speedbar-directory-button-trim-method 'span
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
341 "*Indicates how the directory button will be displayed.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
342 Possible values are:
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
343 'span - span large directories over multiple lines.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
344 'trim - trim large directories to only show the last few.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
345 nil - no trimming.")
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
346
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
347 (defvar speedbar-before-delete-hook nil
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
348 "*Hooks called before deleting the speedbar frame.")
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
349
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
350 (defvar speedbar-mode-hook nil
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
351 "*Hooks called after creating a speedbar buffer.")
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
352
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
353 (defvar speedbar-timer-hook nil
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
354 "*Hooks called after running the speedbar timer function.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
355
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
356 (defvar speedbar-verbosity-level 1
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
357 "*Verbosity level of the speedbar. 0 means say nothing.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
358 1 means medium level verbosity. 2 and higher are higher levels of
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
359 verbosity.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
360
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
361 (defvar speedbar-vc-indicator " *"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
362 "*Text used to mark files which are currently checked out.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
363 Currently only RCS is supported. Other version control systems can be
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
364 added by examining the function `speedbar-this-file-in-vc' and
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
365 `speedbar-vc-check-dir-p'")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
366
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
367 (defvar speedbar-vc-do-check t
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
368 "*Non-nil check all files in speedbar to see if they have been checked out.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
369 Any file checked out is marked with `speedbar-vc-indicator'")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
370
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
371 (defvar speedbar-vc-to-do-point nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
372 "Local variable maintaining the current version control check position.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
373
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
374 (defvar speedbar-ignored-modes nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
375 "*List of major modes which speedbar will not switch directories for.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
376
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
377 (defvar speedbar-ignored-path-expressions
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
378 '("/log/$")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
379 "*List of regular expressions matching directories speedbar will ignore.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
380 They should included paths to directories which are notoriously very
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
381 large and take a long time to load in. Use the function
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
382 `speedbar-add-ignored-path-regexp' to add new items to this list after
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
383 speedbar is loaded. You may place anything you like in this list
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
384 before speedbar has been loaded.")
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
385
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
386 (defvar speedbar-file-unshown-regexp
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
387 (let ((nstr "") (noext completion-ignored-extensions))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
388 (while noext
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
389 (setq nstr (concat nstr (regexp-quote (car noext)) "$"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
390 (if (cdr noext) "\\|" ""))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
391 noext (cdr noext)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
392 (concat nstr "\\|#[^#]+#$\\|\\.\\.?$"))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
393 "*Regexp matching files we don't want displayed in a speedbar buffer.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
394 It is generated from the variable `completion-ignored-extensions'")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
395
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
396 (defvar speedbar-supported-extension-expressions
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
397 (append '(".[CcHh]\\(++\\|pp\\|c\\|h\\)?" ".tex\\(i\\(nfo\\)?\\)?"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
398 ".el" ".emacs" ".p" ".java")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
399 (if speedbar-use-imenu-flag
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
400 '(".f90" ".ada" ".pl" ".tcl" ".m"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
401 "Makefile\\(\\.in\\)?")))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
402 "*List of regular expressions which will match files supported by tagging.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
403 Do not prefix the `.' char with a double \\ to quote it, as the period
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
404 will be stripped by a simplified optimizer when compiled into a
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
405 singular expression. This variable will be turned into
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
406 `speedbar-file-regexp' for use with speedbar. You should use the
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
407 function `speedbar-add-supported-extension' to add a new extension at
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
408 runtime, or use the configuration dialog to set it in your .emacs
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
409 file.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
410
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
411 (defun speedbar-extension-list-to-regex (extlist)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
412 "Takes EXTLIST, a list of extensions and transforms it into regexp.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
413 All the preceding . are stripped for an optimized expression starting
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
414 with . followed by extensions, followed by full-filenames."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
415 (let ((regex1 nil) (regex2 nil))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
416 (while extlist
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
417 (if (= (string-to-char (car extlist)) ?.)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
418 (setq regex1 (concat regex1 (if regex1 "\\|" "")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
419 (substring (car extlist) 1)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
420 (setq regex2 (concat regex2 (if regex2 "\\|" "") (car extlist))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
421 (setq extlist (cdr extlist)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
422 ;; concat all the sub-exressions together, making sure all types
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
423 ;; of parts exist during concatination.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
424 (concat "\\("
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
425 (if regex1 (concat "\\(\\.\\(" regex1 "\\)\\)") "")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
426 (if (and regex1 regex2) "\\|" "")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
427 (if regex2 (concat "\\(" regex2 "\\)") "")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
428 "\\)$")))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
429
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
430 (defvar speedbar-ignored-path-regexp
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
431 (speedbar-extension-list-to-regex speedbar-ignored-path-expressions)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
432 "Regular expression matching paths speedbar will not switch to.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
433 Created from `speedbar-ignored-path-expressions' with the function
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
434 `speedbar-extension-list-to-regex' (A misnamed function in this case.)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
435 Use the function `speedbar-add-ignored-path-regexp' to modify this
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
436 variable.")
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
437
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
438 (defvar speedbar-file-regexp
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
439 (speedbar-extension-list-to-regex speedbar-supported-extension-expressions)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
440 "Regular expression matching files we know how to expand.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
441 Created from `speedbar-supported-extension-expression' with the
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
442 function `speedbar-extension-list-to-regex'")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
443
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
444 (defun speedbar-add-supported-extension (extension)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
445 "Add EXTENSION as a new supported extension for speedbar tagging.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
446 This should start with a `.' if it is not a complete file name, and
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
447 the dot should NOT be quoted in with \\. Other regular expression
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
448 matchers are allowed however. EXTENSION may be a single string or a
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
449 list of strings."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
450 (if (not (listp extension)) (setq extension (list extension)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
451 (while extension
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
452 (if (member (car extension) speedbar-supported-extension-expressions)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
453 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
454 (setq speedbar-supported-extension-expressions
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
455 (cons (car extension) speedbar-supported-extension-expressions)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
456 (setq extension (cdr extension)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
457 (setq speedbar-file-regexp (speedbar-extension-list-to-regex
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
458 speedbar-supported-extension-expressions)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
459
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
460 (defun speedbar-add-ignored-path-regexp (path-expression)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
461 "Add PATH-EXPRESSION as a new ignored path for speedbar tracking.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
462 This function will modify `speedbar-ignored-path-regexp' and add
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
463 PATH-EXPRESSION to `speedbar-ignored-path-expressions'."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
464 (if (not (listp path-expression))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
465 (setq path-expression (list path-expression)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
466 (while path-expression
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
467 (if (member (car path-expression) speedbar-ignored-path-expressions)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
468 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
469 (setq speedbar-ignored-path-expressions
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
470 (cons (car path-expression) speedbar-ignored-path-expressions)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
471 (setq path-expression (cdr path-expression)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
472 (setq speedbar-ignored-path-regexp (speedbar-extension-list-to-regex
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
473 speedbar-ignored-path-expressions)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
474
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
475 (defvar speedbar-update-flag (or (not (fboundp 'run-with-idle-timer))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
476 (not (fboundp 'start-itimer)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
477 "*Non-nil means to automatically update the display.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
478 When this is nil then speedbar will not follow the attached frame's path.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
479 When speedbar is active, use:
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
480
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
481 \\<speedbar-key-map> `\\[speedbar-toggle-updates]'
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
482
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
483 to toggle this value.")
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
484
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
485 (defvar speedbar-syntax-table nil
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
486 "Syntax-table used on the speedbar.")
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
487
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
488 (if speedbar-syntax-table
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
489 nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
490 (setq speedbar-syntax-table (make-syntax-table))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
491 ;; turn off paren matching around here.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
492 (modify-syntax-entry ?\' " " speedbar-syntax-table)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
493 (modify-syntax-entry ?\" " " speedbar-syntax-table)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
494 (modify-syntax-entry ?( " " speedbar-syntax-table)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
495 (modify-syntax-entry ?) " " speedbar-syntax-table)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
496 (modify-syntax-entry ?[ " " speedbar-syntax-table)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
497 (modify-syntax-entry ?] " " speedbar-syntax-table))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
498
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
499
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
500 (defvar speedbar-key-map nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
501 "Keymap used in speedbar buffer.")
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
502
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
503 (autoload 'speedbar-configure-options "speedbcfg" "Configure speedbar variables" t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
504 (autoload 'speedbar-configure-faces "speedbcfg" "Configure speedbar faces" t)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
505
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
506 (if speedbar-key-map
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
507 nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
508 (setq speedbar-key-map (make-keymap))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
509 (suppress-keymap speedbar-key-map t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
510
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
511 ;; control
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
512 (define-key speedbar-key-map "e" 'speedbar-edit-line)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
513 (define-key speedbar-key-map "\C-m" 'speedbar-edit-line)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
514 (define-key speedbar-key-map "+" 'speedbar-expand-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
515 (define-key speedbar-key-map "-" 'speedbar-contract-line)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
516 (define-key speedbar-key-map "g" 'speedbar-refresh)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
517 (define-key speedbar-key-map "t" 'speedbar-toggle-updates)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
518 (define-key speedbar-key-map "q" 'speedbar-close-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
519 (define-key speedbar-key-map "U" 'speedbar-up-directory)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
520
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
521 ;; navigation
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
522 (define-key speedbar-key-map "n" 'speedbar-next)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
523 (define-key speedbar-key-map "p" 'speedbar-prev)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
524 (define-key speedbar-key-map " " 'speedbar-scroll-up)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
525 (define-key speedbar-key-map "\C-?" 'speedbar-scroll-down)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
526
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
527 ;; After much use, I suddenly desired in my heart to perform dired
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
528 ;; style operations since the directory was RIGHT THERE!
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
529 (define-key speedbar-key-map "I" 'speedbar-item-info)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
530 (define-key speedbar-key-map "B" 'speedbar-item-byte-compile)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
531 (define-key speedbar-key-map "L" 'speedbar-item-load)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
532 (define-key speedbar-key-map "C" 'speedbar-item-copy)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
533 (define-key speedbar-key-map "D" 'speedbar-item-delete)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
534 (define-key speedbar-key-map "R" 'speedbar-item-rename)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
535
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
536 (if (string-match "XEmacs" emacs-version)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
537 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
538 ;; bind mouse bindings so we can manipulate the items on each line
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
539 (define-key speedbar-key-map 'button2 'speedbar-click)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
540 (define-key speedbar-key-map '(shift button2) 'speedbar-power-click)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
541 (define-key speedbar-key-map '(meta button3) 'speedbar-mouse-item-info)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
542
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
543 ;; Setup XEmacs Menubar w/ etags specific items
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
544 (defvar speedbar-menu
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
545 '("Speed Bar"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
546 ["Run Speedbar" (speedbar-frame-mode 1) t]
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
547 ["Refresh" speedbar-refresh t]
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
548 ["Allow Auto Updates"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
549 speedbar-toggle-updates
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
550 :style toggle
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
551 :selected speedbar-update-flag]
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
552 "-----"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
553 ["Sort etags in Speedbar"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
554 (speedbar-toggle-etags "sort")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
555 :style toggle
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
556 :selected speedbar-sort-tags]
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
557 ["Show unknown files"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
558 (speedbar-toggle-etags "show")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
559 :style toggle
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
560 :selected speedbar-show-unknown-files]
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
561 "-----"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
562 ["Use C++ Tagging"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
563 (speedbar-toggle-etags "-C")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
564 :style toggle
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
565 :selected (member "-C" speedbar-fetch-etags-arguments)]
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
566 ["Tag preprocessor defs"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
567 (speedbar-toggle-etags "-D")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
568 :style toggle
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
569 :selected (not (member "-D" speedbar-fetch-etags-arguments))]
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
570 ["Use indentation"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
571 (speedbar-toggle-etags "-S")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
572 :style toggle
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
573 :selected (not (member "-S" speedbar-fetch-etags-arguments))]))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
574
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
575 (add-submenu '("Tools") speedbar-menu nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
576
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
577 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
578 ;; bind mouse bindings so we can manipulate the items on each line
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
579 (define-key speedbar-key-map [mouse-2] 'speedbar-click)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
580 ;; This is the power click for poping up new frames
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
581 (define-key speedbar-key-map [S-mouse-2] 'speedbar-power-click)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
582 ;; This adds a small unecessary visual effect
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
583 ;;(define-key speedbar-key-map [down-mouse-2] 'speedbar-quick-mouse)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
584 (define-key speedbar-key-map [M-mouse-2] 'speedbar-mouse-item-info)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
585
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
586 ;; disable all menus - we don't have a lot of space to play with
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
587 ;; in such a skinny frame. This will cleverly find and nuke some
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
588 ;; user-defined menus as well if they are there. Too bad it
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
589 ;; rely's on the structure of a keymap to work.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
590 (let ((k (lookup-key global-map [menu-bar])))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
591 (while k
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
592 (if (and (listp (car k)) (listp (cdr (car k))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
593 (define-key speedbar-key-map (vector 'menu-bar (car (car k)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
594 'undefined))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
595 (setq k (cdr k))))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
596
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
597 ;; This lets the user scroll as if we had a scrollbar... well maybe not
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
598 (define-key speedbar-key-map [mode-line mouse-2] 'speedbar-mouse-hscroll)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
599 ))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
600
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
601 (defvar speedbar-easymenu-definition-base
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
602 '("Speedbar"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
603 ["Update" speedbar-refresh t]
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
604 ["Auto Update" speedbar-toggle-updates
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
605 :style toggle :selected speedbar-update-flag]
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
606 )
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
607 "Base part of the speedbar menu.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
608
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
609 (defvar speedbar-easymenu-definition-special
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
610 '(["Edit Item On Line" speedbar-edit-line t]
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
611 ["Show All Files" speedbar-toggle-show-all-files
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
612 :style toggle :selected speedbar-show-unknown-files]
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
613 ["Expand Item" speedbar-expand-line
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
614 (save-excursion (beginning-of-line)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
615 (looking-at "[0-9]+: *.\\+. "))]
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
616 ["Contract Item" speedbar-contract-line
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
617 (save-excursion (beginning-of-line)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
618 (looking-at "[0-9]+: *.-. "))]
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
619 "----"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
620 ["Item Information" speedbar-item-info t]
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
621 ["Load Lisp File" speedbar-item-load
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
622 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
623 (beginning-of-line)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
624 (looking-at "[0-9]+: *\\[[+-]\\] .+\\(\\.el\\)\\( \\*\\)?$"))]
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
625 ["Byte Compile File" speedbar-item-byte-compile
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
626 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
627 (beginning-of-line)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
628 (looking-at "[0-9]+: *\\[[+-]\\] .+\\(\\.el\\)\\( \\*\\)?$"))]
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
629 ["Copy Item" speedbar-item-copy
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
630 (save-excursion (beginning-of-line) (looking-at "[0-9]+: *\\["))]
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
631 ["Rename Item" speedbar-item-rename
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
632 (save-excursion (beginning-of-line) (looking-at "[0-9]+: *[[<]"))]
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
633 ["Delete Item" speedbar-item-delete
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
634 (save-excursion (beginning-of-line) (looking-at "[0-9]+: *[[<]"))])
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
635 "Additional menu items while in file-mode.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
636
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
637 (defvar speedbar-easymenu-definition-trailer
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
638 '("----"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
639 ["Close" speedbar-close-frame t])
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
640 "Menu items appearing at the end of the speedbar menu.")
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
641
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
642 (defvar speedbar-buffer nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
643 "The buffer displaying the speedbar.")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
644 (defvar speedbar-frame nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
645 "The frame displaying speedbar.")
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
646 (defvar speedbar-cached-frame nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
647 "The frame that was last created, then removed from the display.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
648 (defvar speedbar-full-text-cache nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
649 "The last open directory is saved in it's entirety for ultra-fast switching.")
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
650 (defvar speedbar-timer nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
651 "The speedbar timer used for updating the buffer.")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
652 (defvar speedbar-attached-frame nil
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
653 "The frame which started speedbar mode.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
654 This is the frame from which all data displayed in the speedbar is
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
655 gathered, and in which files and such are displayed.")
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
656
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
657 (defvar speedbar-last-selected-file nil
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
658 "The last file which was selected in speedbar buffer.")
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
659
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
660 (defvar speedbar-shown-directories nil
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
661 "Maintain list of directories simultaneously open in the current speedbar.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
662
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
663 (defvar speedbar-directory-contents-alist nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
664 "An association list of directories and their contents.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
665 Each sublist was returned by `speedbar-file-lists'. This list is
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
666 maintained to speed up the refresh rate when switching between
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
667 directories.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
668
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
669 (defvar speedbar-power-click nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
670 "Never set this by hand. Value is t when S-mouse activity occurs.")
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
671
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
672
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
673 ;;; Mode definitions/ user commands
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
674 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
675 ;;###autoload
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
676 (defalias 'speedbar 'speedbar-frame-mode)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
677 (defun speedbar-frame-mode (&optional arg)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
678 "Enable or disable speedbar. Positive ARG means turn on, negative turn off.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
679 nil means toggle. Once the speedbar frame is activated, a buffer in
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
680 `speedbar-mode' will be displayed. Currently, only one speedbar is
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
681 supported at a time."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
682 (interactive "P")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
683 (if (not window-system)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
684 (error "Speedbar is not useful outside of a windowing environment"))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
685 ;; toggle frame on and off.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
686 (if (not arg) (if speedbar-frame (setq arg -1) (setq arg 1)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
687 ;; turn the frame off on neg number
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
688 (if (and (numberp arg) (< arg 0))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
689 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
690 (run-hooks 'speedbar-before-delete-hook)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
691 (if (and speedbar-frame (frame-live-p speedbar-frame))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
692 (if speedbar-xemacsp
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
693 (delete-frame speedbar-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
694 (setq speedbar-cached-frame speedbar-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
695 (modify-frame-parameters speedbar-frame '((visibility . nil)))))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
696 (setq speedbar-frame nil)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
697 (speedbar-set-timer nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
698 ;; Used to delete the buffer. This has the annoying affect of
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
699 ;; preventing whatever took it's place from ever appearing
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
700 ;; as the default after a C-x b was typed
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
701 ;;(if (bufferp speedbar-buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
702 ;; (kill-buffer speedbar-buffer))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
703 )
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
704 ;; Set this as our currently attached frame
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
705 (setq speedbar-attached-frame (selected-frame))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
706 ;; Get the frame to work in
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
707 (if (frame-live-p speedbar-cached-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
708 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
709 (setq speedbar-frame speedbar-cached-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
710 (modify-frame-parameters speedbar-frame '((visibility . t)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
711 ;; Get the buffer to play with
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
712 (speedbar-mode)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
713 (select-frame speedbar-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
714 (if (not (eq (current-buffer) speedbar-buffer))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
715 (switch-to-buffer speedbar-buffer))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
716 (set-window-dedicated-p (selected-window) t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
717 (raise-frame speedbar-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
718 (speedbar-set-timer speedbar-update-speed)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
719 )
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
720 (if (frame-live-p speedbar-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
721 (raise-frame speedbar-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
722 (let ((params (cons (cons 'height (frame-height))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
723 speedbar-frame-parameters)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
724 (setq speedbar-frame
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
725 (if (< emacs-major-version 20) ;a bug is fixed in v20 & later
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
726 (make-frame params)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
727 (let ((x-pointer-shape x-pointer-top-left-arrow)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
728 (x-sensitive-text-pointer-shape x-pointer-hand2))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
729 (make-frame params)))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
730 ;; reset the selection variable
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
731 (setq speedbar-last-selected-file nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
732 ;; Put the buffer into the frame
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
733 (save-window-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
734 ;; Get the buffer to play with
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
735 (speedbar-mode)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
736 (select-frame speedbar-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
737 (switch-to-buffer speedbar-buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
738 (set-window-dedicated-p (selected-window) t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
739 ;; Turn off toolbar and menubar under XEmacs
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
740 (if speedbar-xemacsp
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
741 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
742 (set-specifier default-toolbar-visible-p
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
743 (cons (selected-frame) nil))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
744 ;; These lines make the menu-bar go away nicely, but
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
745 ;; they also cause xemacs much heartache.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
746 ;;(set-specifier menubar-visible-p (cons (selected-frame) nil))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
747 ;;(make-local-variable 'current-menubar)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
748 ;;(setq current-menubar speedbar-menu)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
749 ;;(add-submenu nil speedbar-menu nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
750 )))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
751 (speedbar-set-timer speedbar-update-speed)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
752 ))))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
753
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
754 (defun speedbar-close-frame ()
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
755 "Turn off a currently active speedbar."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
756 (interactive)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
757 (speedbar-frame-mode -1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
758 (select-frame speedbar-attached-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
759 (other-frame 0))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
760
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
761 (defun speedbar-frame-width ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
762 "Return the width of the speedbar frame in characters.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
763 nil if it doesn't exist."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
764 (and speedbar-frame (cdr (assoc 'width (frame-parameters speedbar-frame)))))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
765
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
766 (defun speedbar-mode ()
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
767 "Major mode for managing a display of directories and tags.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
768 \\<speedbar-key-map>
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
769 The first line represents the default path of the speedbar frame.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
770 Each directory segment is a button which jumps speedbar's default
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
771 directory to that path. Buttons are activated by clicking `\\[speedbar-click]'.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
772 In some situations using `\\[speedbar-power-click]' is a `power click' which will
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
773 rescan cached items, or pop up new frames.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
774
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
775 Each line starting with <+> represents a directory. Click on the <+>
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
776 to insert the directory listing into the current tree. Click on the
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
777 <-> to retract that list. Click on the directory name to go to that
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
778 directory as the default.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
779
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
780 Each line starting with [+] is a file. If the variable
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
781 `speedbar-show-unknown-files' is t, the lines starting with [?] are
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
782 files which don't have imenu support, but are not expressly ignored.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
783 Files are completely ignored if they match `speedbar-file-unshown-regexp'
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
784 which is generated from `completion-ignored-extensions'.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
785
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
786 Files with a `*' character after their name are files checked out of a
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
787 version control system. (currently only RCS is supported.) New
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
788 version control systems can be added by examining the documentation
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
789 for `speedbar-this-file-in-vc' and `speedbar-vc-check-dir-p'
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
790
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
791 Click on the [+] to display a list of tags from that file. Click on
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
792 the [-] to retract the list. Click on the file name to edit the file
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
793 in the attached frame.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
794
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
795 If you open tags, you might find a node starting with {+}, which is a
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
796 category of tags. Click the {+} to expand the category. Jump-able
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
797 tags start with >. Click the name of the tag to go to that position
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
798 in the selected file.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
799
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
800 \\{speedbar-key-map}"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
801 ;; NOT interactive
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
802 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
803 (setq speedbar-buffer (set-buffer (get-buffer-create " SPEEDBAR")))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
804 (kill-all-local-variables)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
805 (setq major-mode 'speedbar-mode)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
806 (setq mode-name "Speedbar")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
807 (use-local-map speedbar-key-map)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
808 (set-syntax-table speedbar-syntax-table)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
809 (setq font-lock-keywords nil) ;; no font-locking please
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
810 (setq truncate-lines t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
811 (make-local-variable 'frame-title-format)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
812 (setq frame-title-format "Speedbar")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
813 ;; Set this up special just for the speedbar buffer
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
814 (if (null default-minibuffer-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
815 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
816 (make-local-variable 'default-minibuffer-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
817 (setq default-minibuffer-frame speedbar-attached-frame)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
818 (make-local-variable 'temp-buffer-show-function)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
819 (setq temp-buffer-show-function 'speedbar-temp-buffer-show-function)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
820 (setq kill-buffer-hook '(lambda () (let ((skilling (boundp 'skilling)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
821 (if skilling
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
822 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
823 (if (eq (current-buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
824 speedbar-buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
825 (speedbar-frame-mode -1))))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
826 (speedbar-set-mode-line-format)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
827 (if (not speedbar-xemacsp)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
828 (setq auto-show-mode nil)) ;no auto-show for Emacs
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
829 (run-hooks 'speedbar-mode-hook))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
830 (speedbar-update-contents)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
831 speedbar-buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
832
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
833 (defun speedbar-set-mode-line-format ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
834 "Set the format of the mode line based on the current speedbar environment.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
835 This gives visual indications of what is up. It EXPECTS the speedbar
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
836 frame and window to be the currently active frame and window."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
837 (if (frame-live-p speedbar-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
838 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
839 (set-buffer speedbar-buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
840 (let* ((w (or (speedbar-frame-width) 20))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
841 (p1 "<<")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
842 (p5 ">>")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
843 (p3 (if speedbar-update-flag "SPEEDBAR" "SLOWBAR"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
844 (blank (- w (length p1) (length p3) (length p5)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
845 (if line-number-mode 4 0)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
846 (p2 (if (> blank 0)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
847 (make-string (/ blank 2) ? )
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
848 ""))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
849 (p4 (if (> blank 0)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
850 (make-string (+ (/ blank 2) (% blank 2)) ? )
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
851 ""))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
852 (tf
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
853 (if line-number-mode
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
854 (list (concat p1 p2 p3) '(line-number-mode " %3l")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
855 (concat p4 p5))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
856 (list (concat p1 p2 p3 p4 p5)))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
857 (if (not (equal mode-line-format tf))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
858 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
859 (setq mode-line-format tf)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
860 (force-mode-line-update)))))))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
861
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
862 (defun speedbar-temp-buffer-show-function (buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
863 "Placed in the variable `temp-buffer-show-function' in `speedbar-mode'.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
864 If a user requests help using \\[help-command] <Key> the temp BUFFER will be
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
865 redirected into a window on the attached frame."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
866 (if speedbar-attached-frame (select-frame speedbar-attached-frame))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
867 (pop-to-buffer buffer nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
868 (other-window -1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
869 (run-hooks 'temp-buffer-show-hook))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
870
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
871 (defun speedbar-reconfigure-menubar ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
872 "Reconfigure the menu-bar in a speedbar frame.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
873 Different menu items are displayed depending on the current display mode
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
874 and the existence of packages."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
875 (let ((km (make-sparse-keymap))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
876 (cf (selected-frame))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
877 (md (append speedbar-easymenu-definition-base
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
878 (if speedbar-shown-directories
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
879 ;; file display mode version
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
880 speedbar-easymenu-definition-special
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
881 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
882 (select-frame speedbar-attached-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
883 (if (local-variable-p
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
884 'speedbar-easymenu-definition-special)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
885 ;; If bound locally, we can use it
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
886 speedbar-easymenu-definition-special)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
887 ;; The trailer
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
888 speedbar-easymenu-definition-trailer)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
889 (easy-menu-define speedbar-menu-map speedbar-key-map "Speedbar menu" md)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
890 (if speedbar-xemacsp (set-buffer-menubar (list km)))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
891
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
892
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
893 ;;; User Input stuff
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
894 ;;
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
895 (defun speedbar-mouse-hscroll (e)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
896 "Read a mouse event E from the mode line, and horizontally scroll.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
897 If the mouse is being clicked on the far left, or far right of the
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
898 mode-line. This is only useful for non-XEmacs"
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
899 (interactive "e")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
900 (let* ((xp (car (nth 2 (car (cdr e)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
901 (cpw (/ (frame-pixel-width)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
902 (frame-width)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
903 (oc (1+ (/ xp cpw)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
904 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
905 (cond ((< oc 3)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
906 (scroll-left 2))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
907 ((> oc (- (window-width) 3))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
908 (scroll-right 2))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
909 (t (message "Click on the edge of the modeline to scroll left/right")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
910 ;;(message "X: Pixel %d Char Pixels %d On char %d" xp cpw oc)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
911 ))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
912
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
913 (defun speedbar-get-focus ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
914 "Change frame focus to or from the speedbar frame.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
915 If the selected frame is not speedbar, then speedbar frame is
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
916 selected. If the speedbar frame is active, then select the attached frame."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
917 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
918 (if (eq (selected-frame) speedbar-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
919 (if (frame-live-p speedbar-attached-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
920 (select-frame speedbar-attached-frame))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
921 ;; make sure we have a frame
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
922 (if (not (frame-live-p speedbar-frame)) (speedbar-frame-mode 1))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
923 ;; go there
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
924 (select-frame speedbar-frame))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
925 (other-frame 0))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
926
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
927 (defun speedbar-next (arg)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
928 "Move to the next ARGth line in a speedbar buffer."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
929 (interactive "p")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
930 (forward-line (or arg 1))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
931 (speedbar-item-info)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
932 (speedbar-position-cursor-on-line))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
933
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
934 (defun speedbar-prev (arg)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
935 "Move to the previous ARGth line in a speedbar buffer."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
936 (interactive "p")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
937 (speedbar-next (if arg (- arg) -1)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
938
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
939 (defun speedbar-scroll-up (&optional arg)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
940 "Page down one screen-full of the speedbar, or ARG lines."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
941 (interactive "P")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
942 (scroll-up arg)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
943 (speedbar-position-cursor-on-line))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
944
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
945 (defun speedbar-scroll-down (&optional arg)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
946 "Page up one screen-full of the speedbar, or ARG lines."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
947 (interactive "P")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
948 (scroll-down arg)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
949 (speedbar-position-cursor-on-line))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
950
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
951 (defun speedbar-up-directory ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
952 "Keyboard accelerator for moving the default directory up one.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
953 Assumes that the current buffer is the speedbar buffer"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
954 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
955 (setq default-directory (expand-file-name (concat default-directory "../")))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
956 (speedbar-update-contents))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
957
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
958 ;;; Speedbar file activity
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
959 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
960 (defun speedbar-refresh ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
961 "Refresh the current speedbar display, disposing of any cached data."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
962 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
963 (let ((dl speedbar-shown-directories))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
964 (while dl
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
965 (adelete 'speedbar-directory-contents-alist (car dl))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
966 (setq dl (cdr dl))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
967 (if (<= 1 speedbar-verbosity-level) (message "Refreshing speedbar..."))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
968 (speedbar-update-contents)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
969 (speedbar-stealthy-updates)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
970 ;; Reset the timer in case it got really hosed for some reason...
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
971 (speedbar-set-timer speedbar-update-speed)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
972 (if (<= 1 speedbar-verbosity-level) (message "Refreshing speedbar...done")))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
973
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
974 (defun speedbar-item-load ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
975 "Byte compile the item under the cursor or mouse if it is a lisp file."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
976 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
977 (let ((f (speedbar-line-file)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
978 (if (and (file-exists-p f) (string-match "\\.el$" f))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
979 (if (and (file-exists-p (concat f "c"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
980 (y-or-n-p (format "Load %sc? " f)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
981 ;; If the compiled version exists, load that instead...
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
982 (load-file (concat f "c"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
983 (load-file f))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
984 (error "Not a loadable file..."))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
985
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
986 (defun speedbar-item-byte-compile ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
987 "Byte compile the item under the cursor or mouse if it is a lisp file."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
988 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
989 (let ((f (speedbar-line-file))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
990 (sf (selected-frame)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
991 (if (and (file-exists-p f) (string-match "\\.el$" f))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
992 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
993 (select-frame speedbar-attached-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
994 (byte-compile-file f nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
995 (select-frame sf)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
996 ))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
997
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
998 (defun speedbar-mouse-item-info (event)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
999 "Provide information about what the user clicked on.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1000 This should be bound to a mouse EVENT."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1001 (interactive "e")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1002 (mouse-set-point event)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1003 (speedbar-item-info))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1004
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1005 (defun speedbar-item-info ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1006 "Display info in the mini-buffer about the button the mouse is over."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1007 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1008 (if (not speedbar-shown-directories)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1009 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1010 (let* ((item (speedbar-line-file))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1011 (attr (if item (file-attributes item) nil)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1012 (if item (message "%s %d %s" (nth 8 attr) (nth 7 attr) item)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1013 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1014 (beginning-of-line)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1015 (looking-at "\\([0-9]+\\):")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1016 (setq item (speedbar-line-path (string-to-int (match-string 1))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1017 (if (re-search-forward "> \\([^ ]+\\)$"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1018 (save-excursion(end-of-line)(point)) t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1019 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1020 (setq attr (get-text-property (match-beginning 1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1021 'speedbar-token))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1022 (message "Tag %s in %s at position %s"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1023 (match-string 1) item (if attr attr 0)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1024 (message "No special info for this line.")))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1025 ))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1026
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1027 (defun speedbar-item-copy ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1028 "Copy the item under the cursor.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1029 Files can be copied to new names or places."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1030 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1031 (let ((f (speedbar-line-file)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1032 (if (not f) (error "Not a file."))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1033 (if (file-directory-p f)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1034 (error "Cannot copy directory.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1035 (let* ((rt (read-file-name (format "Copy %s to: "
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1036 (file-name-nondirectory f))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1037 (file-name-directory f)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1038 (refresh (member (expand-file-name (file-name-directory rt))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1039 speedbar-shown-directories)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1040 ;; Create the right file name part
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1041 (if (file-directory-p rt)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1042 (setq rt
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1043 (concat (expand-file-name rt)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1044 (if (string-match "/$" rt) "" "/")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1045 (file-name-nondirectory f))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1046 (if (or (not (file-exists-p rt))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1047 (y-or-n-p (format "Overwrite %s with %s? " rt f)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1048 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1049 (copy-file f rt t t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1050 ;; refresh display if the new place is currently displayed.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1051 (if refresh
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1052 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1053 (speedbar-refresh)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1054 (if (not (speedbar-goto-this-file rt))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1055 (speedbar-goto-this-file f))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1056 ))))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1057
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1058 (defun speedbar-item-rename ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1059 "Rename the item under the cursor or mouse.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1060 Files can be renamed to new names or moved to new directories."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1061 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1062 (let ((f (speedbar-line-file)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1063 (if f
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1064 (let* ((rt (read-file-name (format "Rename %s to: "
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1065 (file-name-nondirectory f))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1066 (file-name-directory f)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1067 (refresh (member (expand-file-name (file-name-directory rt))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1068 speedbar-shown-directories)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1069 ;; Create the right file name part
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1070 (if (file-directory-p rt)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1071 (setq rt
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1072 (concat (expand-file-name rt)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1073 (if (string-match "/$" rt) "" "/")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1074 (file-name-nondirectory f))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1075 (if (or (not (file-exists-p rt))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1076 (y-or-n-p (format "Overwrite %s with %s? " rt f)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1077 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1078 (rename-file f rt t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1079 ;; refresh display if the new place is currently displayed.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1080 (if refresh
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1081 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1082 (speedbar-refresh)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1083 (speedbar-goto-this-file rt)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1084 )))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1085 (error "Not a file."))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1086
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1087 (defun speedbar-item-delete ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1088 "Delete the item under the cursor. Files are removed from disk."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1089 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1090 (let ((f (speedbar-line-file)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1091 (if (not f) (error "Not a file."))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1092 (if (y-or-n-p (format "Delete %s? " f))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1093 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1094 (if (file-directory-p f)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1095 (delete-directory f)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1096 (delete-file f))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1097 (message "Okie dokie..")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1098 (let ((p (point)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1099 (speedbar-refresh)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1100 (goto-char p))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1101 ))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1102 ))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1103
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1104 (defun speedbar-enable-update ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1105 "Enable automatic updating in speedbar via timers."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1106 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1107 (setq speedbar-update-flag t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1108 (speedbar-set-mode-line-format)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1109 (speedbar-set-timer speedbar-update-speed))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1110
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1111 (defun speedbar-disable-update ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1112 "Disable automatic updating and stop consuming resources."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1113 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1114 (setq speedbar-update-flag nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1115 (speedbar-set-mode-line-format)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1116 (speedbar-set-timer nil))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1117
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1118 (defun speedbar-toggle-updates ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1119 "Toggle automatic update for the speedbar frame."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1120 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1121 (if speedbar-update-flag
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1122 (speedbar-disable-update)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1123 (speedbar-enable-update)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1124
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1125 (defun speedbar-toggle-show-all-files ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1126 "Toggle display of files speedbar can not tag."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1127 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1128 (setq speedbar-show-unknown-files (not speedbar-show-unknown-files))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1129 (speedbar-refresh))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1130
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1131 ;;; Utility functions
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1132 ;;
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1133 (defun speedbar-set-timer (timeout)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1134 "Unset an old timer (if there is one) and activate a new timer with TIMEOUT.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1135 TIMEOUT is the number of seconds until the speedbar timer is called
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1136 again."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1137 (cond
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1138 ;; Xemacs
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1139 (speedbar-xemacsp
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1140 (if speedbar-timer
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1141 (progn (delete-itimer speedbar-timer)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1142 (setq speedbar-timer nil)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1143 (if timeout
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1144 (setq speedbar-timer (start-itimer "speedbar"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1145 'speedbar-timer-fn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1146 timeout
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1147 nil))))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1148 ;; Post 19.31 Emacs
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1149 ((fboundp 'run-with-idle-timer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1150 (if speedbar-timer
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1151 (progn (cancel-timer speedbar-timer)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1152 (setq speedbar-timer nil)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1153 (if timeout
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1154 (setq speedbar-timer
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1155 (run-with-idle-timer timeout nil 'speedbar-timer-fn))))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1156 ;; Older or other Emacsen with no timers. Set up so that it's
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1157 ;; obvious this emacs can't handle the updates
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1158 (t
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1159 (setq speedbar-update-flag nil)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1160 ;; change this if it changed for some reason
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1161 (speedbar-set-mode-line-format))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1162
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1163 (defmacro speedbar-with-writable (&rest forms)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1164 "Allow the buffer to be writable and evaluate FORMS.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1165 Turn read only back on when done."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1166 (list 'let '((speedbar-with-writable-buff (current-buffer)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1167 '(toggle-read-only -1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1168 (cons 'progn forms)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1169 '(save-excursion (set-buffer speedbar-with-writable-buff)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1170 (toggle-read-only 1))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1171 (put 'speedbar-with-writable 'lisp-indent-function 0)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1172
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1173 (defun speedbar-select-window (buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1174 "Select a window in which BUFFER is show.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1175 If it is not shown, force it to appear in the default window."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1176 (let ((win (get-buffer-window buffer speedbar-attached-frame)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1177 (if win
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1178 (select-window win)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1179 (show-buffer (selected-window) buffer))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1180
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1181 (defmacro speedbar-with-attached-buffer (&rest forms)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1182 "Execute FORMS in the attached frame's special buffer.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1183 Optionally select that frame if necessary."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1184 ;; Reset the timer with a new timeout when cliking a file
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1185 ;; in case the user was navigating directories, we can cancel
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1186 ;; that other timer.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1187 (list
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1188 'progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1189 '(speedbar-set-timer speedbar-update-speed)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1190 (list
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1191 'let '((cf (selected-frame)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1192 '(select-frame speedbar-attached-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1193 '(speedbar-select-window speedbar-desired-buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1194 (cons 'progn forms)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1195 '(select-frame cf)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1196 '(speedbar-maybee-jump-to-attached-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1197 )))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1198
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1199 (defun speedbar-insert-button (text face mouse function
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1200 &optional token prevline)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1201 "Insert TEXT as the next logical speedbar button.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1202 FACE is the face to put on the button, MOUSE is the highlight face to use.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1203 When the user clicks on TEXT, FUNCTION is called with the TOKEN parameter.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1204 This function assumes that the current buffer is the speedbar buffer.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1205 If PREVLINE, then put this button on the previous line.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1206
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1207 This is a convenience function for special mode that create their own
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1208 specialized speedbar displays."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1209 (goto-char (point-max))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1210 (if (/= (current-column) 0) (insert "\n"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1211 (if prevline (progn (delete-char -1) (insert " "))) ;back up if desired...
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1212 (let ((start (point)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1213 (insert text)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1214 (speedbar-make-button start (point) face mouse function token))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1215 (let ((start (point)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1216 (insert "\n")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1217 (put-text-property start (point) 'face nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1218 (put-text-property start (point) 'mouse-face nil)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1219
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1220 (defun speedbar-make-button (start end face mouse function &optional token)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1221 "Create a button from START to END, with FACE as the display face.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1222 MOUSE is the mouse face. When this button is clicked on FUNCTION
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1223 will be run with the TOKEN parameter (any lisp object)"
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1224 (put-text-property start end 'face face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1225 (put-text-property start end 'mouse-face mouse)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1226 (put-text-property start end 'invisible nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1227 (if function (put-text-property start end 'speedbar-function function))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1228 (if token (put-text-property start end 'speedbar-token token))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1229 )
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1230
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1231 ;;; File button management
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1232 ;;
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1233 (defun speedbar-file-lists (directory)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1234 "Create file lists for DIRECTORY.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1235 The car is the list of directories, the cdr is list of files not
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1236 matching ignored headers. Cache any directory files found in
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1237 `speedbar-directory-contents-alist' and use that cache before scanning
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1238 the file-system"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1239 (setq directory (expand-file-name directory))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1240 ;; If in powerclick mode, then the directory we are getting
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1241 ;; should be rescanned.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1242 (if speedbar-power-click
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1243 (adelete 'speedbar-directory-contents-alist directory))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1244 ;; find the directory, either in the cache, or build it.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1245 (or (cdr-safe (assoc directory speedbar-directory-contents-alist))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1246 (let ((default-directory directory)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1247 (dir (directory-files directory nil))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1248 (dirs nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1249 (files nil))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1250 (while dir
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1251 (if (not (string-match speedbar-file-unshown-regexp (car dir)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1252 (if (file-directory-p (car dir))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1253 (setq dirs (cons (car dir) dirs))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1254 (setq files (cons (car dir) files))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1255 (setq dir (cdr dir)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1256 (let ((nl (cons (nreverse dirs) (list (nreverse files)))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1257 (aput 'speedbar-directory-contents-alist directory nl)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1258 nl))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1259 ))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1260
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1261 (defun speedbar-directory-buttons (directory index)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1262 "Insert a single button group at point for DIRECTORY.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1263 Each directory path part is a different button. If part of the path
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1264 matches the user directory ~, then it is replaced with a ~.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1265 INDEX is not used, but is required by the caller."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1266 (let* ((tilde (expand-file-name "~"))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1267 (dd (expand-file-name directory))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1268 (junk (string-match (regexp-quote tilde) dd))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1269 (displayme (if junk
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1270 (concat "~" (substring dd (match-end 0)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1271 dd))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1272 (p (point)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1273 (if (string-match "^~/?$" displayme) (setq displayme (concat tilde "/")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1274 (insert displayme)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1275 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1276 (goto-char p)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1277 (while (re-search-forward "\\([^/]+\\)/" nil t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1278 (speedbar-make-button (match-beginning 1) (match-end 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1279 'speedbar-directory-face
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1280 'speedbar-highlight-face
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1281 'speedbar-directory-buttons-follow
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1282 (if (= (match-beginning 1) p)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1283 (expand-file-name "~/") ;the tilde
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1284 (buffer-substring-no-properties
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1285 p (match-end 0)))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1286 ;; Nuke the beginning of the directory if it's too long...
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1287 (cond ((eq speedbar-directory-button-trim-method 'span)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1288 (beginning-of-line)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1289 (let ((ww (or (speedbar-frame-width) 20)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1290 (move-to-column ww nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1291 (while (>= (current-column) ww)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1292 (re-search-backward "/" nil t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1293 (if (<= (current-column) 2)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1294 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1295 (re-search-forward "/" nil t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1296 (if (< (current-column) 4)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1297 (re-search-forward "/" nil t))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1298 (forward-char -1)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1299 (if (looking-at "/?$")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1300 (beginning-of-line)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1301 (insert "/...\n ")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1302 (move-to-column ww nil)))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1303 ((eq speedbar-directory-button-trim-method 'trim)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1304 (end-of-line)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1305 (let ((ww (or (speedbar-frame-width) 20))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1306 (tl (current-column)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1307 (if (< ww tl)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1308 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1309 (move-to-column (- tl ww))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1310 (if (re-search-backward "/" nil t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1311 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1312 (delete-region (point-min) (point))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1313 (insert "$")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1314 )))))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1315 )
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1316 (if (string-match "^/[^/]+/$" displayme)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1317 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1318 (insert " ")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1319 (let ((p (point)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1320 (insert "<root>")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1321 (speedbar-make-button p (point)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1322 'speedbar-directory-face
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1323 'speedbar-highlight-face
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1324 'speedbar-directory-buttons-follow
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1325 "/"))))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1326 (end-of-line)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1327 (insert-char ?\n 1 nil)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1328
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1329 (defun speedbar-make-tag-line (exp-button-type
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1330 exp-button-char exp-button-function
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1331 exp-button-data
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1332 tag-button tag-button-function tag-button-data
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1333 tag-button-face depth)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1334 "Create a tag line with EXP-BUTTON-TYPE for the small expansion button.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1335 This is the button that expands or contracts a node (if applicable),
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1336 and EXP-BUTTON-CHAR the character in it (+, -, ?, etc). EXP-BUTTON-FUNCTION
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1337 is the function to call if it's clicked on. Button types are
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1338 'bracket, 'angle, 'curly, or nil. EXP-BUTTON-DATA is extra data
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1339 attached to the text forming the expansion button.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1340
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1341 Next, TAG-BUTTON is the text of the tag. TAG-BUTTON-FUNCTION is the
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1342 function to call if clicked on, and TAG-BUTTON-DATA is the data to
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1343 attach to the text field (such a tag positioning, etc).
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1344 TAG-BUTTON-FACE is a face used for this type of tag.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1345
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1346 Lastly, DEPTH shows the depth of expansion.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1347
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1348 This function assumes that the cursor is in the speedbar window at the
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1349 position to insert a new item, and that the new item will end with a CR"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1350 (let ((start (point))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1351 (end (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1352 (insert (int-to-string depth) ":")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1353 (point))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1354 (put-text-property start end 'invisible t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1355 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1356 (insert-char ? depth nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1357 (put-text-property (- (point) depth) (point) 'invisible nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1358 (let* ((exp-button (cond ((eq exp-button-type 'bracket) "[%c]")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1359 ((eq exp-button-type 'angle) "<%c>")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1360 ((eq exp-button-type 'curly) "{%c}")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1361 (t ">")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1362 (buttxt (format exp-button exp-button-char))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1363 (start (point))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1364 (end (progn (insert buttxt) (point)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1365 (bf (if exp-button-type 'speedbar-button-face nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1366 (mf (if exp-button-function 'speedbar-highlight-face nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1367 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1368 (speedbar-make-button start end bf mf exp-button-function exp-button-data)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1369 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1370 (insert-char ? 1 nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1371 (put-text-property (1- (point)) (point) 'invisible nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1372 (let ((start (point))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1373 (end (progn (insert tag-button) (point))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1374 (insert-char ?\n 1 nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1375 (put-text-property (1- (point)) (point) 'invisible nil)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1376 (speedbar-make-button start end tag-button-face
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1377 (if tag-button-function 'speedbar-highlight-face nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1378 tag-button-function tag-button-data))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1379 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1380
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1381 (defun speedbar-change-expand-button-char (char)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1382 "Change the expansion button character to CHAR for the current line."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1383 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1384 (beginning-of-line)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1385 (if (re-search-forward ":\\s-*.\\([-+?]\\)" (save-excursion (end-of-line)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1386 (point)) t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1387 (speedbar-with-writable
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1388 (goto-char (match-beginning 1))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1389 (delete-char 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1390 (insert-char char 1 t)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1391
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1392
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1393 ;;; Build button lists
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1394 ;;
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1395 (defun speedbar-insert-files-at-point (files level)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1396 "Insert list of FILES starting at point, and indenting all files to LEVEL.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1397 Tag expandable items with a +, otherwise a ?. Don't highlight ? as we
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1398 don't know how to manage them. The input parameter FILES is a cons
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1399 cell of the form ( 'DIRLIST . 'FILELIST )"
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1400 ;; Start inserting all the directories
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1401 (let ((dirs (car files)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1402 (while dirs
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1403 (speedbar-make-tag-line 'angle ?+ 'speedbar-dired (car dirs)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1404 (car dirs) 'speedbar-dir-follow nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1405 'speedbar-directory-face level)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1406 (setq dirs (cdr dirs))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1407 (let ((lst (car (cdr files))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1408 (while lst
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1409 (let* ((known (string-match speedbar-file-regexp (car lst)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1410 (expchar (if known ?+ ??))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1411 (fn (if known 'speedbar-tag-file nil)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1412 (if (or speedbar-show-unknown-files (/= expchar ??))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1413 (speedbar-make-tag-line 'bracket expchar fn (car lst)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1414 (car lst) 'speedbar-find-file nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1415 'speedbar-file-face level)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1416 (setq lst (cdr lst)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1417
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1418 (defun speedbar-default-directory-list (directory index)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1419 "Insert files for DIRECTORY with level INDEX at point."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1420 (speedbar-insert-files-at-point
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1421 (speedbar-file-lists directory) index)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1422 (speedbar-reset-scanners)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1423 (if (= index 0)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1424 ;; If the shown files variable has extra directories, then
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1425 ;; it is our responsibility to redraw them all
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1426 ;; Luckilly, the nature of inserting items into this list means
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1427 ;; that by reversing it, we can easilly go in the right order
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1428 (let ((sf (cdr (reverse speedbar-shown-directories))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1429 (setq speedbar-shown-directories
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1430 (list (expand-file-name default-directory)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1431 ;; exand them all as we find them
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1432 (while sf
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1433 (if (speedbar-goto-this-file (car sf))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1434 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1435 (beginning-of-line)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1436 (if (looking-at "[0-9]+:[ ]*<")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1437 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1438 (goto-char (match-end 0))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1439 (speedbar-do-function-pointer)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1440 (setq sf (cdr sf)))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1441 )))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1442
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1443 (defun speedbar-insert-generic-list (level lst expand-fun find-fun)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1444 "At LEVEL, insert a generic multi-level alist LST.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1445 Associations with lists get {+} tags (to expand into more nodes) and
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1446 those with positions just get a > as the indicator. {+} buttons will
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1447 have the function EXPAND-FUN and the token is the CDR list. The token
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1448 name will have the function FIND-FUN and not token."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1449 ;; Remove imenu rescan button
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1450 (if (string= (car (car lst)) "*Rescan*")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1451 (setq lst (cdr lst)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1452 ;; insert the parts
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1453 (while lst
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1454 (cond ((null (car-safe lst)) nil) ;this would be a separator
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1455 ((or (numberp (cdr-safe (car-safe lst)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1456 (markerp (cdr-safe (car-safe lst))))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1457 (speedbar-make-tag-line nil nil nil nil ;no expand button data
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1458 (car (car lst)) ;button name
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1459 find-fun ;function
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1460 (cdr (car lst)) ;token is position
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1461 'speedbar-tag-face
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1462 (1+ level)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1463 ((listp (cdr-safe (car-safe lst)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1464 (speedbar-make-tag-line 'curly ?+ expand-fun (cdr (car lst))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1465 (car (car lst)) ;button name
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1466 nil nil 'speedbar-tag-face
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1467 (1+ level)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1468 (t (message "Ooops!")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1469 (setq lst (cdr lst))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1470
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1471 ;;; Timed functions
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1472 ;;
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1473 (defun speedbar-update-contents ()
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1474 "Generically update the contents of the speedbar buffer."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1475 (interactive)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1476 ;; Set the current special buffer
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1477 (setq speedbar-desired-buffer nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1478 (if (and speedbar-mode-specific-contents-flag
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1479 speedbar-special-mode-expansion-list
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1480 (local-variable-p
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1481 'speedbar-special-mode-expansion-list))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1482 ;(eq (get major-mode 'mode-class 'special)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1483 (speedbar-update-special-contents)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1484 (speedbar-update-directory-contents)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1485
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1486 (defun speedbar-update-directory-contents ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1487 "Update the contents of the speedbar buffer based on the current directory."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1488 (let ((cbd (expand-file-name default-directory))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1489 (funclst speedbar-initial-expansion-list)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1490 (cache speedbar-full-text-cache)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1491 ;; disable stealth during update
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1492 (speedbar-stealthy-function-list nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1493 (use-cache nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1494 ;; Because there is a bug I can't find just yet
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1495 (inhibit-quit nil))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1496 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1497 (set-buffer speedbar-buffer)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1498 ;; If we are updating contents to a where we are, then this is
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1499 ;; really a request to update existing contents, so we must be
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1500 ;; careful with our text cache!
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1501 (if (member cbd speedbar-shown-directories)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1502 (setq cache nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1503 ;; If this directory is NOT in the current list of available
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1504 ;; paths, then use the cache, and set the cache to our new
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1505 ;; value. Make sure to unhighlight the current file, or if we
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1506 ;; come back to this directory, it might be a different file
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1507 ;; and then we get a mess!
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1508 (if (> (point-max) 1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1509 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1510 (speedbar-clear-current-file)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1511 (setq speedbar-full-text-cache
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1512 (cons speedbar-shown-directories (buffer-string)))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1513
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1514 ;; Check if our new directory is in the list of directories
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1515 ;; show in the text-cahce
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1516 (if (member cbd (car cache))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1517 (setq speedbar-shown-directories (car cache)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1518 use-cache t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1519 ;; default the shown directories to this list...
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1520 (setq speedbar-shown-directories (list cbd)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1521 )
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1522 (setq speedbar-last-selected-file nil)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1523 (speedbar-with-writable
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1524 (setq default-directory cbd)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1525 (erase-buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1526 (if use-cache
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1527 (insert (cdr cache))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1528 (while funclst
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1529 (funcall (car funclst) cbd 0)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1530 (setq funclst (cdr funclst)))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1531 (goto-char (point-min))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1532 (speedbar-reconfigure-menubar))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1533
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1534 (defun speedbar-update-special-contents ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1535 "Used the mode-specific variable to fill in the speedbar buffer.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1536 This should only be used by modes classified as special."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1537 (let ((funclst speedbar-special-mode-expansion-list)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1538 (specialbuff (current-buffer)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1539 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1540 (setq speedbar-desired-buffer specialbuff)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1541 (set-buffer speedbar-buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1542 ;; If we are leaving a directory, cache it.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1543 (if (not speedbar-shown-directories)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1544 ;; Do nothing
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1545 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1546 ;; Clean up directory maintenance stuff
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1547 (speedbar-clear-current-file)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1548 (setq speedbar-full-text-cache
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1549 (cons speedbar-shown-directories (buffer-string))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1550 speedbar-shown-directories nil))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1551 ;; Now fill in the buffer with our newly found specialized list.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1552 (speedbar-with-writable
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1553 (while funclst
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1554 ;; We do not erase the buffer because these functions may
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1555 ;; decide NOT to update themselves.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1556 (funcall (car funclst) specialbuff)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1557 (setq funclst (cdr funclst))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1558 (goto-char (point-min))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1559 (speedbar-reconfigure-menubar))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1560
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1561 (defun speedbar-timer-fn ()
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1562 "Run whenever emacs is idle to update the speedbar item."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1563 (if (not (and (frame-live-p speedbar-frame)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1564 (frame-live-p speedbar-attached-frame)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1565 (speedbar-set-timer nil)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1566 (condition-case nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1567 ;; Save all the match data so that we don't mess up executing fns
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1568 (save-match-data
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1569 (if (and (frame-visible-p speedbar-frame) speedbar-update-flag)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1570 (let ((af (selected-frame)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1571 (save-window-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1572 (select-frame speedbar-attached-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1573 ;; make sure we at least choose a window to
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1574 ;; get a good directory from
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1575 (if (string-match "\\*Minibuf-[0-9]+\\*" (buffer-name))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1576 (other-window 1))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1577 ;; Update for special mode all the time!
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1578 (if (and speedbar-mode-specific-contents-flag
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1579 speedbar-special-mode-expansion-list
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1580 (local-variable-p
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1581 'speedbar-special-mode-expansion-list))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1582 ;(eq (get major-mode 'mode-class 'special)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1583 (speedbar-update-special-contents)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1584 ;; Update all the contents if directories change!
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1585 (if (or (member (expand-file-name default-directory)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1586 speedbar-shown-directories)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1587 (string-match speedbar-ignored-path-regexp
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1588 (expand-file-name default-directory))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1589 (member major-mode speedbar-ignored-modes)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1590 (eq af speedbar-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1591 (not (buffer-file-name)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1592 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1593 (if (<= 1 speedbar-verbosity-level)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1594 (message "Updating speedbar to: %s..."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1595 default-directory))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1596 (speedbar-update-directory-contents)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1597 (if (<= 1 speedbar-verbosity-level)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1598 (message "Updating speedbar to: %s...done"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1599 default-directory))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1600 (select-frame af))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1601 ;; Now run stealthy updates of time-consuming items
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1602 (speedbar-stealthy-updates))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1603 ;; errors that might occur
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1604 (error (message "Speedbar error!")))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1605 ;; Reset the timer
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1606 (speedbar-set-timer speedbar-update-speed))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1607 (run-hooks 'speedbar-timer-hook)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1608 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1609
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1610
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1611 ;;; Stealthy activities
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1612 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1613 (defun speedbar-stealthy-updates ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1614 "For a given speedbar, run all items in the stealthy function list.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1615 Each item returns t if it completes successfully, or nil if
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1616 interrupted by the user."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1617 (let ((l speedbar-stealthy-function-list))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1618 (unwind-protect
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1619 (while (and l (funcall (car l)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1620 (sit-for 0)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1621 (setq l (cdr l)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1622 ;(message "Exit with %S" (car l))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1623 )))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1624
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1625 (defun speedbar-reset-scanners ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1626 "Reset any variables used by functions in the stealthy list as state.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1627 If new functions are added, their state needs to be updated here."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1628 (setq speedbar-vc-to-do-point t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1629 )
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1630
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1631 (defun speedbar-clear-current-file ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1632 "Locate the file thought to be current, and unhighlight it."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1633 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1634 (set-buffer speedbar-buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1635 (if speedbar-last-selected-file
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1636 (speedbar-with-writable
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1637 (goto-char (point-min))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1638 (if (and
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1639 speedbar-last-selected-file
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1640 (re-search-forward
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1641 (concat " \\(" (regexp-quote speedbar-last-selected-file)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1642 "\\)\\(" (regexp-quote speedbar-vc-indicator)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1643 "\\)?\n")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1644 nil t))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1645 (put-text-property (match-beginning 1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1646 (match-end 1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1647 'face
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1648 'speedbar-file-face))))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1649
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1650 (defun speedbar-update-current-file ()
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1651 "Find the current file is, and update our visuals to indicate its name.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1652 This is specific to file names. If the file name doesn't show up, but
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1653 it should be in the list, then the directory cache needs to be
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1654 updated."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1655 (let* ((lastf (selected-frame))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1656 (newcfd (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1657 (select-frame speedbar-attached-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1658 (let ((rf (if (buffer-file-name)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1659 (buffer-file-name)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1660 nil)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1661 (select-frame lastf)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1662 rf)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1663 (newcf (if newcfd (file-name-nondirectory newcfd)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1664 (lastb (current-buffer))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1665 (sucf-recursive (boundp 'sucf-recursive)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1666 (if (and newcf
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1667 ;; check here, that way we won't refresh to newcf until
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1668 ;; its been written, thus saving ourselves some time
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1669 (file-exists-p newcf)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1670 (not (string= newcf speedbar-last-selected-file)))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1671 (progn
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1672 ;; It is important to select the frame, otherwise the window
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1673 ;; we want the cursor to move in will not be updated by the
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1674 ;; search-forward command.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1675 (select-frame speedbar-frame)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1676 ;; Remove the old file...
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1677 (speedbar-clear-current-file)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1678 ;; now highlight the new one.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1679 (set-buffer speedbar-buffer)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1680 (speedbar-with-writable
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1681 (goto-char (point-min))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1682 (if (re-search-forward
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1683 (concat " \\(" (regexp-quote newcf) "\\)\\("
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1684 (regexp-quote speedbar-vc-indicator)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1685 "\\)?\n") nil t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1686 ;; put the property on it
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1687 (put-text-property (match-beginning 1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1688 (match-end 1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1689 'face
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1690 'speedbar-selected-face)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1691 ;; Oops, it's not in the list. Should it be?
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1692 (if (and (string-match speedbar-file-regexp newcf)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1693 (string= (file-name-directory newcfd)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1694 (expand-file-name default-directory)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1695 ;; yes, it is (we will ignore unknowns for now...)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1696 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1697 (speedbar-refresh)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1698 (if (re-search-forward
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1699 (concat " \\(" (regexp-quote newcf) "\\)\n") nil t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1700 ;; put the property on it
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1701 (put-text-property (match-beginning 1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1702 (match-end 1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1703 'face
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1704 'speedbar-selected-face)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1705 ;; if it's not in there now, whatever...
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1706 ))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1707 (setq speedbar-last-selected-file newcf))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1708 (if (not sucf-recursive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1709 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1710 (forward-line -1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1711 (speedbar-position-cursor-on-line)))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1712 (set-buffer lastb)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1713 (select-frame lastf)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1714 )))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1715 ;; return that we are done with this activity.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1716 t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1717
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1718 ;; If it's being used, check for it
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1719 (eval-when-compile (or (featurep 'xemacs) (require 'ange-ftp)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1720
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1721 (defun speedbar-check-vc ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1722 "Scan all files in a directory, and for each see if it's checked out.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1723 See `speedbar-this-file-in-vc' and `speedbar-vc-check-dir-p' for how
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1724 to add more types of version control systems."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1725 ;; Check for to-do to be reset. If reset but no RCS is available
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1726 ;; then set to nil (do nothing) otherwise, start at the beginning
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1727 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1728 (set-buffer speedbar-buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1729 (if (and speedbar-vc-do-check (eq speedbar-vc-to-do-point t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1730 (speedbar-vc-check-dir-p default-directory)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1731 (not (and (featurep 'ange-ftp)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1732 (string-match (car
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1733 (if speedbar-xemacsp
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1734 ange-ftp-path-format
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1735 ange-ftp-name-format))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1736 (expand-file-name default-directory)))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1737 (setq speedbar-vc-to-do-point 0))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1738 (if (numberp speedbar-vc-to-do-point)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1739 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1740 (goto-char speedbar-vc-to-do-point)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1741 (while (and (not (input-pending-p))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1742 (re-search-forward "^\\([0-9]+\\):\\s-*\\[[+-]\\] " nil t))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1743 (setq speedbar-vc-to-do-point (point))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1744 (if (speedbar-check-vc-this-line)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1745 (speedbar-with-writable
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1746 (insert speedbar-vc-indicator))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1747 (if (input-pending-p)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1748 ;; return that we are incomplete
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1749 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1750 ;; we are done, set to-do to nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1751 (setq speedbar-vc-to-do-point nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1752 ;; and return t
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1753 t))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1754 t)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1755
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1756 (defun speedbar-check-vc-this-line ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1757 "Return t if the file on this line is check of of a version control system.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1758 The one caller-requirement is that the last regexp matching operation
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1759 has the current depth stored in (MATCHSTRING 1), and that the cursor
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1760 is right in front of the file name."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1761 (let* ((d (string-to-int (match-string 1)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1762 (f (speedbar-line-path d))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1763 (fn (buffer-substring-no-properties
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1764 (point) (progn (end-of-line) (point))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1765 (fulln (concat f fn)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1766 (if (<= 2 speedbar-verbosity-level)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1767 (message "Speedbar vc check...%s" fulln))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1768 (and (file-writable-p fulln)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1769 (speedbar-this-file-in-vc f fn))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1770
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1771 (defun speedbar-vc-check-dir-p (path)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1772 "Return t if we should bother checking PATH for version control files.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1773 This can be overloaded to add new types of version control systems."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1774 (or
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1775 (file-exists-p (concat path "RCS/"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1776 ;; If SCCS is added in `speedbar-this-file-in-vc'
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1777 ;; (file-exists-p (concat path "SCCS/"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1778 ;; (file-exists-p (getenv "SCCSPATHTHINGIDONTREMEMBER"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1779 ))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1780
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1781 (defun speedbar-this-file-in-vc (path name)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1782 "Check to see if the file in PATH with NAME is in a version control system.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1783 You can add new VC systems by overriding this function. You can
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1784 optimize this function by overriding it and only doing those checks
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1785 that will occur on your system."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1786 (or
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1787 (file-exists-p (concat path "RCS/" name ",v"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1788 ;; Is this right? I don't recall
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1789 ;;(file-exists-p (concat path "SCCS/," fn))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1790 ;;(file-exists-p (concat (getenv "SCCSPATHTHING") "/SCCS/," fn))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1791 ))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1792
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1793 ;;; Clicking Activity
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1794 ;;
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1795 (defun speedbar-quick-mouse (e)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1796 "Since mouse events are strange, this will keep the mouse nicely positioned.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1797 This should be bound to mouse event E."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1798 (interactive "e")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1799 (mouse-set-point e)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1800 (speedbar-position-cursor-on-line)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1801 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1802
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1803 (defun speedbar-position-cursor-on-line ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1804 "Position the cursor on a line."
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1805 (let ((oldpos (point)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1806 (beginning-of-line)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1807 (if (looking-at "[0-9]+:\\s-*..?.? ")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1808 (goto-char (1- (match-end 0)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1809 (goto-char oldpos))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1810
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1811 (defun speedbar-power-click (e)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1812 "Activate any speedbar button as a power click.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1813 This should be bound to mouse event E."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1814 (interactive "e")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1815 (let ((speedbar-power-click t))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1816 (speedbar-click e)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1817
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1818 (defun speedbar-click (e)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1819 "Activate any speedbar buttons where the mouse is clicked.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1820 This must be bound to a mouse event. A button is any location of text
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1821 with a mouse face that has a text property called `speedbar-function'.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1822 This should be bound to mouse event E."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1823 (interactive "e")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1824 (mouse-set-point e)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1825 (speedbar-do-function-pointer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1826 (speedbar-quick-mouse e))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1827
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1828 (defun speedbar-do-function-pointer ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1829 "Look under the cursor and examine the text properties.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1830 From this extract the file/tag name, token, indentation level and call
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1831 a function if appropriate"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1832 (let* ((fn (get-text-property (point) 'speedbar-function))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1833 (tok (get-text-property (point) 'speedbar-token))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1834 ;; The 1-,+ is safe because scaning starts AFTER the point
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1835 ;; specified. This lets the search include the character the
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1836 ;; cursor is on.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1837 (tp (previous-single-property-change
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1838 (1+ (point)) 'speedbar-function))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1839 (np (next-single-property-change
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1840 (point) 'speedbar-function))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1841 (txt (buffer-substring-no-properties (or tp (point-min))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1842 (or np (point-max))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1843 (dent (save-excursion (beginning-of-line)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1844 (string-to-number
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1845 (if (looking-at "[0-9]+")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1846 (buffer-substring-no-properties
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1847 (match-beginning 0) (match-end 0))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1848 "0")))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1849 ;;(message "%S:%S:%S:%s" fn tok txt dent)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1850 (and fn (funcall fn txt tok dent)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1851 (speedbar-position-cursor-on-line))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1852
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1853 ;;; Reading info from the speedbar buffer
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1854 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1855 (defun speedbar-line-file (&optional p)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1856 "Retrieve the file or whatever from the line at P point.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1857 The return value is a string representing the file. If it is a
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1858 directory, then it is the directory name."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1859 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1860 (save-match-data
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1861 (beginning-of-line)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1862 (if (looking-at (concat
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1863 "\\([0-9]+\\): *[[<][-+][]>] \\([^ \n]+\\)\\("
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1864 (regexp-quote speedbar-vc-indicator)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1865 "\\)?"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1866 (let* ((depth (string-to-int (match-string 1)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1867 (path (speedbar-line-path depth))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1868 (f (match-string 2)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1869 (concat path f))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1870 nil))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1871
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1872 (defun speedbar-goto-this-file (file)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1873 "If FILE is displayed, goto this line and return t.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1874 Otherwise do not move and return nil."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1875 (let ((path (substring (file-name-directory (expand-file-name file))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1876 (length (expand-file-name default-directory))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1877 (dest (point)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1878 (save-match-data
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1879 (goto-char (point-min))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1880 ;; scan all the directories
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1881 (while (and path (not (eq path t)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1882 (if (string-match "^/?\\([^/]+\\)" path)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1883 (let ((pp (match-string 1 path)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1884 (if (save-match-data
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1885 (re-search-forward (concat "> " (regexp-quote pp) "$")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1886 nil t))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1887 (setq path (substring path (match-end 1)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1888 (setq path nil)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1889 (setq path t)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1890 ;; find the file part
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1891 (if (or (not path) (string= (file-name-nondirectory file) ""))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1892 ;; only had a dir part
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1893 (if path
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1894 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1895 (speedbar-position-cursor-on-line)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1896 t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1897 (goto-char dest) nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1898 ;; find the file part
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1899 (let ((nd (file-name-nondirectory file)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1900 (if (re-search-forward
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1901 (concat "] \\(" (regexp-quote nd)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1902 "\\)\\(" (regexp-quote speedbar-vc-indicator) "\\)?$")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1903 nil t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1904 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1905 (speedbar-position-cursor-on-line)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1906 t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1907 (goto-char dest)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1908 nil))))))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1909
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1910 (defun speedbar-line-path (depth)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1911 "Retrieve the pathname associated with the current line.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1912 This may require traversing backwards from DEPTH and combining the default
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1913 directory with these items."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1914 (save-excursion
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1915 (save-match-data
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1916 (let ((path nil))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1917 (setq depth (1- depth))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1918 (while (/= depth -1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1919 (if (not (re-search-backward (format "^%d:" depth) nil t))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1920 (error "Error building path of tag")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1921 (cond ((looking-at "[0-9]+:\\s-*<->\\s-+\\([^\n]+\\)$")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1922 (setq path (concat (buffer-substring-no-properties
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1923 (match-beginning 1) (match-end 1))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1924 "/"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1925 path)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1926 ((looking-at "[0-9]+:\\s-*[-]\\s-+\\([^\n]+\\)$")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1927 ;; This is the start of our path.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1928 (setq path (buffer-substring-no-properties
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1929 (match-beginning 1) (match-end 1))))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1930 (setq depth (1- depth)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1931 (if (and path
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1932 (string-match (concat (regexp-quote speedbar-vc-indicator) "$")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1933 path))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1934 (setq path (substring path 0 (match-beginning 0))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1935 (concat default-directory path)))))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1936
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1937 (defun speedbar-edit-line ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1938 "Edit whatever tag or file is on the current speedbar line."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1939 (interactive)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1940 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1941 (beginning-of-line)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1942 ;; If this fails, then it is a non-standard click, and as such,
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1943 ;; perfectly allowed.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1944 (re-search-forward "[]>}] [a-zA-Z0-9]"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1945 (save-excursion (end-of-line) (point)) t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1946 (speedbar-do-function-pointer)))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1947
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1948 (defun speedbar-expand-line ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1949 "Expand the line under the cursor."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1950 (interactive)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1951 (beginning-of-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1952 (re-search-forward ":\\s-*.\\+. " (save-excursion (end-of-line) (point)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1953 (forward-char -2)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1954 (speedbar-do-function-pointer))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1955
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1956 (defun speedbar-contract-line ()
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1957 "Contract the line under the cursor."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1958 (interactive)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1959 (beginning-of-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1960 (re-search-forward ":\\s-*.-. " (save-excursion (end-of-line) (point)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1961 (forward-char -2)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1962 (speedbar-do-function-pointer))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1963
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1964 (defun speedbar-maybee-jump-to-attached-frame ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1965 "Jump to the attached frame ONLY if this was not a mouse event."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1966 (if (numberp last-input-char)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1967 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1968 (select-frame speedbar-attached-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1969 (other-frame 0))))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1970
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1971 (defun speedbar-find-file (text token indent)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1972 "Speedbar click handler for filenames.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1973 TEXT, the file will be displayed in the attached frame.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1974 TOKEN is unused, but required by the click handler. INDENT is the
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1975 current indentation level."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1976 (let ((cdd (speedbar-line-path indent)))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1977 (speedbar-find-file-in-frame (concat cdd text))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1978 (speedbar-stealthy-updates)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1979 ;; Reset the timer with a new timeout when cliking a file
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1980 ;; in case the user was navigating directories, we can cancel
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1981 ;; that other timer.
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1982 (speedbar-set-timer speedbar-update-speed))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1983 (speedbar-maybee-jump-to-attached-frame))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1984
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1985 (defun speedbar-dir-follow (text token indent)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1986 "Speedbar click handler for directory names.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1987 Clicking a directory will cause the speedbar to list files in the
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1988 the subdirectory TEXT. TOKEN is an unused requirement. The
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1989 subdirectory chosen will be at INDENT level."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1990 (setq default-directory
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1991 (concat (expand-file-name (concat (speedbar-line-path indent) text))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1992 "/"))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1993 ;; Because we leave speedbar as the current buffer,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1994 ;; update contents will change directory without
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1995 ;; having to touch the attached frame.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1996 (speedbar-update-contents)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1997 (speedbar-set-timer speedbar-navigating-speed)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1998 (setq speedbar-last-selected-file nil)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1999 (speedbar-stealthy-updates))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2000
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2001 (defun speedbar-delete-subblock (indent)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2002 "Delete text from point to indentation level INDENT or greater.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2003 Handles end-of-sublist smartly."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2004 (speedbar-with-writable
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2005 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2006 (end-of-line) (forward-char 1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2007 (while (and (not (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2008 (re-search-forward (format "^%d:" indent)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2009 nil t)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2010 (>= indent 0))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2011 (setq indent (1- indent)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2012 (delete-region (point) (if (>= indent 0)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2013 (match-beginning 0)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2014 (point-max))))))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2015
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2016 (defun speedbar-dired (text token indent)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2017 "Speedbar click handler for directory expand button.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2018 Clicking this button expands or contracts a directory. TEXT is the
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2019 button clicked which has either a + or -. TOKEN is the directory to be
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2020 expanded. INDENT is the current indentation level."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2021 (cond ((string-match "+" text) ;we have to expand this dir
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2022 (setq speedbar-shown-directories
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2023 (cons (expand-file-name
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2024 (concat (speedbar-line-path indent) token "/"))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2025 speedbar-shown-directories))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2026 (speedbar-change-expand-button-char ?-)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2027 (speedbar-reset-scanners)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2028 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2029 (end-of-line) (forward-char 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2030 (speedbar-with-writable
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2031 (speedbar-default-directory-list
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2032 (concat (speedbar-line-path indent) token "/")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2033 (1+ indent)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2034 ((string-match "-" text) ;we have to contract this node
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2035 (speedbar-reset-scanners)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2036 (let ((oldl speedbar-shown-directories)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2037 (newl nil)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2038 (td (expand-file-name
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2039 (concat (speedbar-line-path indent) token))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2040 (while oldl
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2041 (if (not (string-match (concat "^" (regexp-quote td)) (car oldl)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2042 (setq newl (cons (car oldl) newl)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2043 (setq oldl (cdr oldl)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2044 (setq speedbar-shown-directories newl))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2045 (speedbar-change-expand-button-char ?+)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2046 (speedbar-delete-subblock indent)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2047 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2048 (t (error "Ooops... not sure what to do.")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2049 (speedbar-center-buffer-smartly)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2050 (setq speedbar-last-selected-file nil)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2051 (save-excursion (speedbar-stealthy-updates)))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2052
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2053 (defun speedbar-directory-buttons-follow (text token indent)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2054 "Speedbar click handler for default directory buttons.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2055 TEXT is the button clicked on. TOKEN is the directory to follow.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2056 INDENT is the current indentation level and is unused."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2057 (setq default-directory token)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2058 ;; Because we leave speedbar as the current buffer,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2059 ;; update contents will change directory without
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2060 ;; having to touch the attached frame.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2061 (speedbar-update-contents)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2062 (speedbar-set-timer speedbar-navigating-speed))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2063
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2064 (defun speedbar-tag-file (text token indent)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2065 "The cursor is on a selected line. Expand the tags in the specified file.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2066 The parameter TEXT and TOKEN are required, where TEXT is the button
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2067 clicked, and TOKEN is the file to expand. INDENT is the current
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2068 indentation level."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2069 (cond ((string-match "+" text) ;we have to expand this file
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2070 (let* ((fn (expand-file-name (concat (speedbar-line-path indent)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2071 token)))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2072 (lst (if speedbar-use-imenu-flag
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2073 (let ((tim (speedbar-fetch-dynamic-imenu fn)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2074 (if (eq tim t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2075 (speedbar-fetch-dynamic-etags fn)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2076 tim))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2077 (speedbar-fetch-dynamic-etags fn))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2078 ;; if no list, then remove expando button
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2079 (if (not lst)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2080 (speedbar-change-expand-button-char ??)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2081 (speedbar-change-expand-button-char ?-)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2082 (speedbar-with-writable
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2083 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2084 (end-of-line) (forward-char 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2085 (speedbar-insert-generic-list indent
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2086 lst 'speedbar-tag-expand
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2087 'speedbar-tag-find))))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2088 ((string-match "-" text) ;we have to contract this node
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2089 (speedbar-change-expand-button-char ?+)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2090 (speedbar-delete-subblock indent))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2091 (t (error "Ooops... not sure what to do.")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2092 (speedbar-center-buffer-smartly))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2093
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2094 (defun speedbar-tag-find (text token indent)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2095 "For the tag TEXT in a file TOKEN, goto that position.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2096 INDENT is the current indentation level."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2097 (let ((file (speedbar-line-path indent)))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2098 (speedbar-find-file-in-frame file)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2099 (save-excursion (speedbar-stealthy-updates))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2100 ;; Reset the timer with a new timeout when cliking a file
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2101 ;; in case the user was navigating directories, we can cancel
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2102 ;; that other timer.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2103 (speedbar-set-timer speedbar-update-speed)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2104 (goto-char token)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2105 ;;(recenter)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2106 (speedbar-maybee-jump-to-attached-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2107 ))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2108
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2109 (defun speedbar-tag-expand (text token indent)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2110 "Expand a tag sublist. Imenu will return sub-lists of specialized tag types.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2111 Etags does not support this feature. TEXT will be the button
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2112 string. TOKEN will be the list, and INDENT is the current indentation
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2113 level."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2114 (cond ((string-match "+" text) ;we have to expand this file
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2115 (speedbar-change-expand-button-char ?-)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2116 (speedbar-with-writable
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2117 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2118 (end-of-line) (forward-char 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2119 (speedbar-insert-generic-list indent
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2120 token 'speedbar-tag-expand
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2121 'speedbar-tag-find))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2122 ((string-match "-" text) ;we have to contract this node
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2123 (speedbar-change-expand-button-char ?+)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2124 (speedbar-delete-subblock indent))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2125 (t (error "Ooops... not sure what to do.")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2126 (speedbar-center-buffer-smartly))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2127
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2128 ;;; Loading files into the attached frame.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2129 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2130 (defun speedbar-find-file-in-frame (file)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2131 "This will load FILE into the speedbar attached frame.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2132 If the file is being displayed in a different frame already, then raise that
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2133 frame instead."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2134 (let* ((buff (find-file-noselect file))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2135 (bwin (get-buffer-window buff 0)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2136 (if bwin
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2137 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2138 (select-window bwin)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2139 (raise-frame (window-frame bwin)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2140 (if speedbar-power-click
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2141 (let ((pop-up-frames t)) (select-window (display-buffer buff)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2142 (select-frame speedbar-attached-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2143 (switch-to-buffer buff))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2144 )
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2145
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2146 ;;; Centering Utility
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2147 ;;
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2148 (defun speedbar-center-buffer-smartly ()
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2149 "Recenter a speedbar buffer so the current indentation level is all visible.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2150 This assumes that the cursor is on a file, or tag of a file which the user is
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2151 interested in."
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2152 (if (<= (count-lines (point-min) (point-max))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2153 (window-height (selected-window)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2154 ;; whole buffer fits
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2155 (let ((cp (point)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2156 (goto-char (point-min))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2157 (recenter 0)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2158 (goto-char cp))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2159 ;; too big
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2160 (let (depth start end exp p)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2161 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2162 (beginning-of-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2163 (setq depth (if (looking-at "[0-9]+")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2164 (string-to-int (buffer-substring-no-properties
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2165 (match-beginning 0) (match-end 0)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2166 0))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2167 (setq exp (format "^%d:\\s-*[[{<]\\([?+-]\\)[]>}]" depth)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2168 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2169 (end-of-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2170 (if (re-search-backward exp nil t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2171 (setq start (point))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2172 (error "Center error"))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2173 (save-excursion ;Not sure about this part.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2174 (end-of-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2175 (setq p (point))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2176 (while (and (not (re-search-forward exp nil t))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2177 (>= depth 0))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2178 (setq depth (1- depth))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2179 (setq exp (format "^%d:\\s-*[[{<]\\([?+-]\\)[]>}]" depth)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2180 (if (/= (point) p)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2181 (setq end (point))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2182 (setq end (point-max)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2183 ;; Now work out the details of centering
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2184 (let ((nl (count-lines start end))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2185 (cp (point)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2186 (if (> nl (window-height (selected-window)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2187 ;; We can't fit it all, so just center on cursor
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2188 (progn (goto-char start)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2189 (recenter 1))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2190 ;; we can fit everything on the screen, but...
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2191 (if (and (pos-visible-in-window-p start (selected-window))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2192 (pos-visible-in-window-p end (selected-window)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2193 ;; we are all set!
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2194 nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2195 ;; we need to do something...
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2196 (goto-char start)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2197 (let ((newcent (/ (- (window-height (selected-window)) nl) 2))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2198 (lte (count-lines start (point-max))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2199 (if (and (< (+ newcent lte) (window-height (selected-window)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2200 (> (- (window-height (selected-window)) lte 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2201 newcent))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2202 (setq newcent (- (window-height (selected-window))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2203 lte 1)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2204 (recenter newcent))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2205 (goto-char cp)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2206
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2207
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2208 ;;; Tag Management -- Imenu
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2209 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2210 (if (string-match "XEmacs" emacs-version)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2211
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2212 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2213
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2214 (eval-when-compile (if (locate-library "imenu") (require 'imenu)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2215
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2216 (defun speedbar-fetch-dynamic-imenu (file)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2217 "Load FILE into a buffer, and generate tags using Imenu.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2218 Returns the tag list, or t for an error."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2219 ;; Load this AND compile it in
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2220 (require 'imenu)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2221 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2222 (set-buffer (find-file-noselect file))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2223 (condition-case nil
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2224 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2225 (if speedbar-power-click (setq imenu--index-alist nil))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2226 (imenu--make-index-alist t))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2227 (error t))))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2228 )
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2229
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2230 ;;; Tag Management -- etags (XEmacs compatibility part)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2231 ;;
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2232 (defvar speedbar-fetch-etags-parse-list
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2233 '(;; Note that java has the same parse-group as c
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2234 ("\\.\\([cChH]\\|c++\\|cpp\\|cc\\|hh\\|java\\)$" . speedbar-parse-c-or-c++tag)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2235 ("\\.el\\|\\.emacs" . "defun\\s-+\\(\\(\\w\\|[-_]\\)+\\)\\s-*\C-?")
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2236 ("\\.tex$" . speedbar-parse-tex-string)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2237 ("\\.p" .
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2238 "\\(\\(FUNCTION\\|function\\|PROCEDURE\\|procedure\\)\\s-+\\([a-zA-Z0-9_.:]+\\)\\)\\s-*(?^?")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2239
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2240 )
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2241 "Associations of file extensions and expressions for extracting tags.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2242 To add a new file type, you would want to add a new association to the
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2243 list, where the car is the file match, and the cdr is the way to
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2244 extract an element from the tags output. If the output is complex,
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2245 use a function symbol instead of regexp. The function should expect
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2246 to be at the beginning of a line in the etags buffer.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2247
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2248 This variable is ignored if `speedbar-use-imenu-flag' is t")
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2249
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2250 (defvar speedbar-fetch-etags-command "etags"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2251 "*Command used to create an etags file.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2252
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2253 This variable is ignored if `speedbar-use-imenu-flag' is t")
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2254
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2255 (defvar speedbar-fetch-etags-arguments '("-D" "-I" "-o" "-")
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2256 "*List of arguments to use with `speedbar-fetch-etags-command'.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2257 This creates an etags output buffer. Use `speedbar-toggle-etags' to
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2258 modify this list conveniently.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2259
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2260 This variable is ignored if `speedbar-use-imenu-flag' is t")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2261
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2262 (defun speedbar-toggle-etags (flag)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2263 "Toggle FLAG in `speedbar-fetch-etags-arguments'.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2264 FLAG then becomes a member of etags command line arguments. If flag
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2265 is \"sort\", then toggle the value of `speedbar-sort-tags'. If it's
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2266 value is \"show\" then toggle the value of
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2267 `speedbar-show-unknown-files'.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2268
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2269 This function is a convenience function for XEmacs menu created by
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2270 Farzin Guilak <farzin@protocol.com>"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2271 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2272 (cond
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2273 ((equal flag "sort")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2274 (setq speedbar-sort-tags (not speedbar-sort-tags)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2275 ((equal flag "show")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2276 (setq speedbar-show-unknown-files (not speedbar-show-unknown-files)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2277 ((or (equal flag "-C")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2278 (equal flag "-S")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2279 (equal flag "-D"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2280 (if (member flag speedbar-fetch-etags-arguments)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2281 (setq speedbar-fetch-etags-arguments
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2282 (delete flag speedbar-fetch-etags-arguments))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2283 (add-to-list 'speedbar-fetch-etags-arguments flag)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2284 (t nil)))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2285
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2286 (defun speedbar-fetch-dynamic-etags (file)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2287 "For FILE, run etags and create a list of symbols extracted.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2288 Each symbol will be associated with it's line position in FILE."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2289 (let ((newlist nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2290 (unwind-protect
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2291 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2292 (if (get-buffer "*etags tmp*")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2293 (kill-buffer "*etags tmp*")) ;kill to clean it up
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2294 (if (<= 1 speedbar-verbosity-level) (message "Fetching etags..."))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2295 (set-buffer (get-buffer-create "*etags tmp*"))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2296 (apply 'call-process speedbar-fetch-etags-command nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2297 (current-buffer) nil
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2298 (append speedbar-fetch-etags-arguments (list file)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2299 (goto-char (point-min))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2300 (if (<= 1 speedbar-verbosity-level) (message "Fetching etags..."))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2301 (let ((expr
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2302 (let ((exprlst speedbar-fetch-etags-parse-list)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2303 (ans nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2304 (while (and (not ans) exprlst)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2305 (if (string-match (car (car exprlst)) file)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2306 (setq ans (car exprlst)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2307 (setq exprlst (cdr exprlst)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2308 (cdr ans))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2309 (if expr
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2310 (let (tnl)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2311 (while (not (save-excursion (end-of-line) (eobp)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2312 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2313 (setq tnl (speedbar-extract-one-symbol expr)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2314 (if tnl (setq newlist (cons tnl newlist)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2315 (forward-line 1)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2316 (message "Sorry, no support for a file of that extension"))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2317 )
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2318 (if speedbar-sort-tags
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2319 (sort newlist (lambda (a b) (string< (car a) (car b))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2320 (reverse newlist))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2321
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2322 ;; This bit donated by Farzin Guilak <farzin@protocol.com> but I'm not
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2323 ;; sure it's needed with the different sorting method.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2324 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2325 ;(defun speedbar-clean-etags()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2326 ; "Removes spaces before the ^? character, and removes `#define',
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2327 ;return types, etc. preceding tags. This ensures that the sort operation
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2328 ;works on the tags, not the return types."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2329 ; (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2330 ; (goto-char (point-min))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2331 ; (while
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2332 ; (re-search-forward "(?[ \t](?\C-?" nil t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2333 ; (replace-match "\C-?" nil nil))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2334 ; (goto-char (point-min))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2335 ; (while
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2336 ; (re-search-forward "\\(.*[ \t]+\\)\\([^ \t\n]+.*\C-?\\)" nil t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2337 ; (delete-region (match-beginning 1) (match-end 1)))))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2338
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2339 (defun speedbar-extract-one-symbol (expr)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2340 "At point, return nil, or one alist in the form: ( symbol . position )
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2341 The line should contain output from etags. Parse the output using the
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2342 regular expression EXPR"
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2343 (let* ((sym (if (stringp expr)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2344 (if (save-excursion
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2345 (re-search-forward expr (save-excursion
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2346 (end-of-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2347 (point)) t))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2348 (buffer-substring-no-properties (match-beginning 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2349 (match-end 1)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2350 (funcall expr)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2351 (pos (let ((j (re-search-forward "[\C-?\C-a]\\([0-9]+\\),\\([0-9]+\\)"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2352 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2353 (end-of-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2354 (point))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2355 t)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2356 (if (and j sym)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2357 (1+ (string-to-int (buffer-substring-no-properties
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2358 (match-beginning 2)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2359 (match-end 2))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2360 0))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2361 (if (/= pos 0)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2362 (cons sym pos)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2363 nil)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2364
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2365 (defun speedbar-parse-c-or-c++tag ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2366 "Parse a c or c++ tag, which tends to be a little complex."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2367 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2368 (let ((bound (save-excursion (end-of-line) (point))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2369 (cond ((re-search-forward "\C-?\\([^\C-a]+\\)\C-a" bound t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2370 (buffer-substring-no-properties (match-beginning 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2371 (match-end 1)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2372 ((re-search-forward "\\<\\([^ \t]+\\)\\s-+new(" bound t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2373 (buffer-substring-no-properties (match-beginning 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2374 (match-end 1)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2375 ((re-search-forward "\\<\\([^ \t(]+\\)\\s-*(\C-?" bound t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2376 (buffer-substring-no-properties (match-beginning 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2377 (match-end 1)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2378 (t nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2379 )))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2380
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2381 (defun speedbar-parse-tex-string ()
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2382 "Parse a Tex string. Only find data which is relevant."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2383 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2384 (let ((bound (save-excursion (end-of-line) (point))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2385 (cond ((re-search-forward "\\(section\\|chapter\\|cite\\)\\s-*{[^\C-?}]*}?" bound t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2386 (buffer-substring-no-properties (match-beginning 0)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2387 (match-end 0)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2388 (t nil)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2389
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2390
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2391 ;;; Color loading section This is messy *Blech!*
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2392 ;;
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2393 (defun speedbar-load-color (sym l-fg l-bg d-fg d-bg &optional bold italic underline)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2394 "Create a color for SYM with a L-FG and L-BG color, or D-FG and D-BG.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2395 Optionally make BOLD, ITALIC, or UNDERLINE if applicable. If the background
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2396 attribute of the current frame is determined to be light (white, for example)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2397 then L-FG and L-BG is used. If not, then D-FG and D-BG is used. This will
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2398 allocate the colors in the best possible manor. This will allow me to store
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2399 multiple defaults and dynamically determine which colors to use."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2400 (let* ((params (frame-parameters))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2401 (disp-res (if (fboundp 'x-get-resource)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2402 (if speedbar-xemacsp
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2403 (x-get-resource ".displayType" "DisplayType" 'string)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2404 (x-get-resource ".displayType" "DisplayType"))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2405 nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2406 (display-type
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2407 (cond (disp-res (intern (downcase disp-res)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2408 ((and (fboundp 'x-display-color-p) (x-display-color-p)) 'color)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2409 (t 'mono)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2410 (bg-res (if (fboundp 'x-get-resource)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2411 (if speedbar-xemacsp
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2412 (x-get-resource ".backgroundMode" "BackgroundMode" 'string)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2413 (x-get-resource ".backgroundMode" "BackgroundMode"))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2414 nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2415 (bgmode
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2416 (cond (bg-res (intern (downcase bg-res)))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2417 ((let* ((bgc (or (cdr (assq 'background-color params))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2418 (if speedbar-xemacsp
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2419 (x-get-resource ".background"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2420 "Background" 'string)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2421 (x-get-resource ".background"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2422 "Background"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2423 ;; if no other options, default is white
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2424 "white"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2425 (bgcr (if speedbar-xemacsp
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2426 (color-instance-rgb-components
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2427 (make-color-instance bgc))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2428 (x-color-values bgc)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2429 (wcr (if speedbar-xemacsp
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2430 (color-instance-rgb-components
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2431 (make-color-instance "white"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2432 (x-color-values "white"))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2433 (< (apply '+ bgcr) (/ (apply '+ wcr) 3)))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2434 'dark)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2435 (t 'light))) ;our default
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2436 (set-p (function (lambda (face-name resource)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2437 (if speedbar-xemacsp
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2438 (x-get-resource
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2439 (concat face-name ".attribute" resource)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2440 (concat "Face.Attribute" resource)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2441 'string)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2442 (x-get-resource
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2443 (concat face-name ".attribute" resource)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2444 (concat "Face.Attribute" resource)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2445 )))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2446 (nbg (cond ((eq bgmode 'dark) d-bg)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2447 (t l-bg)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2448 (nfg (cond ((eq bgmode 'dark) d-fg)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2449 (t l-fg))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2450
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2451 (if (not (eq display-type 'color))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2452 ;; we need a face of some sort, so just make due with default
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2453 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2454 (copy-face 'default sym)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2455 (if bold (condition-case nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2456 (make-face-bold sym)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2457 (error (message "Cannot make face %s bold!"
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2458 (symbol-name sym)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2459 (if italic (condition-case nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2460 (make-face-italic sym)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2461 (error (message "Cannot make face %s italic!"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2462 (symbol-name sym)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2463 (set-face-underline-p sym underline)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2464 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2465 ;; make a colorized version of a face. Be sure to check Xdefaults
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2466 ;; for possible overrides first!
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2467 (let ((newface (make-face sym)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2468 ;; For each attribute, check if it might already be set by Xdefaults
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2469 (if (and nfg (not (funcall set-p (symbol-name sym) "Foreground")))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2470 (set-face-foreground newface nfg))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2471 (if (and nbg (not (funcall set-p (symbol-name sym) "Background")))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2472 (set-face-background newface nbg))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2473
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2474 (if bold (condition-case nil
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2475 (make-face-bold newface)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2476 (error (message "Cannot make face %s bold!"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2477 (symbol-name sym)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2478 (if italic (condition-case nil
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2479 (make-face-italic newface)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2480 (error (message "Cannot make face %s italic!"
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2481 (symbol-name newface)))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2482 (set-face-underline-p newface underline)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2483 ))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2484
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2485 (if (x-display-color-p)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2486 (progn
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2487 (speedbar-load-color 'speedbar-button-face "green4" nil "green3" nil nil nil nil)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2488 (speedbar-load-color 'speedbar-file-face "cyan4" nil "cyan" nil nil nil nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2489 (speedbar-load-color 'speedbar-directory-face "blue4" nil "light blue" nil nil nil nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2490 (speedbar-load-color 'speedbar-tag-face "brown" nil "yellow" nil nil nil nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2491 (speedbar-load-color 'speedbar-selected-face "red" nil "red" nil nil nil t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2492 (speedbar-load-color 'speedbar-highlight-face nil "green" nil "sea green" nil nil nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2493 ) ; color
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2494 (make-face 'speedbar-button-face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2495 ;;(make-face 'speedbar-file-face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2496 (copy-face 'bold 'speedbar-file-face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2497 (make-face 'speedbar-directory-face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2498 (make-face 'speedbar-tag-face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2499 ;;(make-face 'speedbar-selected-face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2500 (copy-face 'underline 'speedbar-selected-face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2501 ;;(make-face 'speedbar-highlight-face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2502 (copy-face 'highlight 'speedbar-highlight-face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2503
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2504 ) ;; monochrome
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2505
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2506 ;; some edebug hooks
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2507 (add-hook 'edebug-setup-hook
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2508 (lambda ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2509 (def-edebug-spec speedbar-with-writable def-body)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2510
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2511 ;; run load-time hooks
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2512 (run-hooks 'speedbar-load-hook)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2513
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2514 (provide 'speedbar)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2515 ;;; speedbar ends here