annotate lisp/utils/speedbar.el @ 205:92f8ad5d0d3f r20-4b1

Import from CVS: tag r20-4b1
author cvs
date Mon, 13 Aug 2007 10:02:46 +0200
parents 850242ba4a81
children
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
203
850242ba4a81 Import from CVS: tag r20-3b28
cvs
parents: 177
diff changeset
8 ;; X-RCS: $Id: speedbar.el,v 1.4 1997/10/12 01:39:54 steve Exp $
167
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
203
850242ba4a81 Import from CVS: tag r20-3b28
cvs
parents: 177
diff changeset
301 ;; XEmacs timers aren't based on idleness. Therefore tune it down a little
100
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
203
850242ba4a81 Import from CVS: tag r20-3b28
cvs
parents: 177
diff changeset
313 ;; XEmacs fails to delete speedbar
167
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 ;;
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 167
diff changeset
675 ;;;###autoload
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
676 (defalias 'speedbar 'speedbar-frame-mode)
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 167
diff changeset
677 ;;;###autoload
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
678 (defun speedbar-frame-mode (&optional arg)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
679 "Enable or disable speedbar. Positive ARG means turn on, negative turn off.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
680 nil means toggle. Once the speedbar frame is activated, a buffer in
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
681 `speedbar-mode' will be displayed. Currently, only one speedbar is
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
682 supported at a time."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
683 (interactive "P")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
684 (if (not window-system)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
685 (error "Speedbar is not useful outside of a windowing environment"))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
686 ;; toggle frame on and off.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
687 (if (not arg) (if speedbar-frame (setq arg -1) (setq arg 1)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
688 ;; turn the frame off on neg number
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
689 (if (and (numberp arg) (< arg 0))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
690 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
691 (run-hooks 'speedbar-before-delete-hook)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
692 (if (and speedbar-frame (frame-live-p speedbar-frame))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
693 (if speedbar-xemacsp
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
694 (delete-frame speedbar-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
695 (setq speedbar-cached-frame speedbar-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
696 (modify-frame-parameters speedbar-frame '((visibility . nil)))))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
697 (setq speedbar-frame nil)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
698 (speedbar-set-timer nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
699 ;; Used to delete the buffer. This has the annoying affect of
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
700 ;; preventing whatever took it's place from ever appearing
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
701 ;; as the default after a C-x b was typed
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
702 ;;(if (bufferp speedbar-buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
703 ;; (kill-buffer speedbar-buffer))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
704 )
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
705 ;; Set this as our currently attached frame
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
706 (setq speedbar-attached-frame (selected-frame))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
707 ;; Get the frame to work in
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
708 (if (frame-live-p speedbar-cached-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
709 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
710 (setq speedbar-frame speedbar-cached-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
711 (modify-frame-parameters speedbar-frame '((visibility . t)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
712 ;; Get the buffer to play with
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
713 (speedbar-mode)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
714 (select-frame speedbar-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
715 (if (not (eq (current-buffer) speedbar-buffer))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
716 (switch-to-buffer speedbar-buffer))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
717 (set-window-dedicated-p (selected-window) t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
718 (raise-frame speedbar-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
719 (speedbar-set-timer speedbar-update-speed)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
720 )
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
721 (if (frame-live-p speedbar-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
722 (raise-frame speedbar-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
723 (let ((params (cons (cons 'height (frame-height))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
724 speedbar-frame-parameters)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
725 (setq speedbar-frame
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 167
diff changeset
726 (if (or speedbar-xemacsp
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 167
diff changeset
727 (< emacs-major-version 20)) ;a bug is fixed in v20 & later
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
728 (make-frame params)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
729 (let ((x-pointer-shape x-pointer-top-left-arrow)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
730 (x-sensitive-text-pointer-shape x-pointer-hand2))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
731 (make-frame params)))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
732 ;; reset the selection variable
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
733 (setq speedbar-last-selected-file nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
734 ;; Put the buffer into the frame
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
735 (save-window-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
736 ;; Get the buffer to play with
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
737 (speedbar-mode)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
738 (select-frame speedbar-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
739 (switch-to-buffer speedbar-buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
740 (set-window-dedicated-p (selected-window) t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
741 ;; Turn off toolbar and menubar under XEmacs
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
742 (if speedbar-xemacsp
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
743 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
744 (set-specifier default-toolbar-visible-p
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
745 (cons (selected-frame) nil))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
746 ;; These lines make the menu-bar go away nicely, but
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
747 ;; they also cause xemacs much heartache.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
748 ;;(set-specifier menubar-visible-p (cons (selected-frame) nil))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
749 ;;(make-local-variable 'current-menubar)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
750 ;;(setq current-menubar speedbar-menu)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
751 ;;(add-submenu nil speedbar-menu nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
752 )))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
753 (speedbar-set-timer speedbar-update-speed)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
754 ))))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
755
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
756 (defun speedbar-close-frame ()
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
757 "Turn off a currently active speedbar."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
758 (interactive)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
759 (speedbar-frame-mode -1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
760 (select-frame speedbar-attached-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
761 (other-frame 0))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
762
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
763 (defun speedbar-frame-width ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
764 "Return the width of the speedbar frame in characters.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
765 nil if it doesn't exist."
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 167
diff changeset
766 (and speedbar-frame
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 167
diff changeset
767 (frame-live-p speedbar-frame)
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 167
diff changeset
768 (cdr (assoc 'width (frame-parameters speedbar-frame)))))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
769
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
770 (defun speedbar-mode ()
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
771 "Major mode for managing a display of directories and tags.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
772 \\<speedbar-key-map>
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
773 The first line represents the default path of the speedbar frame.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
774 Each directory segment is a button which jumps speedbar's default
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
775 directory to that path. Buttons are activated by clicking `\\[speedbar-click]'.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
776 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
777 rescan cached items, or pop up new frames.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
778
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
779 Each line starting with <+> represents a directory. Click on the <+>
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
780 to insert the directory listing into the current tree. Click on the
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
781 <-> to retract that list. Click on the directory name to go to that
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
782 directory as the default.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
783
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
784 Each line starting with [+] is a file. If the variable
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
785 `speedbar-show-unknown-files' is t, the lines starting with [?] are
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
786 files which don't have imenu support, but are not expressly ignored.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
787 Files are completely ignored if they match `speedbar-file-unshown-regexp'
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
788 which is generated from `completion-ignored-extensions'.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
789
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
790 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
791 version control system. (currently only RCS is supported.) New
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
792 version control systems can be added by examining the documentation
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
793 for `speedbar-this-file-in-vc' and `speedbar-vc-check-dir-p'
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
794
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
795 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
796 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
797 in the attached frame.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
798
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
799 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
800 category of tags. Click the {+} to expand the category. Jump-able
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
801 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
802 in the selected file.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
803
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
804 \\{speedbar-key-map}"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
805 ;; NOT interactive
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
806 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
807 (setq speedbar-buffer (set-buffer (get-buffer-create " SPEEDBAR")))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
808 (kill-all-local-variables)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
809 (setq major-mode 'speedbar-mode)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
810 (setq mode-name "Speedbar")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
811 (use-local-map speedbar-key-map)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
812 (set-syntax-table speedbar-syntax-table)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
813 (setq font-lock-keywords nil) ;; no font-locking please
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
814 (setq truncate-lines t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
815 (make-local-variable 'frame-title-format)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
816 (setq frame-title-format "Speedbar")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
817 ;; Set this up special just for the speedbar buffer
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
818 (if (null default-minibuffer-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
819 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
820 (make-local-variable 'default-minibuffer-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
821 (setq default-minibuffer-frame speedbar-attached-frame)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
822 (make-local-variable 'temp-buffer-show-function)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
823 (setq temp-buffer-show-function 'speedbar-temp-buffer-show-function)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
824 (setq kill-buffer-hook '(lambda () (let ((skilling (boundp 'skilling)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
825 (if skilling
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
826 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
827 (if (eq (current-buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
828 speedbar-buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
829 (speedbar-frame-mode -1))))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
830 (speedbar-set-mode-line-format)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
831 (if (not speedbar-xemacsp)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
832 (setq auto-show-mode nil)) ;no auto-show for Emacs
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
833 (run-hooks 'speedbar-mode-hook))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
834 (speedbar-update-contents)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
835 speedbar-buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
836
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
837 (defun speedbar-set-mode-line-format ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
838 "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
839 This gives visual indications of what is up. It EXPECTS the speedbar
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
840 frame and window to be the currently active frame and window."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
841 (if (frame-live-p speedbar-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
842 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
843 (set-buffer speedbar-buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
844 (let* ((w (or (speedbar-frame-width) 20))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
845 (p1 "<<")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
846 (p5 ">>")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
847 (p3 (if speedbar-update-flag "SPEEDBAR" "SLOWBAR"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
848 (blank (- w (length p1) (length p3) (length p5)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
849 (if line-number-mode 4 0)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
850 (p2 (if (> blank 0)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
851 (make-string (/ blank 2) ? )
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
852 ""))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
853 (p4 (if (> blank 0)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
854 (make-string (+ (/ blank 2) (% blank 2)) ? )
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
855 ""))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
856 (tf
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
857 (if line-number-mode
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
858 (list (concat p1 p2 p3) '(line-number-mode " %3l")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
859 (concat p4 p5))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
860 (list (concat p1 p2 p3 p4 p5)))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
861 (if (not (equal mode-line-format tf))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
862 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
863 (setq mode-line-format tf)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
864 (force-mode-line-update)))))))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
865
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
866 (defun speedbar-temp-buffer-show-function (buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
867 "Placed in the variable `temp-buffer-show-function' in `speedbar-mode'.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
868 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
869 redirected into a window on the attached frame."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
870 (if speedbar-attached-frame (select-frame speedbar-attached-frame))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
871 (pop-to-buffer buffer nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
872 (other-window -1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
873 (run-hooks 'temp-buffer-show-hook))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
874
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
875 (defun speedbar-reconfigure-menubar ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
876 "Reconfigure the menu-bar in a speedbar frame.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
877 Different menu items are displayed depending on the current display mode
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
878 and the existence of packages."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
879 (let ((km (make-sparse-keymap))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
880 (cf (selected-frame))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
881 (md (append speedbar-easymenu-definition-base
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
882 (if speedbar-shown-directories
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
883 ;; file display mode version
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 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
886 (select-frame speedbar-attached-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
887 (if (local-variable-p
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
888 'speedbar-easymenu-definition-special)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
889 ;; If bound locally, we can use it
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
890 speedbar-easymenu-definition-special)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
891 ;; The trailer
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
892 speedbar-easymenu-definition-trailer)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
893 (easy-menu-define speedbar-menu-map speedbar-key-map "Speedbar menu" md)
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 167
diff changeset
894 ;; (if speedbar-xemacsp (set-buffer-menubar (list km)))
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 167
diff changeset
895 ))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
896
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
897
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
898 ;;; User Input stuff
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
899 ;;
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
900 (defun speedbar-mouse-hscroll (e)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
901 "Read a mouse event E from the mode line, and horizontally scroll.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
902 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
903 mode-line. This is only useful for non-XEmacs"
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
904 (interactive "e")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
905 (let* ((xp (car (nth 2 (car (cdr e)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
906 (cpw (/ (frame-pixel-width)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
907 (frame-width)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
908 (oc (1+ (/ xp cpw)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
909 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
910 (cond ((< oc 3)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
911 (scroll-left 2))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
912 ((> oc (- (window-width) 3))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
913 (scroll-right 2))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
914 (t (message "Click on the edge of the modeline to scroll left/right")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
915 ;;(message "X: Pixel %d Char Pixels %d On char %d" xp cpw oc)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
916 ))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
917
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 167
diff changeset
918 ;;;###autoload
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
919 (defun speedbar-get-focus ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
920 "Change frame focus to or from the speedbar frame.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
921 If the selected frame is not speedbar, then speedbar frame is
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
922 selected. If the speedbar frame is active, then select the attached frame."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
923 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
924 (if (eq (selected-frame) speedbar-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
925 (if (frame-live-p speedbar-attached-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
926 (select-frame speedbar-attached-frame))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
927 ;; make sure we have a frame
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
928 (if (not (frame-live-p speedbar-frame)) (speedbar-frame-mode 1))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
929 ;; go there
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
930 (select-frame speedbar-frame))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
931 (other-frame 0))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
932
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
933 (defun speedbar-next (arg)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
934 "Move to the next ARGth line in a speedbar buffer."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
935 (interactive "p")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
936 (forward-line (or arg 1))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
937 (speedbar-item-info)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
938 (speedbar-position-cursor-on-line))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
939
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
940 (defun speedbar-prev (arg)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
941 "Move to the previous ARGth line in a speedbar buffer."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
942 (interactive "p")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
943 (speedbar-next (if arg (- arg) -1)))
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-up (&optional arg)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
946 "Page down 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-up 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-scroll-down (&optional arg)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
952 "Page up one screen-full of the speedbar, or ARG lines."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
953 (interactive "P")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
954 (scroll-down arg)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
955 (speedbar-position-cursor-on-line))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
956
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
957 (defun speedbar-up-directory ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
958 "Keyboard accelerator for moving the default directory up one.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
959 Assumes that the current buffer is the speedbar buffer"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
960 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
961 (setq default-directory (expand-file-name (concat default-directory "../")))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
962 (speedbar-update-contents))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
963
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
964 ;;; Speedbar file activity
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
965 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
966 (defun speedbar-refresh ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
967 "Refresh the current speedbar display, disposing of any cached data."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
968 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
969 (let ((dl speedbar-shown-directories))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
970 (while dl
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
971 (adelete 'speedbar-directory-contents-alist (car dl))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
972 (setq dl (cdr dl))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
973 (if (<= 1 speedbar-verbosity-level) (message "Refreshing speedbar..."))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
974 (speedbar-update-contents)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
975 (speedbar-stealthy-updates)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
976 ;; Reset the timer in case it got really hosed for some reason...
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
977 (speedbar-set-timer speedbar-update-speed)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
978 (if (<= 1 speedbar-verbosity-level) (message "Refreshing speedbar...done")))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
979
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
980 (defun speedbar-item-load ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
981 "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
982 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
983 (let ((f (speedbar-line-file)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
984 (if (and (file-exists-p f) (string-match "\\.el$" f))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
985 (if (and (file-exists-p (concat f "c"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
986 (y-or-n-p (format "Load %sc? " f)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
987 ;; If the compiled version exists, load that instead...
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
988 (load-file (concat f "c"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
989 (load-file f))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
990 (error "Not a loadable file..."))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
991
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
992 (defun speedbar-item-byte-compile ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
993 "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
994 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
995 (let ((f (speedbar-line-file))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
996 (sf (selected-frame)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
997 (if (and (file-exists-p f) (string-match "\\.el$" f))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
998 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
999 (select-frame speedbar-attached-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1000 (byte-compile-file f nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1001 (select-frame sf)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1002 ))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1003
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1004 (defun speedbar-mouse-item-info (event)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1005 "Provide information about what the user clicked on.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1006 This should be bound to a mouse EVENT."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1007 (interactive "e")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1008 (mouse-set-point event)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1009 (speedbar-item-info))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1010
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1011 (defun speedbar-item-info ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1012 "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
1013 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1014 (if (not speedbar-shown-directories)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1015 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1016 (let* ((item (speedbar-line-file))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1017 (attr (if item (file-attributes item) nil)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1018 (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
1019 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1020 (beginning-of-line)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1021 (looking-at "\\([0-9]+\\):")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1022 (setq item (speedbar-line-path (string-to-int (match-string 1))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1023 (if (re-search-forward "> \\([^ ]+\\)$"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1024 (save-excursion(end-of-line)(point)) t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1025 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1026 (setq attr (get-text-property (match-beginning 1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1027 'speedbar-token))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1028 (message "Tag %s in %s at position %s"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1029 (match-string 1) item (if attr attr 0)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1030 (message "No special info for this line.")))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1031 ))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1032
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1033 (defun speedbar-item-copy ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1034 "Copy the item under the cursor.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1035 Files can be copied to new names or places."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1036 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1037 (let ((f (speedbar-line-file)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1038 (if (not f) (error "Not a file."))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1039 (if (file-directory-p f)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1040 (error "Cannot copy directory.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1041 (let* ((rt (read-file-name (format "Copy %s to: "
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1042 (file-name-nondirectory f))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1043 (file-name-directory f)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1044 (refresh (member (expand-file-name (file-name-directory rt))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1045 speedbar-shown-directories)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1046 ;; Create the right file name part
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1047 (if (file-directory-p rt)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1048 (setq rt
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1049 (concat (expand-file-name rt)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1050 (if (string-match "/$" rt) "" "/")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1051 (file-name-nondirectory f))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1052 (if (or (not (file-exists-p rt))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1053 (y-or-n-p (format "Overwrite %s with %s? " rt f)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1054 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1055 (copy-file f rt t t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1056 ;; refresh display if the new place is currently displayed.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1057 (if refresh
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1058 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1059 (speedbar-refresh)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1060 (if (not (speedbar-goto-this-file rt))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1061 (speedbar-goto-this-file f))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1062 ))))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1063
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1064 (defun speedbar-item-rename ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1065 "Rename the item under the cursor or mouse.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1066 Files can be renamed to new names or moved to new directories."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1067 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1068 (let ((f (speedbar-line-file)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1069 (if f
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1070 (let* ((rt (read-file-name (format "Rename %s to: "
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1071 (file-name-nondirectory f))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1072 (file-name-directory f)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1073 (refresh (member (expand-file-name (file-name-directory rt))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1074 speedbar-shown-directories)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1075 ;; Create the right file name part
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1076 (if (file-directory-p rt)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1077 (setq rt
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1078 (concat (expand-file-name rt)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1079 (if (string-match "/$" rt) "" "/")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1080 (file-name-nondirectory f))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1081 (if (or (not (file-exists-p rt))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1082 (y-or-n-p (format "Overwrite %s with %s? " rt f)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1083 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1084 (rename-file f rt t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1085 ;; refresh display if the new place is currently displayed.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1086 (if refresh
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1087 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1088 (speedbar-refresh)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1089 (speedbar-goto-this-file rt)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1090 )))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1091 (error "Not a file."))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1092
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1093 (defun speedbar-item-delete ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1094 "Delete the item under the cursor. Files are removed from disk."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1095 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1096 (let ((f (speedbar-line-file)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1097 (if (not f) (error "Not a file."))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1098 (if (y-or-n-p (format "Delete %s? " f))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1099 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1100 (if (file-directory-p f)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1101 (delete-directory f)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1102 (delete-file f))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1103 (message "Okie dokie..")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1104 (let ((p (point)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1105 (speedbar-refresh)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1106 (goto-char p))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1107 ))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1108 ))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1109
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1110 (defun speedbar-enable-update ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1111 "Enable automatic updating in speedbar via timers."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1112 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1113 (setq speedbar-update-flag t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1114 (speedbar-set-mode-line-format)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1115 (speedbar-set-timer speedbar-update-speed))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1116
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1117 (defun speedbar-disable-update ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1118 "Disable automatic updating and stop consuming resources."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1119 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1120 (setq speedbar-update-flag nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1121 (speedbar-set-mode-line-format)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1122 (speedbar-set-timer nil))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1123
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1124 (defun speedbar-toggle-updates ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1125 "Toggle automatic update for the speedbar frame."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1126 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1127 (if speedbar-update-flag
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1128 (speedbar-disable-update)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1129 (speedbar-enable-update)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1130
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1131 (defun speedbar-toggle-show-all-files ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1132 "Toggle display of files speedbar can not tag."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1133 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1134 (setq speedbar-show-unknown-files (not speedbar-show-unknown-files))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1135 (speedbar-refresh))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1136
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1137 ;;; Utility functions
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1138 ;;
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1139 (defun speedbar-set-timer (timeout)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1140 "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
1141 TIMEOUT is the number of seconds until the speedbar timer is called
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1142 again."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1143 (cond
203
850242ba4a81 Import from CVS: tag r20-3b28
cvs
parents: 177
diff changeset
1144 ;; XEmacs
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1145 (speedbar-xemacsp
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1146 (if speedbar-timer
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1147 (progn (delete-itimer speedbar-timer)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1148 (setq speedbar-timer nil)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1149 (if timeout
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1150 (setq speedbar-timer (start-itimer "speedbar"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1151 'speedbar-timer-fn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1152 timeout
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1153 nil))))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1154 ;; Post 19.31 Emacs
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1155 ((fboundp 'run-with-idle-timer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1156 (if speedbar-timer
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1157 (progn (cancel-timer speedbar-timer)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1158 (setq speedbar-timer nil)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1159 (if timeout
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1160 (setq speedbar-timer
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1161 (run-with-idle-timer timeout nil 'speedbar-timer-fn))))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1162 ;; 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
1163 ;; obvious this emacs can't handle the updates
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1164 (t
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1165 (setq speedbar-update-flag nil)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1166 ;; change this if it changed for some reason
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1167 (speedbar-set-mode-line-format))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1168
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1169 (defmacro speedbar-with-writable (&rest forms)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1170 "Allow the buffer to be writable and evaluate FORMS.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1171 Turn read only back on when done."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1172 (list 'let '((speedbar-with-writable-buff (current-buffer)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1173 '(toggle-read-only -1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1174 (cons 'progn forms)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1175 '(save-excursion (set-buffer speedbar-with-writable-buff)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1176 (toggle-read-only 1))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1177 (put 'speedbar-with-writable 'lisp-indent-function 0)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1178
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1179 (defun speedbar-select-window (buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1180 "Select a window in which BUFFER is show.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1181 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
1182 (let ((win (get-buffer-window buffer speedbar-attached-frame)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1183 (if win
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1184 (select-window win)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1185 (show-buffer (selected-window) buffer))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1186
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1187 (defmacro speedbar-with-attached-buffer (&rest forms)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1188 "Execute FORMS in the attached frame's special buffer.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1189 Optionally select that frame if necessary."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1190 ;; Reset the timer with a new timeout when cliking a file
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1191 ;; in case the user was navigating directories, we can cancel
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1192 ;; that other timer.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1193 (list
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1194 'progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1195 '(speedbar-set-timer speedbar-update-speed)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1196 (list
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1197 'let '((cf (selected-frame)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1198 '(select-frame speedbar-attached-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1199 '(speedbar-select-window speedbar-desired-buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1200 (cons 'progn forms)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1201 '(select-frame cf)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1202 '(speedbar-maybee-jump-to-attached-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1203 )))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1204
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1205 (defun speedbar-insert-button (text face mouse function
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1206 &optional token prevline)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1207 "Insert TEXT as the next logical speedbar button.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1208 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
1209 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
1210 This function assumes that the current buffer is the speedbar buffer.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1211 If PREVLINE, then put this button on the previous line.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1212
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1213 This is a convenience function for special mode that create their own
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1214 specialized speedbar displays."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1215 (goto-char (point-max))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1216 (if (/= (current-column) 0) (insert "\n"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1217 (if prevline (progn (delete-char -1) (insert " "))) ;back up if desired...
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1218 (let ((start (point)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1219 (insert text)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1220 (speedbar-make-button start (point) face mouse function token))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1221 (let ((start (point)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1222 (insert "\n")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1223 (put-text-property start (point) 'face nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1224 (put-text-property start (point) 'mouse-face nil)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1225
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1226 (defun speedbar-make-button (start end face mouse function &optional token)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1227 "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
1228 MOUSE is the mouse face. When this button is clicked on FUNCTION
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1229 will be run with the TOKEN parameter (any lisp object)"
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1230 (put-text-property start end 'face face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1231 (put-text-property start end 'mouse-face mouse)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1232 (put-text-property start end 'invisible nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1233 (if function (put-text-property start end 'speedbar-function function))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1234 (if token (put-text-property start end 'speedbar-token token))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1235 )
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1236
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1237 ;;; File button management
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1238 ;;
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1239 (defun speedbar-file-lists (directory)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1240 "Create file lists for DIRECTORY.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1241 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
1242 matching ignored headers. Cache any directory files found in
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1243 `speedbar-directory-contents-alist' and use that cache before scanning
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1244 the file-system"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1245 (setq directory (expand-file-name directory))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1246 ;; If in powerclick mode, then the directory we are getting
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1247 ;; should be rescanned.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1248 (if speedbar-power-click
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1249 (adelete 'speedbar-directory-contents-alist directory))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1250 ;; find the directory, either in the cache, or build it.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1251 (or (cdr-safe (assoc directory speedbar-directory-contents-alist))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1252 (let ((default-directory directory)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1253 (dir (directory-files directory nil))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1254 (dirs nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1255 (files nil))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1256 (while dir
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1257 (if (not (string-match speedbar-file-unshown-regexp (car dir)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1258 (if (file-directory-p (car dir))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1259 (setq dirs (cons (car dir) dirs))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1260 (setq files (cons (car dir) files))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1261 (setq dir (cdr dir)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1262 (let ((nl (cons (nreverse dirs) (list (nreverse files)))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1263 (aput 'speedbar-directory-contents-alist directory nl)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1264 nl))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1265 ))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1266
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1267 (defun speedbar-directory-buttons (directory index)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1268 "Insert a single button group at point for DIRECTORY.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1269 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
1270 matches the user directory ~, then it is replaced with a ~.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1271 INDEX is not used, but is required by the caller."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1272 (let* ((tilde (expand-file-name "~"))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1273 (dd (expand-file-name directory))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1274 (junk (string-match (regexp-quote tilde) dd))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1275 (displayme (if junk
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1276 (concat "~" (substring dd (match-end 0)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1277 dd))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1278 (p (point)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1279 (if (string-match "^~/?$" displayme) (setq displayme (concat tilde "/")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1280 (insert displayme)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1281 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1282 (goto-char p)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1283 (while (re-search-forward "\\([^/]+\\)/" nil t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1284 (speedbar-make-button (match-beginning 1) (match-end 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1285 'speedbar-directory-face
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1286 'speedbar-highlight-face
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1287 'speedbar-directory-buttons-follow
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1288 (if (= (match-beginning 1) p)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1289 (expand-file-name "~/") ;the tilde
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1290 (buffer-substring-no-properties
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1291 p (match-end 0)))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1292 ;; Nuke the beginning of the directory if it's too long...
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1293 (cond ((eq speedbar-directory-button-trim-method 'span)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1294 (beginning-of-line)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1295 (let ((ww (or (speedbar-frame-width) 20)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1296 (move-to-column ww nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1297 (while (>= (current-column) ww)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1298 (re-search-backward "/" nil t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1299 (if (<= (current-column) 2)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1300 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1301 (re-search-forward "/" nil t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1302 (if (< (current-column) 4)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1303 (re-search-forward "/" nil t))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1304 (forward-char -1)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1305 (if (looking-at "/?$")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1306 (beginning-of-line)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1307 (insert "/...\n ")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1308 (move-to-column ww nil)))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1309 ((eq speedbar-directory-button-trim-method 'trim)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1310 (end-of-line)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1311 (let ((ww (or (speedbar-frame-width) 20))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1312 (tl (current-column)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1313 (if (< ww tl)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1314 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1315 (move-to-column (- tl ww))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1316 (if (re-search-backward "/" nil t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1317 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1318 (delete-region (point-min) (point))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1319 (insert "$")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1320 )))))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1321 )
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1322 (if (string-match "^/[^/]+/$" displayme)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1323 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1324 (insert " ")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1325 (let ((p (point)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1326 (insert "<root>")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1327 (speedbar-make-button p (point)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1328 'speedbar-directory-face
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1329 'speedbar-highlight-face
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1330 'speedbar-directory-buttons-follow
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1331 "/"))))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1332 (end-of-line)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1333 (insert-char ?\n 1 nil)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1334
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1335 (defun speedbar-make-tag-line (exp-button-type
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1336 exp-button-char exp-button-function
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1337 exp-button-data
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1338 tag-button tag-button-function tag-button-data
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1339 tag-button-face depth)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1340 "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
1341 This is the button that expands or contracts a node (if applicable),
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1342 and EXP-BUTTON-CHAR the character in it (+, -, ?, etc). EXP-BUTTON-FUNCTION
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1343 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
1344 'bracket, 'angle, 'curly, or nil. EXP-BUTTON-DATA is extra data
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1345 attached to the text forming the expansion button.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1346
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1347 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
1348 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
1349 attach to the text field (such a tag positioning, etc).
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1350 TAG-BUTTON-FACE is a face used for this type of tag.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1351
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1352 Lastly, DEPTH shows the depth of expansion.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1353
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1354 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
1355 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
1356 (let ((start (point))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1357 (end (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1358 (insert (int-to-string depth) ":")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1359 (point))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1360 (put-text-property start end 'invisible t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1361 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1362 (insert-char ? depth nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1363 (put-text-property (- (point) depth) (point) 'invisible nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1364 (let* ((exp-button (cond ((eq exp-button-type 'bracket) "[%c]")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1365 ((eq exp-button-type 'angle) "<%c>")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1366 ((eq exp-button-type 'curly) "{%c}")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1367 (t ">")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1368 (buttxt (format exp-button exp-button-char))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1369 (start (point))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1370 (end (progn (insert buttxt) (point)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1371 (bf (if exp-button-type 'speedbar-button-face nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1372 (mf (if exp-button-function 'speedbar-highlight-face nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1373 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1374 (speedbar-make-button start end bf mf exp-button-function exp-button-data)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1375 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1376 (insert-char ? 1 nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1377 (put-text-property (1- (point)) (point) 'invisible nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1378 (let ((start (point))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1379 (end (progn (insert tag-button) (point))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1380 (insert-char ?\n 1 nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1381 (put-text-property (1- (point)) (point) 'invisible nil)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1382 (speedbar-make-button start end tag-button-face
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1383 (if tag-button-function 'speedbar-highlight-face nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1384 tag-button-function tag-button-data))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1385 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1386
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1387 (defun speedbar-change-expand-button-char (char)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1388 "Change the expansion button character to CHAR for the current line."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1389 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1390 (beginning-of-line)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1391 (if (re-search-forward ":\\s-*.\\([-+?]\\)" (save-excursion (end-of-line)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1392 (point)) t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1393 (speedbar-with-writable
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1394 (goto-char (match-beginning 1))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1395 (delete-char 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1396 (insert-char char 1 t)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1397
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1398
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1399 ;;; Build button lists
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1400 ;;
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1401 (defun speedbar-insert-files-at-point (files level)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1402 "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
1403 Tag expandable items with a +, otherwise a ?. Don't highlight ? as we
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1404 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
1405 cell of the form ( 'DIRLIST . 'FILELIST )"
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1406 ;; Start inserting all the directories
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1407 (let ((dirs (car files)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1408 (while dirs
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1409 (speedbar-make-tag-line 'angle ?+ 'speedbar-dired (car dirs)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1410 (car dirs) 'speedbar-dir-follow nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1411 'speedbar-directory-face level)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1412 (setq dirs (cdr dirs))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1413 (let ((lst (car (cdr files))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1414 (while lst
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1415 (let* ((known (string-match speedbar-file-regexp (car lst)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1416 (expchar (if known ?+ ??))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1417 (fn (if known 'speedbar-tag-file nil)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1418 (if (or speedbar-show-unknown-files (/= expchar ??))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1419 (speedbar-make-tag-line 'bracket expchar fn (car lst)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1420 (car lst) 'speedbar-find-file nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1421 'speedbar-file-face level)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1422 (setq lst (cdr lst)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1423
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1424 (defun speedbar-default-directory-list (directory index)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1425 "Insert files for DIRECTORY with level INDEX at point."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1426 (speedbar-insert-files-at-point
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1427 (speedbar-file-lists directory) index)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1428 (speedbar-reset-scanners)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1429 (if (= index 0)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1430 ;; If the shown files variable has extra directories, then
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1431 ;; it is our responsibility to redraw them all
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1432 ;; Luckilly, the nature of inserting items into this list means
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1433 ;; that by reversing it, we can easilly go in the right order
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1434 (let ((sf (cdr (reverse speedbar-shown-directories))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1435 (setq speedbar-shown-directories
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1436 (list (expand-file-name default-directory)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1437 ;; exand them all as we find them
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1438 (while sf
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1439 (if (speedbar-goto-this-file (car sf))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1440 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1441 (beginning-of-line)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1442 (if (looking-at "[0-9]+:[ ]*<")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1443 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1444 (goto-char (match-end 0))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1445 (speedbar-do-function-pointer)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1446 (setq sf (cdr sf)))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1447 )))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1448
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1449 (defun speedbar-insert-generic-list (level lst expand-fun find-fun)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1450 "At LEVEL, insert a generic multi-level alist LST.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1451 Associations with lists get {+} tags (to expand into more nodes) and
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1452 those with positions just get a > as the indicator. {+} buttons will
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1453 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
1454 name will have the function FIND-FUN and not token."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1455 ;; Remove imenu rescan button
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1456 (if (string= (car (car lst)) "*Rescan*")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1457 (setq lst (cdr lst)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1458 ;; insert the parts
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1459 (while lst
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1460 (cond ((null (car-safe lst)) nil) ;this would be a separator
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1461 ((or (numberp (cdr-safe (car-safe lst)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1462 (markerp (cdr-safe (car-safe lst))))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1463 (speedbar-make-tag-line nil nil nil nil ;no expand button data
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1464 (car (car lst)) ;button name
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1465 find-fun ;function
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1466 (cdr (car lst)) ;token is position
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1467 'speedbar-tag-face
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1468 (1+ level)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1469 ((listp (cdr-safe (car-safe lst)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1470 (speedbar-make-tag-line 'curly ?+ expand-fun (cdr (car lst))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1471 (car (car lst)) ;button name
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1472 nil nil 'speedbar-tag-face
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1473 (1+ level)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1474 (t (message "Ooops!")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1475 (setq lst (cdr lst))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1476
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1477 ;;; Timed functions
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1478 ;;
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1479 (defun speedbar-update-contents ()
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1480 "Generically update the contents of the speedbar buffer."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1481 (interactive)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1482 ;; Set the current special buffer
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1483 (setq speedbar-desired-buffer nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1484 (if (and speedbar-mode-specific-contents-flag
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1485 speedbar-special-mode-expansion-list
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1486 (local-variable-p
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1487 'speedbar-special-mode-expansion-list))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1488 ;(eq (get major-mode 'mode-class 'special)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1489 (speedbar-update-special-contents)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1490 (speedbar-update-directory-contents)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1491
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1492 (defun speedbar-update-directory-contents ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1493 "Update the contents of the speedbar buffer based on the current directory."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1494 (let ((cbd (expand-file-name default-directory))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1495 (funclst speedbar-initial-expansion-list)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1496 (cache speedbar-full-text-cache)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1497 ;; disable stealth during update
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1498 (speedbar-stealthy-function-list nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1499 (use-cache nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1500 ;; Because there is a bug I can't find just yet
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1501 (inhibit-quit nil))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1502 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1503 (set-buffer speedbar-buffer)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1504 ;; 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
1505 ;; really a request to update existing contents, so we must be
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1506 ;; careful with our text cache!
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1507 (if (member cbd speedbar-shown-directories)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1508 (setq cache nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1509 ;; If this directory is NOT in the current list of available
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1510 ;; paths, then use the cache, and set the cache to our new
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1511 ;; value. Make sure to unhighlight the current file, or if we
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1512 ;; come back to this directory, it might be a different file
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1513 ;; and then we get a mess!
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1514 (if (> (point-max) 1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1515 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1516 (speedbar-clear-current-file)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1517 (setq speedbar-full-text-cache
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1518 (cons speedbar-shown-directories (buffer-string)))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1519
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1520 ;; Check if our new directory is in the list of directories
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1521 ;; show in the text-cahce
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1522 (if (member cbd (car cache))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1523 (setq speedbar-shown-directories (car cache)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1524 use-cache t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1525 ;; default the shown directories to this list...
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1526 (setq speedbar-shown-directories (list cbd)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1527 )
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1528 (setq speedbar-last-selected-file nil)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1529 (speedbar-with-writable
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1530 (setq default-directory cbd)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1531 (erase-buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1532 (if use-cache
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1533 (insert (cdr cache))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1534 (while funclst
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1535 (funcall (car funclst) cbd 0)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1536 (setq funclst (cdr funclst)))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1537 (goto-char (point-min))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1538 (speedbar-reconfigure-menubar))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1539
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1540 (defun speedbar-update-special-contents ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1541 "Used the mode-specific variable to fill in the speedbar buffer.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1542 This should only be used by modes classified as special."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1543 (let ((funclst speedbar-special-mode-expansion-list)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1544 (specialbuff (current-buffer)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1545 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1546 (setq speedbar-desired-buffer specialbuff)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1547 (set-buffer speedbar-buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1548 ;; If we are leaving a directory, cache it.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1549 (if (not speedbar-shown-directories)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1550 ;; Do nothing
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1551 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1552 ;; Clean up directory maintenance stuff
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1553 (speedbar-clear-current-file)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1554 (setq speedbar-full-text-cache
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1555 (cons speedbar-shown-directories (buffer-string))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1556 speedbar-shown-directories nil))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1557 ;; Now fill in the buffer with our newly found specialized list.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1558 (speedbar-with-writable
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1559 (while funclst
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1560 ;; We do not erase the buffer because these functions may
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1561 ;; decide NOT to update themselves.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1562 (funcall (car funclst) specialbuff)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1563 (setq funclst (cdr funclst))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1564 (goto-char (point-min))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1565 (speedbar-reconfigure-menubar))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1566
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1567 (defun speedbar-timer-fn ()
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1568 "Run whenever emacs is idle to update the speedbar item."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1569 (if (not (and (frame-live-p speedbar-frame)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1570 (frame-live-p speedbar-attached-frame)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1571 (speedbar-set-timer nil)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1572 (condition-case nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1573 ;; 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
1574 (save-match-data
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1575 (if (and (frame-visible-p speedbar-frame) speedbar-update-flag)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1576 (let ((af (selected-frame)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1577 (save-window-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1578 (select-frame speedbar-attached-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1579 ;; make sure we at least choose a window to
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1580 ;; get a good directory from
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1581 (if (string-match "\\*Minibuf-[0-9]+\\*" (buffer-name))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1582 (other-window 1))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1583 ;; Update for special mode all the time!
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1584 (if (and speedbar-mode-specific-contents-flag
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1585 speedbar-special-mode-expansion-list
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1586 (local-variable-p
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1587 'speedbar-special-mode-expansion-list))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1588 ;(eq (get major-mode 'mode-class 'special)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1589 (speedbar-update-special-contents)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1590 ;; Update all the contents if directories change!
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1591 (if (or (member (expand-file-name default-directory)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1592 speedbar-shown-directories)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1593 (string-match speedbar-ignored-path-regexp
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1594 (expand-file-name default-directory))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1595 (member major-mode speedbar-ignored-modes)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1596 (eq af speedbar-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1597 (not (buffer-file-name)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1598 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1599 (if (<= 1 speedbar-verbosity-level)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1600 (message "Updating speedbar to: %s..."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1601 default-directory))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1602 (speedbar-update-directory-contents)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1603 (if (<= 1 speedbar-verbosity-level)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1604 (message "Updating speedbar to: %s...done"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1605 default-directory))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1606 (select-frame af))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1607 ;; Now run stealthy updates of time-consuming items
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1608 (speedbar-stealthy-updates))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1609 ;; errors that might occur
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1610 (error (message "Speedbar error!")))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1611 ;; Reset the timer
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1612 (speedbar-set-timer speedbar-update-speed))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1613 (run-hooks 'speedbar-timer-hook)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1614 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1615
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1616
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1617 ;;; Stealthy activities
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1618 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1619 (defun speedbar-stealthy-updates ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1620 "For a given speedbar, run all items in the stealthy function list.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1621 Each item returns t if it completes successfully, or nil if
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1622 interrupted by the user."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1623 (let ((l speedbar-stealthy-function-list))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1624 (unwind-protect
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1625 (while (and l (funcall (car l)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1626 (sit-for 0)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1627 (setq l (cdr l)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1628 ;(message "Exit with %S" (car l))
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-reset-scanners ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1632 "Reset any variables used by functions in the stealthy list as state.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1633 If new functions are added, their state needs to be updated here."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1634 (setq speedbar-vc-to-do-point t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1635 )
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1636
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1637 (defun speedbar-clear-current-file ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1638 "Locate the file thought to be current, and unhighlight it."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1639 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1640 (set-buffer speedbar-buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1641 (if speedbar-last-selected-file
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1642 (speedbar-with-writable
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1643 (goto-char (point-min))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1644 (if (and
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1645 speedbar-last-selected-file
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1646 (re-search-forward
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1647 (concat " \\(" (regexp-quote speedbar-last-selected-file)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1648 "\\)\\(" (regexp-quote speedbar-vc-indicator)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1649 "\\)?\n")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1650 nil t))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1651 (put-text-property (match-beginning 1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1652 (match-end 1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1653 'face
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1654 'speedbar-file-face))))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1655
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1656 (defun speedbar-update-current-file ()
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1657 "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
1658 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
1659 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
1660 updated."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1661 (let* ((lastf (selected-frame))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1662 (newcfd (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1663 (select-frame speedbar-attached-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1664 (let ((rf (if (buffer-file-name)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1665 (buffer-file-name)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1666 nil)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1667 (select-frame lastf)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1668 rf)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1669 (newcf (if newcfd (file-name-nondirectory newcfd)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1670 (lastb (current-buffer))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1671 (sucf-recursive (boundp 'sucf-recursive)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1672 (if (and newcf
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1673 ;; check here, that way we won't refresh to newcf until
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1674 ;; its been written, thus saving ourselves some time
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1675 (file-exists-p newcf)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1676 (not (string= newcf speedbar-last-selected-file)))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1677 (progn
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1678 ;; It is important to select the frame, otherwise the window
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1679 ;; 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
1680 ;; search-forward command.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1681 (select-frame speedbar-frame)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1682 ;; Remove the old file...
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1683 (speedbar-clear-current-file)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1684 ;; now highlight the new one.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1685 (set-buffer speedbar-buffer)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1686 (speedbar-with-writable
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1687 (goto-char (point-min))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1688 (if (re-search-forward
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1689 (concat " \\(" (regexp-quote newcf) "\\)\\("
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1690 (regexp-quote speedbar-vc-indicator)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1691 "\\)?\n") nil t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1692 ;; put the property on it
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1693 (put-text-property (match-beginning 1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1694 (match-end 1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1695 'face
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1696 'speedbar-selected-face)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1697 ;; Oops, it's not in the list. Should it be?
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1698 (if (and (string-match speedbar-file-regexp newcf)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1699 (string= (file-name-directory newcfd)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1700 (expand-file-name default-directory)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1701 ;; yes, it is (we will ignore unknowns for now...)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1702 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1703 (speedbar-refresh)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1704 (if (re-search-forward
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1705 (concat " \\(" (regexp-quote newcf) "\\)\n") nil t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1706 ;; put the property on it
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1707 (put-text-property (match-beginning 1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1708 (match-end 1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1709 'face
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1710 'speedbar-selected-face)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1711 ;; if it's not in there now, whatever...
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1712 ))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1713 (setq speedbar-last-selected-file newcf))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1714 (if (not sucf-recursive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1715 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1716 (forward-line -1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1717 (speedbar-position-cursor-on-line)))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1718 (set-buffer lastb)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1719 (select-frame lastf)
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 ;; return that we are done with this activity.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1722 t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1723
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1724 ;; If it's being used, check for it
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1725 (eval-when-compile (or (featurep 'xemacs) (require 'ange-ftp)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1726
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1727 (defun speedbar-check-vc ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1728 "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
1729 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
1730 to add more types of version control systems."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1731 ;; 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
1732 ;; then set to nil (do nothing) otherwise, start at the beginning
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1733 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1734 (set-buffer speedbar-buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1735 (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
1736 (speedbar-vc-check-dir-p default-directory)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1737 (not (and (featurep 'ange-ftp)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1738 (string-match (car
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1739 (if speedbar-xemacsp
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1740 ange-ftp-path-format
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1741 ange-ftp-name-format))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1742 (expand-file-name default-directory)))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1743 (setq speedbar-vc-to-do-point 0))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1744 (if (numberp speedbar-vc-to-do-point)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1745 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1746 (goto-char speedbar-vc-to-do-point)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1747 (while (and (not (input-pending-p))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1748 (re-search-forward "^\\([0-9]+\\):\\s-*\\[[+-]\\] " nil t))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1749 (setq speedbar-vc-to-do-point (point))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1750 (if (speedbar-check-vc-this-line)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1751 (speedbar-with-writable
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1752 (insert speedbar-vc-indicator))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1753 (if (input-pending-p)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1754 ;; return that we are incomplete
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1755 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1756 ;; we are done, set to-do to nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1757 (setq speedbar-vc-to-do-point nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1758 ;; and return t
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1759 t))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1760 t)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1761
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1762 (defun speedbar-check-vc-this-line ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1763 "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
1764 The one caller-requirement is that the last regexp matching operation
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1765 has the current depth stored in (MATCHSTRING 1), and that the cursor
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1766 is right in front of the file name."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1767 (let* ((d (string-to-int (match-string 1)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1768 (f (speedbar-line-path d))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1769 (fn (buffer-substring-no-properties
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1770 (point) (progn (end-of-line) (point))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1771 (fulln (concat f fn)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1772 (if (<= 2 speedbar-verbosity-level)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1773 (message "Speedbar vc check...%s" fulln))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1774 (and (file-writable-p fulln)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1775 (speedbar-this-file-in-vc f fn))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1776
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1777 (defun speedbar-vc-check-dir-p (path)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1778 "Return t if we should bother checking PATH for version control files.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1779 This can be overloaded to add new types of version control systems."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1780 (or
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1781 (file-exists-p (concat path "RCS/"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1782 ;; If SCCS is added in `speedbar-this-file-in-vc'
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1783 ;; (file-exists-p (concat path "SCCS/"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1784 ;; (file-exists-p (getenv "SCCSPATHTHINGIDONTREMEMBER"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1785 ))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1786
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1787 (defun speedbar-this-file-in-vc (path name)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1788 "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
1789 You can add new VC systems by overriding this function. You can
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1790 optimize this function by overriding it and only doing those checks
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1791 that will occur on your system."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1792 (or
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1793 (file-exists-p (concat path "RCS/" name ",v"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1794 ;; Is this right? I don't recall
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1795 ;;(file-exists-p (concat path "SCCS/," fn))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1796 ;;(file-exists-p (concat (getenv "SCCSPATHTHING") "/SCCS/," fn))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1797 ))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1798
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1799 ;;; Clicking Activity
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1800 ;;
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1801 (defun speedbar-quick-mouse (e)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1802 "Since mouse events are strange, this will keep the mouse nicely positioned.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1803 This should be bound to mouse event E."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1804 (interactive "e")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1805 (mouse-set-point e)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1806 (speedbar-position-cursor-on-line)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1807 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1808
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1809 (defun speedbar-position-cursor-on-line ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1810 "Position the cursor on a line."
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1811 (let ((oldpos (point)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1812 (beginning-of-line)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1813 (if (looking-at "[0-9]+:\\s-*..?.? ")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1814 (goto-char (1- (match-end 0)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1815 (goto-char oldpos))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1816
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1817 (defun speedbar-power-click (e)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1818 "Activate any speedbar button as a power click.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1819 This should be bound to mouse event E."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1820 (interactive "e")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1821 (let ((speedbar-power-click t))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1822 (speedbar-click e)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1823
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1824 (defun speedbar-click (e)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1825 "Activate any speedbar buttons where the mouse is clicked.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1826 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
1827 with a mouse face that has a text property called `speedbar-function'.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1828 This should be bound to mouse event E."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1829 (interactive "e")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1830 (mouse-set-point e)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1831 (speedbar-do-function-pointer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1832 (speedbar-quick-mouse e))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1833
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1834 (defun speedbar-do-function-pointer ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1835 "Look under the cursor and examine the text properties.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1836 From this extract the file/tag name, token, indentation level and call
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1837 a function if appropriate"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1838 (let* ((fn (get-text-property (point) 'speedbar-function))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1839 (tok (get-text-property (point) 'speedbar-token))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1840 ;; The 1-,+ is safe because scaning starts AFTER the point
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1841 ;; specified. This lets the search include the character the
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1842 ;; cursor is on.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1843 (tp (previous-single-property-change
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1844 (1+ (point)) 'speedbar-function))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1845 (np (next-single-property-change
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1846 (point) 'speedbar-function))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1847 (txt (buffer-substring-no-properties (or tp (point-min))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1848 (or np (point-max))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1849 (dent (save-excursion (beginning-of-line)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1850 (string-to-number
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1851 (if (looking-at "[0-9]+")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1852 (buffer-substring-no-properties
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1853 (match-beginning 0) (match-end 0))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1854 "0")))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1855 ;;(message "%S:%S:%S:%s" fn tok txt dent)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1856 (and fn (funcall fn txt tok dent)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1857 (speedbar-position-cursor-on-line))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1858
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1859 ;;; Reading info from the speedbar buffer
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1860 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1861 (defun speedbar-line-file (&optional p)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1862 "Retrieve the file or whatever from the line at P point.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1863 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
1864 directory, then it is the directory name."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1865 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1866 (save-match-data
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1867 (beginning-of-line)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1868 (if (looking-at (concat
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1869 "\\([0-9]+\\): *[[<][-+][]>] \\([^ \n]+\\)\\("
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1870 (regexp-quote speedbar-vc-indicator)
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 (let* ((depth (string-to-int (match-string 1)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1873 (path (speedbar-line-path depth))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1874 (f (match-string 2)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1875 (concat path f))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1876 nil))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1877
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1878 (defun speedbar-goto-this-file (file)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1879 "If FILE is displayed, goto this line and return t.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1880 Otherwise do not move and return nil."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1881 (let ((path (substring (file-name-directory (expand-file-name file))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1882 (length (expand-file-name default-directory))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1883 (dest (point)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1884 (save-match-data
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1885 (goto-char (point-min))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1886 ;; scan all the directories
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1887 (while (and path (not (eq path t)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1888 (if (string-match "^/?\\([^/]+\\)" path)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1889 (let ((pp (match-string 1 path)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1890 (if (save-match-data
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1891 (re-search-forward (concat "> " (regexp-quote pp) "$")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1892 nil t))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1893 (setq path (substring path (match-end 1)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1894 (setq path nil)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1895 (setq path t)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1896 ;; find the file part
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1897 (if (or (not path) (string= (file-name-nondirectory file) ""))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1898 ;; only had a dir part
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1899 (if path
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1900 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1901 (speedbar-position-cursor-on-line)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1902 t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1903 (goto-char dest) nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1904 ;; find the file part
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1905 (let ((nd (file-name-nondirectory file)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1906 (if (re-search-forward
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1907 (concat "] \\(" (regexp-quote nd)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1908 "\\)\\(" (regexp-quote speedbar-vc-indicator) "\\)?$")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1909 nil t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1910 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1911 (speedbar-position-cursor-on-line)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1912 t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1913 (goto-char dest)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1914 nil))))))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1915
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1916 (defun speedbar-line-path (depth)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1917 "Retrieve the pathname associated with the current line.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1918 This may require traversing backwards from DEPTH and combining the default
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1919 directory with these items."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1920 (save-excursion
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1921 (save-match-data
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1922 (let ((path nil))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1923 (setq depth (1- depth))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1924 (while (/= depth -1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1925 (if (not (re-search-backward (format "^%d:" depth) nil t))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1926 (error "Error building path of tag")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1927 (cond ((looking-at "[0-9]+:\\s-*<->\\s-+\\([^\n]+\\)$")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1928 (setq path (concat (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 "/"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1931 path)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1932 ((looking-at "[0-9]+:\\s-*[-]\\s-+\\([^\n]+\\)$")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1933 ;; This is the start of our path.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1934 (setq path (buffer-substring-no-properties
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1935 (match-beginning 1) (match-end 1))))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1936 (setq depth (1- depth)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1937 (if (and path
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1938 (string-match (concat (regexp-quote speedbar-vc-indicator) "$")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1939 path))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1940 (setq path (substring path 0 (match-beginning 0))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1941 (concat default-directory path)))))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1942
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1943 (defun speedbar-edit-line ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1944 "Edit whatever tag or file is on the current speedbar line."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1945 (interactive)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1946 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1947 (beginning-of-line)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1948 ;; 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
1949 ;; perfectly allowed.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1950 (re-search-forward "[]>}] [a-zA-Z0-9]"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1951 (save-excursion (end-of-line) (point)) t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1952 (speedbar-do-function-pointer)))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1953
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1954 (defun speedbar-expand-line ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1955 "Expand the line under the cursor."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1956 (interactive)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1957 (beginning-of-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1958 (re-search-forward ":\\s-*.\\+. " (save-excursion (end-of-line) (point)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1959 (forward-char -2)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1960 (speedbar-do-function-pointer))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1961
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1962 (defun speedbar-contract-line ()
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1963 "Contract the line under the cursor."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1964 (interactive)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1965 (beginning-of-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1966 (re-search-forward ":\\s-*.-. " (save-excursion (end-of-line) (point)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1967 (forward-char -2)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1968 (speedbar-do-function-pointer))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1969
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1970 (defun speedbar-maybee-jump-to-attached-frame ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1971 "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
1972 (if (numberp last-input-char)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1973 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1974 (select-frame speedbar-attached-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1975 (other-frame 0))))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1976
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1977 (defun speedbar-find-file (text token indent)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1978 "Speedbar click handler for filenames.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1979 TEXT, the file will be displayed in the attached frame.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1980 TOKEN is unused, but required by the click handler. INDENT is the
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1981 current indentation level."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1982 (let ((cdd (speedbar-line-path indent)))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1983 (speedbar-find-file-in-frame (concat cdd text))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1984 (speedbar-stealthy-updates)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1985 ;; Reset the timer with a new timeout when cliking a file
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1986 ;; in case the user was navigating directories, we can cancel
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1987 ;; that other timer.
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1988 (speedbar-set-timer speedbar-update-speed))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1989 (speedbar-maybee-jump-to-attached-frame))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1990
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1991 (defun speedbar-dir-follow (text token indent)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1992 "Speedbar click handler for directory names.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1993 Clicking a directory will cause the speedbar to list files in the
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1994 the subdirectory TEXT. TOKEN is an unused requirement. The
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1995 subdirectory chosen will be at INDENT level."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
1996 (setq default-directory
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1997 (concat (expand-file-name (concat (speedbar-line-path indent) text))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1998 "/"))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1999 ;; Because we leave speedbar as the current buffer,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2000 ;; update contents will change directory without
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2001 ;; having to touch the attached frame.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2002 (speedbar-update-contents)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2003 (speedbar-set-timer speedbar-navigating-speed)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2004 (setq speedbar-last-selected-file nil)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2005 (speedbar-stealthy-updates))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2006
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2007 (defun speedbar-delete-subblock (indent)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2008 "Delete text from point to indentation level INDENT or greater.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2009 Handles end-of-sublist smartly."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2010 (speedbar-with-writable
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2011 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2012 (end-of-line) (forward-char 1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2013 (while (and (not (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2014 (re-search-forward (format "^%d:" indent)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2015 nil t)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2016 (>= indent 0))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2017 (setq indent (1- indent)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2018 (delete-region (point) (if (>= indent 0)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2019 (match-beginning 0)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2020 (point-max))))))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2021
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2022 (defun speedbar-dired (text token indent)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2023 "Speedbar click handler for directory expand button.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2024 Clicking this button expands or contracts a directory. TEXT is the
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2025 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
2026 expanded. INDENT is the current indentation level."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2027 (cond ((string-match "+" text) ;we have to expand this dir
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2028 (setq speedbar-shown-directories
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2029 (cons (expand-file-name
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2030 (concat (speedbar-line-path indent) token "/"))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2031 speedbar-shown-directories))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2032 (speedbar-change-expand-button-char ?-)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2033 (speedbar-reset-scanners)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2034 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2035 (end-of-line) (forward-char 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2036 (speedbar-with-writable
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2037 (speedbar-default-directory-list
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2038 (concat (speedbar-line-path indent) token "/")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2039 (1+ indent)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2040 ((string-match "-" text) ;we have to contract this node
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2041 (speedbar-reset-scanners)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2042 (let ((oldl speedbar-shown-directories)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2043 (newl nil)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2044 (td (expand-file-name
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2045 (concat (speedbar-line-path indent) token))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2046 (while oldl
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2047 (if (not (string-match (concat "^" (regexp-quote td)) (car oldl)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2048 (setq newl (cons (car oldl) newl)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2049 (setq oldl (cdr oldl)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2050 (setq speedbar-shown-directories newl))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2051 (speedbar-change-expand-button-char ?+)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2052 (speedbar-delete-subblock indent)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2053 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2054 (t (error "Ooops... not sure what to do.")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2055 (speedbar-center-buffer-smartly)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2056 (setq speedbar-last-selected-file nil)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2057 (save-excursion (speedbar-stealthy-updates)))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2058
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2059 (defun speedbar-directory-buttons-follow (text token indent)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2060 "Speedbar click handler for default directory buttons.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2061 TEXT is the button clicked on. TOKEN is the directory to follow.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2062 INDENT is the current indentation level and is unused."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2063 (setq default-directory token)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2064 ;; Because we leave speedbar as the current buffer,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2065 ;; update contents will change directory without
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2066 ;; having to touch the attached frame.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2067 (speedbar-update-contents)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2068 (speedbar-set-timer speedbar-navigating-speed))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2069
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2070 (defun speedbar-tag-file (text token indent)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2071 "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
2072 The parameter TEXT and TOKEN are required, where TEXT is the button
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2073 clicked, and TOKEN is the file to expand. INDENT is the current
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2074 indentation level."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2075 (cond ((string-match "+" text) ;we have to expand this file
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2076 (let* ((fn (expand-file-name (concat (speedbar-line-path indent)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2077 token)))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2078 (lst (if speedbar-use-imenu-flag
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2079 (let ((tim (speedbar-fetch-dynamic-imenu fn)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2080 (if (eq tim t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2081 (speedbar-fetch-dynamic-etags fn)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2082 tim))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2083 (speedbar-fetch-dynamic-etags fn))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2084 ;; if no list, then remove expando button
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2085 (if (not lst)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2086 (speedbar-change-expand-button-char ??)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2087 (speedbar-change-expand-button-char ?-)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2088 (speedbar-with-writable
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2089 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2090 (end-of-line) (forward-char 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2091 (speedbar-insert-generic-list indent
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2092 lst 'speedbar-tag-expand
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2093 'speedbar-tag-find))))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2094 ((string-match "-" text) ;we have to contract this node
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2095 (speedbar-change-expand-button-char ?+)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2096 (speedbar-delete-subblock indent))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2097 (t (error "Ooops... not sure what to do.")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2098 (speedbar-center-buffer-smartly))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2099
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2100 (defun speedbar-tag-find (text token indent)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2101 "For the tag TEXT in a file TOKEN, goto that position.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2102 INDENT is the current indentation level."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2103 (let ((file (speedbar-line-path indent)))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2104 (speedbar-find-file-in-frame file)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2105 (save-excursion (speedbar-stealthy-updates))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2106 ;; Reset the timer with a new timeout when cliking a file
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2107 ;; in case the user was navigating directories, we can cancel
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2108 ;; that other timer.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2109 (speedbar-set-timer speedbar-update-speed)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2110 (goto-char token)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2111 ;;(recenter)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2112 (speedbar-maybee-jump-to-attached-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2113 ))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2114
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2115 (defun speedbar-tag-expand (text token indent)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2116 "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
2117 Etags does not support this feature. TEXT will be the button
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2118 string. TOKEN will be the list, and INDENT is the current indentation
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2119 level."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2120 (cond ((string-match "+" text) ;we have to expand this file
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2121 (speedbar-change-expand-button-char ?-)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2122 (speedbar-with-writable
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2123 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2124 (end-of-line) (forward-char 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2125 (speedbar-insert-generic-list indent
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2126 token 'speedbar-tag-expand
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2127 'speedbar-tag-find))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2128 ((string-match "-" text) ;we have to contract this node
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2129 (speedbar-change-expand-button-char ?+)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2130 (speedbar-delete-subblock indent))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2131 (t (error "Ooops... not sure what to do.")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2132 (speedbar-center-buffer-smartly))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2133
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2134 ;;; Loading files into the attached frame.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2135 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2136 (defun speedbar-find-file-in-frame (file)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2137 "This will load FILE into the speedbar attached frame.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2138 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
2139 frame instead."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2140 (let* ((buff (find-file-noselect file))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2141 (bwin (get-buffer-window buff 0)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2142 (if bwin
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2143 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2144 (select-window bwin)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2145 (raise-frame (window-frame bwin)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2146 (if speedbar-power-click
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2147 (let ((pop-up-frames t)) (select-window (display-buffer buff)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2148 (select-frame speedbar-attached-frame)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2149 (switch-to-buffer buff))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2150 )
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2151
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2152 ;;; Centering Utility
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2153 ;;
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2154 (defun speedbar-center-buffer-smartly ()
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2155 "Recenter a speedbar buffer so the current indentation level is all visible.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2156 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
2157 interested in."
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2158 (if (<= (count-lines (point-min) (point-max))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2159 (window-height (selected-window)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2160 ;; whole buffer fits
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2161 (let ((cp (point)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2162 (goto-char (point-min))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2163 (recenter 0)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2164 (goto-char cp))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2165 ;; too big
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2166 (let (depth start end exp p)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2167 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2168 (beginning-of-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2169 (setq depth (if (looking-at "[0-9]+")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2170 (string-to-int (buffer-substring-no-properties
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2171 (match-beginning 0) (match-end 0)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2172 0))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2173 (setq exp (format "^%d:\\s-*[[{<]\\([?+-]\\)[]>}]" depth)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2174 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2175 (end-of-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2176 (if (re-search-backward exp nil t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2177 (setq start (point))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2178 (error "Center error"))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2179 (save-excursion ;Not sure about this part.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2180 (end-of-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2181 (setq p (point))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2182 (while (and (not (re-search-forward exp nil t))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2183 (>= depth 0))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2184 (setq depth (1- depth))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2185 (setq exp (format "^%d:\\s-*[[{<]\\([?+-]\\)[]>}]" depth)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2186 (if (/= (point) p)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2187 (setq end (point))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2188 (setq end (point-max)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2189 ;; Now work out the details of centering
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2190 (let ((nl (count-lines start end))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2191 (cp (point)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2192 (if (> nl (window-height (selected-window)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2193 ;; We can't fit it all, so just center on cursor
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2194 (progn (goto-char start)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2195 (recenter 1))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2196 ;; we can fit everything on the screen, but...
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2197 (if (and (pos-visible-in-window-p start (selected-window))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2198 (pos-visible-in-window-p end (selected-window)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2199 ;; we are all set!
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2200 nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2201 ;; we need to do something...
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2202 (goto-char start)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2203 (let ((newcent (/ (- (window-height (selected-window)) nl) 2))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2204 (lte (count-lines start (point-max))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2205 (if (and (< (+ newcent lte) (window-height (selected-window)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2206 (> (- (window-height (selected-window)) lte 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2207 newcent))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2208 (setq newcent (- (window-height (selected-window))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2209 lte 1)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2210 (recenter newcent))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2211 (goto-char cp)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2212
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2213
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2214 ;;; Tag Management -- Imenu
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2215 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2216 (if (string-match "XEmacs" emacs-version)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2217
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2218 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2219
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2220 (eval-when-compile (if (locate-library "imenu") (require 'imenu)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2221
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2222 (defun speedbar-fetch-dynamic-imenu (file)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2223 "Load FILE into a buffer, and generate tags using Imenu.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2224 Returns the tag list, or t for an error."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2225 ;; Load this AND compile it in
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2226 (require 'imenu)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2227 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2228 (set-buffer (find-file-noselect file))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2229 (condition-case nil
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2230 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2231 (if speedbar-power-click (setq imenu--index-alist nil))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2232 (imenu--make-index-alist t))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2233 (error t))))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2234 )
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2235
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2236 ;;; Tag Management -- etags (XEmacs compatibility part)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2237 ;;
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2238 (defvar speedbar-fetch-etags-parse-list
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2239 '(;; Note that java has the same parse-group as c
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2240 ("\\.\\([cChH]\\|c++\\|cpp\\|cc\\|hh\\|java\\)$" . speedbar-parse-c-or-c++tag)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2241 ("\\.el\\|\\.emacs" . "defun\\s-+\\(\\(\\w\\|[-_]\\)+\\)\\s-*\C-?")
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2242 ("\\.tex$" . speedbar-parse-tex-string)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2243 ("\\.p" .
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2244 "\\(\\(FUNCTION\\|function\\|PROCEDURE\\|procedure\\)\\s-+\\([a-zA-Z0-9_.:]+\\)\\)\\s-*(?^?")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2245
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2246 )
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2247 "Associations of file extensions and expressions for extracting tags.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2248 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
2249 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
2250 extract an element from the tags output. If the output is complex,
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2251 use a function symbol instead of regexp. The function should expect
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2252 to be at the beginning of a line in the etags buffer.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2253
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2254 This variable is ignored if `speedbar-use-imenu-flag' is t")
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2255
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2256 (defvar speedbar-fetch-etags-command "etags"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2257 "*Command used to create an etags file.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2258
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2259 This variable is ignored if `speedbar-use-imenu-flag' is t")
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2260
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2261 (defvar speedbar-fetch-etags-arguments '("-D" "-I" "-o" "-")
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2262 "*List of arguments to use with `speedbar-fetch-etags-command'.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2263 This creates an etags output buffer. Use `speedbar-toggle-etags' to
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2264 modify this list conveniently.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2265
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2266 This variable is ignored if `speedbar-use-imenu-flag' is t")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2267
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2268 (defun speedbar-toggle-etags (flag)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2269 "Toggle FLAG in `speedbar-fetch-etags-arguments'.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2270 FLAG then becomes a member of etags command line arguments. If flag
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2271 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
2272 value is \"show\" then toggle the value of
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2273 `speedbar-show-unknown-files'.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2274
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2275 This function is a convenience function for XEmacs menu created by
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2276 Farzin Guilak <farzin@protocol.com>"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2277 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2278 (cond
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2279 ((equal flag "sort")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2280 (setq speedbar-sort-tags (not speedbar-sort-tags)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2281 ((equal flag "show")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2282 (setq speedbar-show-unknown-files (not speedbar-show-unknown-files)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2283 ((or (equal flag "-C")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2284 (equal flag "-S")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2285 (equal flag "-D"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2286 (if (member flag speedbar-fetch-etags-arguments)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2287 (setq speedbar-fetch-etags-arguments
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2288 (delete flag speedbar-fetch-etags-arguments))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2289 (add-to-list 'speedbar-fetch-etags-arguments flag)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2290 (t nil)))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2291
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2292 (defun speedbar-fetch-dynamic-etags (file)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2293 "For FILE, run etags and create a list of symbols extracted.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2294 Each symbol will be associated with it's line position in FILE."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2295 (let ((newlist nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2296 (unwind-protect
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2297 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2298 (if (get-buffer "*etags tmp*")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2299 (kill-buffer "*etags tmp*")) ;kill to clean it up
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2300 (if (<= 1 speedbar-verbosity-level) (message "Fetching etags..."))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2301 (set-buffer (get-buffer-create "*etags tmp*"))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2302 (apply 'call-process speedbar-fetch-etags-command nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2303 (current-buffer) nil
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2304 (append speedbar-fetch-etags-arguments (list file)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2305 (goto-char (point-min))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2306 (if (<= 1 speedbar-verbosity-level) (message "Fetching etags..."))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2307 (let ((expr
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2308 (let ((exprlst speedbar-fetch-etags-parse-list)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2309 (ans nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2310 (while (and (not ans) exprlst)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2311 (if (string-match (car (car exprlst)) file)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2312 (setq ans (car exprlst)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2313 (setq exprlst (cdr exprlst)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2314 (cdr ans))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2315 (if expr
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2316 (let (tnl)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2317 (while (not (save-excursion (end-of-line) (eobp)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2318 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2319 (setq tnl (speedbar-extract-one-symbol expr)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2320 (if tnl (setq newlist (cons tnl newlist)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2321 (forward-line 1)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2322 (message "Sorry, no support for a file of that extension"))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2323 )
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2324 (if speedbar-sort-tags
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2325 (sort newlist (lambda (a b) (string< (car a) (car b))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2326 (reverse newlist))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2327
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2328 ;; 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
2329 ;; sure it's needed with the different sorting method.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2330 ;;
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2331 ;(defun speedbar-clean-etags()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2332 ; "Removes spaces before the ^? character, and removes `#define',
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2333 ;return types, etc. preceding tags. This ensures that the sort operation
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2334 ;works on the tags, not the return types."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2335 ; (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2336 ; (goto-char (point-min))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2337 ; (while
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2338 ; (re-search-forward "(?[ \t](?\C-?" nil t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2339 ; (replace-match "\C-?" nil nil))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2340 ; (goto-char (point-min))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2341 ; (while
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2342 ; (re-search-forward "\\(.*[ \t]+\\)\\([^ \t\n]+.*\C-?\\)" nil t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2343 ; (delete-region (match-beginning 1) (match-end 1)))))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2344
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2345 (defun speedbar-extract-one-symbol (expr)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2346 "At point, return nil, or one alist in the form: ( symbol . position )
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2347 The line should contain output from etags. Parse the output using the
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2348 regular expression EXPR"
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2349 (let* ((sym (if (stringp expr)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2350 (if (save-excursion
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2351 (re-search-forward expr (save-excursion
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2352 (end-of-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2353 (point)) t))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2354 (buffer-substring-no-properties (match-beginning 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2355 (match-end 1)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2356 (funcall expr)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2357 (pos (let ((j (re-search-forward "[\C-?\C-a]\\([0-9]+\\),\\([0-9]+\\)"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2358 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2359 (end-of-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2360 (point))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2361 t)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2362 (if (and j sym)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2363 (1+ (string-to-int (buffer-substring-no-properties
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2364 (match-beginning 2)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2365 (match-end 2))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2366 0))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2367 (if (/= pos 0)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2368 (cons sym pos)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2369 nil)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2370
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2371 (defun speedbar-parse-c-or-c++tag ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2372 "Parse a c or c++ tag, which tends to be a little complex."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2373 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2374 (let ((bound (save-excursion (end-of-line) (point))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2375 (cond ((re-search-forward "\C-?\\([^\C-a]+\\)\C-a" 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 ((re-search-forward "\\<\\([^ \t]+\\)\\s-+new(" bound t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2379 (buffer-substring-no-properties (match-beginning 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2380 (match-end 1)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2381 ((re-search-forward "\\<\\([^ \t(]+\\)\\s-*(\C-?" bound t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2382 (buffer-substring-no-properties (match-beginning 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2383 (match-end 1)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2384 (t nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2385 )))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2386
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2387 (defun speedbar-parse-tex-string ()
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2388 "Parse a Tex string. Only find data which is relevant."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2389 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2390 (let ((bound (save-excursion (end-of-line) (point))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2391 (cond ((re-search-forward "\\(section\\|chapter\\|cite\\)\\s-*{[^\C-?}]*}?" bound t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2392 (buffer-substring-no-properties (match-beginning 0)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2393 (match-end 0)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2394 (t nil)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2395
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2396
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2397 ;;; Color loading section This is messy *Blech!*
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2398 ;;
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2399 (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
2400 "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
2401 Optionally make BOLD, ITALIC, or UNDERLINE if applicable. If the background
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2402 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
2403 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
2404 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
2405 multiple defaults and dynamically determine which colors to use."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2406 (let* ((params (frame-parameters))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2407 (disp-res (if (fboundp 'x-get-resource)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2408 (if speedbar-xemacsp
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2409 (x-get-resource ".displayType" "DisplayType" 'string)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2410 (x-get-resource ".displayType" "DisplayType"))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2411 nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2412 (display-type
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2413 (cond (disp-res (intern (downcase disp-res)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2414 ((and (fboundp 'x-display-color-p) (x-display-color-p)) 'color)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2415 (t 'mono)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2416 (bg-res (if (fboundp 'x-get-resource)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2417 (if speedbar-xemacsp
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2418 (x-get-resource ".backgroundMode" "BackgroundMode" 'string)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2419 (x-get-resource ".backgroundMode" "BackgroundMode"))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2420 nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2421 (bgmode
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2422 (cond (bg-res (intern (downcase bg-res)))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2423 ((let* ((bgc (or (cdr (assq 'background-color params))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2424 (if speedbar-xemacsp
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2425 (x-get-resource ".background"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2426 "Background" 'string)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2427 (x-get-resource ".background"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2428 "Background"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2429 ;; if no other options, default is white
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2430 "white"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2431 (bgcr (if speedbar-xemacsp
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2432 (color-instance-rgb-components
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2433 (make-color-instance bgc))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2434 (x-color-values bgc)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2435 (wcr (if speedbar-xemacsp
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2436 (color-instance-rgb-components
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2437 (make-color-instance "white"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2438 (x-color-values "white"))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2439 (< (apply '+ bgcr) (/ (apply '+ wcr) 3)))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2440 'dark)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2441 (t 'light))) ;our default
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2442 (set-p (function (lambda (face-name resource)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2443 (if speedbar-xemacsp
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2444 (x-get-resource
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2445 (concat face-name ".attribute" resource)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2446 (concat "Face.Attribute" resource)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2447 'string)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2448 (x-get-resource
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2449 (concat face-name ".attribute" resource)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2450 (concat "Face.Attribute" resource)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2451 )))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2452 (nbg (cond ((eq bgmode 'dark) d-bg)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2453 (t l-bg)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2454 (nfg (cond ((eq bgmode 'dark) d-fg)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2455 (t l-fg))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2456
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2457 (if (not (eq display-type 'color))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2458 ;; we need a face of some sort, so just make due with default
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2459 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2460 (copy-face 'default sym)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2461 (if bold (condition-case nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2462 (make-face-bold sym)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2463 (error (message "Cannot make face %s bold!"
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2464 (symbol-name sym)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2465 (if italic (condition-case nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2466 (make-face-italic sym)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2467 (error (message "Cannot make face %s italic!"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2468 (symbol-name sym)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2469 (set-face-underline-p sym underline)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2470 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2471 ;; make a colorized version of a face. Be sure to check Xdefaults
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2472 ;; for possible overrides first!
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2473 (let ((newface (make-face sym)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2474 ;; For each attribute, check if it might already be set by Xdefaults
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2475 (if (and nfg (not (funcall set-p (symbol-name sym) "Foreground")))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2476 (set-face-foreground newface nfg))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2477 (if (and nbg (not (funcall set-p (symbol-name sym) "Background")))
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2478 (set-face-background newface nbg))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2479
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2480 (if bold (condition-case nil
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2481 (make-face-bold newface)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2482 (error (message "Cannot make face %s bold!"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2483 (symbol-name sym)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2484 (if italic (condition-case nil
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2485 (make-face-italic newface)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2486 (error (message "Cannot make face %s italic!"
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2487 (symbol-name newface)))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2488 (set-face-underline-p newface underline)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2489 ))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2490
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2491 (if (x-display-color-p)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2492 (progn
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2493 (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
2494 (speedbar-load-color 'speedbar-file-face "cyan4" nil "cyan" nil nil nil nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2495 (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
2496 (speedbar-load-color 'speedbar-tag-face "brown" nil "yellow" nil nil nil nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2497 (speedbar-load-color 'speedbar-selected-face "red" nil "red" nil nil nil t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2498 (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
2499 ) ; color
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2500 (make-face 'speedbar-button-face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2501 ;;(make-face 'speedbar-file-face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2502 (copy-face 'bold 'speedbar-file-face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2503 (make-face 'speedbar-directory-face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2504 (make-face 'speedbar-tag-face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2505 ;;(make-face 'speedbar-selected-face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2506 (copy-face 'underline 'speedbar-selected-face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2507 ;;(make-face 'speedbar-highlight-face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2508 (copy-face 'highlight 'speedbar-highlight-face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2509
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2510 ) ;; monochrome
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2511
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2512 ;; some edebug hooks
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2513 (add-hook 'edebug-setup-hook
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2514 (lambda ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2515 (def-edebug-spec speedbar-with-writable def-body)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2516
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2517 ;; run load-time hooks
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2518 (run-hooks 'speedbar-load-hook)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2519
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2520 (provide 'speedbar)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 100
diff changeset
2521 ;;; speedbar ends here